コード例 #1
0
ファイル: backend.py プロジェクト: agg23/Mopidy-AppleMusic
    def browseAlbum(self, albumId):
        album = self.appleMusicClient.user_get_album(albumId,
                                                     include=['artists'])

        albumData = album['data']

        if not albumData:
            logger.error("Could not load album")
            return []

        albumRef = self.albumDataToRefs(albumData)[0]

        logger.info(albumRef)

        tracks = self.trackRelationshipsToRefs(albumData[0]['relationships'],
                                               albumRef)
        trackRefs = []

        for track in tracks:
            if not track:
                continue

            self.trackCache[track.uri] = track
            trackRefs.append(trackToRef(track))

        return trackRefs
コード例 #2
0
ファイル: backend.py プロジェクト: agg23/Mopidy-AppleMusic
    def lookup(self, uri):
        logger.info("Looking up %s", uri)

        parts = uri.split(':')
        prefix = ''

        if len(parts) > 1:
            prefix = ':'.join(parts[0:2]) + ':'

        if prefix == TRACK_PREFIX:
            return self.lookupTrack(parts[2], uri)
        pass
コード例 #3
0
ファイル: backend.py プロジェクト: agg23/Mopidy-AppleMusic
    def translate_uri(self, uri):
        logger.info("Attempting to translate uri %s", uri)

        parts = uri.split(':')

        if len(parts) < 1:
            return None

        track = self.lookupTrack(parts[len(parts) - 1])

        logger.info("Selected track url %s", track)

        if track is not None:
            return track
        else:
            return None
コード例 #4
0
ファイル: backend.py プロジェクト: agg23/Mopidy-AppleMusic
    def __init__(self, config, audio):
        super(AppleMusicBackend, self).__init__()
        self.audio = audio
        self.config = config

        developerToken = config['applemusic']['developertoken']
        userToken = config['applemusic']['usertoken']

        logger.info(config)

        self.appleMusicClient = AppleMusicClient(developerToken, userToken)

        self.library = AppleMusicLibraryProvider(
            backend=self, appleMusicClient=self.appleMusicClient)
        self.playback = AppleMusicPlaybackProvider(
            audio=audio, backend=self, appleMusicClient=self.appleMusicClient)

        self.uri_schemes = ['applemusic']
コード例 #5
0
ファイル: backend.py プロジェクト: agg23/Mopidy-AppleMusic
    def browse(self, uri):
        logger.info("Browse %s", uri)
        parts = uri.split(':')
        prefix = ''

        if len(parts) > 1:
            prefix = ':'.join(parts[0:2]) + ':'

        logger.info("Prefix %s", prefix)

        if uri == ROOT:
            logger.info("Browsing root")
            return self.sub_directory

        # All albums
        elif uri == MY_ALBUMS:
            logger.info("Browsing my albums")
            return self.browseAlbums()

        # Single album
        elif prefix == ALBUM_PREFIX:
            logger.info("Browsing album")
            return self.browseAlbum(parts[2])

        logger.info(self.appleMusicClient.user_songs(limit=10))
        pass