Example #1
0
    def _aa_search_track_to_mopidy_track(self, search_track):
        track = search_track['track']

        aa_artist_id = create_id(track['artist'])
        if 'artistId' in track:
            aa_artist_id = track['artistId'][0]
        else:
            logger.warning('No artistId for Track %r', track)

        artist = Artist(
            uri='gmusic:artist:' + aa_artist_id,
            name=track['artist'])

        album = Album(
            uri='gmusic:album:' + track['albumId'],
            name=track['album'],
            artists=[artist],
            date=unicode(track.get('year', 0)))

        return Track(
            uri='gmusic:track:' + track['storeId'],
            name=track['title'],
            artists=[artist],
            album=album,
            track_no=track.get('trackNumber', 1),
            disc_no=track.get('discNumber', 1),
            date=unicode(track.get('year', 0)),
            length=int(track['durationMillis']),
            bitrate=320)
Example #2
0
    def _aa_search_track_to_mopidy_track(self, search_track):
        track = search_track['track']

        aa_artist_id = create_id(track['artist'])
        if 'artistId' in track:
            aa_artist_id = track['artistId'][0]
        else:
            logger.warning('No artistId for Track %r', track)

        artist = Artist(uri='gmusic:artist:' + aa_artist_id,
                        name=track['artist'])

        album = Album(uri='gmusic:album:' + track['albumId'],
                      name=track['album'],
                      artists=[artist],
                      date=unicode(track.get('year', 0)))

        return Track(uri='gmusic:track:' + track['storeId'],
                     name=track['title'],
                     artists=[artist],
                     album=album,
                     track_no=track.get('trackNumber', 1),
                     disc_no=track.get('discNumber', 1),
                     date=unicode(track.get('year', 0)),
                     length=int(track['durationMillis']),
                     bitrate=320)
Example #3
0
    def _aa_search_track_to_mopidy_track(self, search_track):
        track = search_track["track"]

        aa_artist_id = create_id(track["artist"])
        if "artistId" in track:
            aa_artist_id = track["artistId"][0]
        else:
            logger.warning("No artistId for Track %r", track)

        artist = Artist(uri="gmusic:artist:" + aa_artist_id,
                        name=track["artist"])

        album = Album(
            uri="gmusic:album:" + track["albumId"],
            name=track["album"],
            artists=[artist],
            date=str(track.get("year", 0)),
        )

        return Track(
            uri="gmusic:track:" + track["storeId"],
            name=track["title"],
            artists=[artist],
            album=album,
            track_no=track.get("trackNumber", 1),
            disc_no=track.get("discNumber", 1),
            date=str(track.get("year", 0)),
            length=int(track["durationMillis"]),
            bitrate=self.backend.config["gmusic"]["bitrate"],
        )
Example #4
0
 def _to_mopidy_artist(self, song):
     name = song.get('artist', '')
     artist_id = song.get('artistId')
     if artist_id is not None:
         artist_id = artist_id[0]
     else:
         artist_id = create_id(name)
     uri = 'gmusic:artist:' + artist_id
     return Artist(uri=uri, name=name)
Example #5
0
 def _to_mopidy_artist(self, song):
     name = song.get('artist', '')
     artist_id = song.get('artistId')
     if artist_id is not None:
         artist_id = artist_id[0]
     else:
         artist_id = create_id(name)
     uri = 'gmusic:artist:' + artist_id
     return Artist(uri=uri, name=name)
Example #6
0
    def _to_mopidy_album(self, song):
        name = song.get("album", "")
        artist = self._to_mopidy_album_artist(song)
        date = str(song.get("year", 0))

        album_id = create_id(f"{artist.name}|{name}|{date}")

        uri = "gmusic:album:" + album_id
        return Album(
            uri=uri,
            name=name,
            artists=[artist],
            num_tracks=song.get("totalTrackCount"),
            num_discs=song.get("totalDiscCount"),
            date=date,
        )
Example #7
0
    def _to_mopidy_album(self, song):
        name = song.get('album', '')
        artist = self._to_mopidy_album_artist(song)
        date = unicode(song.get('year', 0))

        album_id = song.get('albumId')
        if album_id is None:
            album_id = create_id(artist.name + name + date)

        uri = 'gmusic:album:' + album_id
        images = get_images(song)
        return Album(uri=uri,
                     name=name,
                     artists=[artist],
                     num_tracks=song.get('totalTrackCount'),
                     num_discs=song.get('totalDiscCount'),
                     date=date,
                     images=images)
Example #8
0
    def _to_mopidy_album(self, song):
        name = song.get('album', '')
        artist = self._to_mopidy_album_artist(song)
        date = unicode(song.get('year', 0))

        album_id = song.get('albumId')
        if album_id is None:
            album_id = create_id(artist.name + name + date)

        uri = 'gmusic:album:' + album_id
        images = get_images(song)
        return Album(
            uri=uri,
            name=name,
            artists=[artist],
            num_tracks=song.get('totalTrackCount'),
            num_discs=song.get('totalDiscCount'),
            date=date,
            images=images)
Example #9
0
 def _aa_search_artist_album_to_mopidy_artist_album(self, album):
     name = album.get('albumArtist', '')
     if name.strip() == '':
         name = album.get('artist', '')
     uri = 'gmusic:artist:' + create_id(name)
     return Artist(uri=uri, name=name)
Example #10
0
 def _to_mopidy_album_artist(self, song):
     name = song.get('albumArtist', '')
     if name.strip() == '':
         name = song.get('artist', '')
     uri = 'gmusic:artist:' + create_id(name)
     return Artist(uri=uri, name=name)
Example #11
0
 def _to_mopidy_album_artist(self, song):
     name = song.get('albumArtist', '')
     if name.strip() == '':
         name = song.get('artist', '')
     uri = 'gmusic:artist:' + create_id(name)
     return Artist(uri=uri, name=name)
Example #12
0
 def _aa_search_artist_album_to_mopidy_artist_album(self, album):
     name = album.get('albumArtist', '')
     if name.strip() == '':
         name = album.get('artist', '')
     uri = 'gmusic:artist:' + create_id(name)
     return Artist(uri=uri, name=name)
Example #13
0
 def _aa_search_artist_album_to_mopidy_artist_album(self, album):
     name = album.get("albumArtist", "")
     if name.strip() == "":
         name = album.get("artist", "")
     uri = "gmusic:artist:" + create_id(name)
     return Artist(uri=uri, name=name)
Example #14
0
 def _to_mopidy_album_artist(self, song):
     name = song.get("albumArtist", "")
     if name.strip() == "":
         name = song.get("artist", "")
     uri = "gmusic:artist:" + create_id(name)
     return Artist(uri=uri, name=name)
Example #15
0
 def _to_mopidy_artist(self, song):
     name = song.get("artist", "")
     artist_id = create_id(name)
     uri = "gmusic:artist:" + artist_id
     return Artist(uri=uri, name=name)