Skip to content

Instantly share code, notes, and snippets.

@paramsingh
Created January 6, 2022 23:11
Show Gist options
  • Save paramsingh/3d5463c988861dbc5316c18784fc4fe2 to your computer and use it in GitHub Desktop.
Save paramsingh/3d5463c988861dbc5316c18784fc4fe2 to your computer and use it in GitHub Desktop.
Copilot is helpful
"""
{
"playlist": {
"creator": "iliekcomputers",
"date": "2021-02-28T11:41:15.994353+00:00",
"extension": {
"https://musicbrainz.org/doc/jspf#playlist": {
"creator": "iliekcomputers",
"last_modified_at": "2021-02-28T11:41:45.453529+00:00",
"public": true
}
},
"identifier": "https://listenbrainz.org/playlist/51b7ecc6-87ce-47a2-8bd9-05dd82d8e237",
"title": "India",
"track": [
{
"creator": "Prateek Kuhad",
"extension": {
"https://musicbrainz.org/doc/jspf#track": {
"added_at": "2021-02-28T11:41:45.443570+00:00",
"added_by": "iliekcomputers",
"artist_identifier": [
"https://musicbrainz.org/artist/810b210f-b461-4f02-aff2-dff91196147e"
]
}
},
"identifier": "https://musicbrainz.org/recording/600d3615-40c4-4686-97a3-754a7c463250",
"title": "cold / mess"
}
]
}
}
"""
class Track:
def __init__(self, identifier, title, creator, extension):
self.identifier = identifier
self.title = title
self.creator = creator
self.extension = extension
class Playlist:
def __init__(self, identifier, title, creator, date, extension):
self.identifier = identifier
self.title = title
self.creator = creator
self.date = date
self.extension = extension
self.tracks = []
def from_json(self, json):
self.identifier = json['playlist']['identifier']
self.title = json['playlist']['title']
self.creator = json['playlist']['creator']
self.date = json['playlist']['date']
self.extension = json['playlist']['extension']
self.tracks = []
for track in json['playlist']['track']:
self.tracks.append(
Track(track['identifier'], track['title'], track['creator'], track['extension']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment