Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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"],
        )
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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,
        )
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)