示例#1
0
 def get_album(url):
     data = extract_ldjson_blob(url, clean=True)
     if data.get('inAlbum'):
         return BandcampAlbum({
             "title": data['inAlbum'].get('name'),
             "url": data['inAlbum'].get('id', url).split("#")[0],
             'type': data['inAlbum'].get("type"),
         })
示例#2
0
 def get_comments(url):
     data = extract_ldjson_blob(url, clean=True)
     comments = []
     for d in data.get("comment", []):
         comment = {
             "text": d["text"],
             'image': d["author"].get("image"),
             "author": d["author"]["name"]
         }
         comments.append(comment)
     return comments
示例#3
0
 def get_artist(url):
     data = extract_ldjson_blob(url, clean=True)
     d = data.get("byArtist")
     if d:
         return BandcampArtist({
             "title": d.get('name'),
             "url": d.get('id', url).split("#")[0],
             'genre': d.get('genre'),
             "artist_type": d.get('type')
         }, scrap=False)
     return None
示例#4
0
 def get_releases(url):
     data = extract_ldjson_blob(url, clean=True)
     releases = []
     for d in data.get("albumRelease", []):
         release = {
             "description": d.get("description"),
             'image': d.get('image'),
             "title": d.get('name'),
             "url": d.get('id', url).split("#")[0],
             'format': d.get('musicReleaseFormat'),
         }
         releases.append(release)
     return releases
示例#5
0
 def get_track_data(url):
     data = extract_ldjson_blob(url, clean=True)
     track = {
         'dateModified': data.get('dateModified'),
         'datePublished': data.get('datePublished'),
         "url": data.get('id') or url,
         "title": data.get("name"),
         "type": data.get("type"),
         'image': data.get('image'),
         'keywords': data.get('keywords', "").split(", ")
     }
     for k, v in get_props(data).items():
         track[k] = v
     return track
示例#6
0
 def get_album_data(url):
     data = extract_ldjson_blob(url, clean=True)
     props = get_props(data)
     return {
         'dateModified': data.get('dateModified'),
         'datePublished': data.get('datePublished'),
         'description': data.get('description'),
         "url": data.get('id') or url,
         "title": data.get("name"),
         "type": data.get("type"),
         "n_tracks": data.get('numTracks'),
         'image': data.get('image'),
         'featured_track_num': props.get('featured_track_num'),
         'keywords': data.get('keywords', "").split(", ")
     }
示例#7
0
    def get_tracks(url):
        data = extract_ldjson_blob(url, clean=True)
        if not data.get("track"):
            return []

        data = data['track']

        tracks = []

        for d in data.get('itemListElement', []):
            d = d['item']
            track = {
                "title": d.get('name'),
                "url": d.get('id') or url,
                'type': d.get('type'),
            }
            for k, v in get_props(d).items():
                track[k] = v
            tracks.append(BandcampTrack(track, scrap=False))
        return tracks