Ejemplo n.º 1
0
def test_path_to_ref():
    from mopidy.m3u.translator import path_to_ref

    assert path_to_ref(b'test.m3u') == Ref.playlist(uri='m3u:test.m3u',
                                                    name='test')
    assert path_to_ref(b'Test Playlist.m3u') == Ref.playlist(
        uri='m3u:Test%20Playlist.m3u', name='Test Playlist')
Ejemplo n.º 2
0
def test_as_list_with_folders_and_ignored_unloaded_playlist(provider):
    result = provider.as_list()

    assert len(result) == 2

    assert result[0] == Ref.playlist(uri="spotify:user:alice:playlist:foo", name="Foo")
    assert result[1] == Ref.playlist(uri="spotify:playlist:bob:baz", name="Bar/Baz (by bob)")
Ejemplo n.º 3
0
    def test_as_list(self):
        result = self.provider.as_list()

        self.assertEqual(len(result), 2)
        self.assertEqual(
            result[0], Ref.playlist(uri='gmusic:playlist:boo', name='boo'))
        self.assertEqual(
            result[1], Ref.playlist(uri='gmusic:playlist:foo', name='foo'))
Ejemplo n.º 4
0
def test_as_list_with_folders_and_ignored_unloaded_playlist(provider):
    result = provider.as_list()

    assert len(result) == 2

    assert result[0] == Ref.playlist(uri='spotify:user:alice:playlist:foo',
                                     name='Foo')
    assert result[1] == Ref.playlist(uri='spotify:playlist:bob:baz',
                                     name='Bar/Baz (by bob)')
Ejemplo n.º 5
0
def test_path_to_ref():
    from mopidy.m3u.translator import path_to_ref

    assert path_to_ref(b'test.m3u') == Ref.playlist(
        uri='m3u:test.m3u', name='test'
    )
    assert path_to_ref(b'Test Playlist.m3u') == Ref.playlist(
        uri='m3u:Test%20Playlist.m3u', name='Test Playlist'
    )
Ejemplo n.º 6
0
def test_as_list_when_playlist_wont_translate(provider):
    result = provider.as_list()

    assert len(result) == 6

    assert result[0] == Ref.playlist(uri="spotify:user:alice:playlist:foo",
                                     name="Foo")
    assert result[1] == Ref.playlist(uri="spotify:user:bob:playlist:baz",
                                     name="Baz (by bob)")
def test_as_list_with_folders_and_ignored_unloaded_playlist(provider):
    result = provider.as_list()

    assert len(result) == 3

    assert result[0] == Ref.playlist(
        uri='spotify:user:alice:starred', name='Starred')
    assert result[1] == Ref.playlist(
        uri='spotify:user:alice:playlist:foo', name='Foo')
    assert result[2] == Ref.playlist(
        uri='spotify:playlist:bob:baz', name='Bar/Baz (by bob)')
Ejemplo n.º 8
0
    def as_list(self):
        if self._playlists is None:
            self.refresh()

        logger.debug("Listing TIDAL playlists..")
        refs = [Ref.playlist(uri=pl.uri, name=pl.name) for pl in self._playlists.values()]
        return sorted(refs, key=operator.attrgetter("name"))
Ejemplo n.º 9
0
 def raw_playlist_to_ref(self, playlist):
     if playlist is None:
         return None
     return Ref.playlist(
         uri=uri.get_playlist_uri(playlist.get("id")),
         name=playlist.get("name"),
     )
Ejemplo n.º 10
0
    def as_list(self):
        refs = [
            Ref.playlist(uri=i.uri, name=i.name)
            for i in self._playlists.values()
        ]

        return sorted(refs, key=operator.attrgetter('name'))
Ejemplo n.º 11
0
def list_playlists(uri, user_key):
    uri = strip_uri(uri)
    refs = refs_cache.get(uri)
    if refs is not None: return refs

    json = uri_json(uri)
    playlists = json['data']
    refs = []
    for playlist in playlists:
        user_name = playlist['name']
        key = urllib.quote(playlist['key'])
        playlist_uri = api_prefix + key + u'cloudcasts/'
        ref = Ref.playlist(name=user_name, uri=make_uri(playlist_uri))
        refs.append(ref)

    more = get_next_page_uri(json)
    if more is not None:
        more_param = more.split('/')[-1]
        more_uri = make_special_uri(user_key, uri_playlists, more_param)
        ref = Ref.directory(name=make_more_name(user_key, u'playlists'),
                            uri=make_uri(more_uri))
        refs.append(ref)

    refs_cache.add(uri, refs)
    return refs
Ejemplo n.º 12
0
def spotify_browse_process_results(results):
    logger.debug('Processing spotify browse result')
    if 'categories' in results:
        result_list = results['categories']
        browse_uri = 'spotifyweb:browse:categories:'
        arr = [Ref.directory(uri=browse_uri + cat['id'],
                             name=cat['name'])
               for cat in result_list['items']]
    elif 'playlists' in results:
        result_list = results['playlists']
        arr = [Ref.playlist(uri=playlist['uri'],
                            name=playlist['name'])
               for playlist in result_list['items']]
    elif 'albums' in results:
        result_list = results['albums']
        arr = [Ref.album(uri=album['uri'],
                         name=album['name'])
               for album in result_list['items']]
    else:
        result_list = None
        arr = []

    cont = result_list is not None and result_list['next'] is not None
    logger.debug('Spotify browse result cont: %s' % cont)
    return arr, cont
Ejemplo n.º 13
0
    def test_listallinfo_without_uri(self):
        tracks = [
            Track(uri="dummy:/a", name="a"),
            Track(uri="dummy:/foo/b", name="b"),
        ]
        self.backend.library.dummy_library = tracks
        self.backend.library.dummy_browse_result = {
            "dummy:/": [
                Ref.track(uri="dummy:/a", name="a"),
                Ref.directory(uri="dummy:/foo", name="foo"),
                Ref.album(uri="dummy:/album", name="album"),
                Ref.artist(uri="dummy:/artist", name="artist"),
                Ref.playlist(uri="dummy:/pl", name="pl"),
            ],
            "dummy:/foo": [Ref.track(uri="dummy:/foo/b", name="b")],
        }

        self.send_request("listallinfo")

        self.assertInResponse("file: dummy:/a")
        self.assertInResponse("Title: a")
        self.assertInResponse("directory: dummy/foo")
        self.assertInResponse("directory: dummy/album")
        self.assertInResponse("directory: dummy/artist")
        self.assertInResponse("directory: dummy/pl")
        self.assertInResponse("file: dummy:/foo/b")
        self.assertInResponse("Title: b")
        self.assertInResponse("OK")
Ejemplo n.º 14
0
    def test_listallinfo_without_uri(self):
        tracks = [
            Track(uri='dummy:/a', name='a'),
            Track(uri='dummy:/foo/b', name='b')
        ]
        self.backend.library.dummy_library = tracks
        self.backend.library.dummy_browse_result = {
            'dummy:/': [
                Ref.track(uri='dummy:/a', name='a'),
                Ref.directory(uri='dummy:/foo', name='foo'),
                Ref.album(uri='dummy:/album', name='album'),
                Ref.artist(uri='dummy:/artist', name='artist'),
                Ref.playlist(uri='dummy:/pl', name='pl')
            ],
            'dummy:/foo': [Ref.track(uri='dummy:/foo/b', name='b')]
        }

        self.send_request('listallinfo')

        self.assertInResponse('file: dummy:/a')
        self.assertInResponse('Title: a')
        self.assertInResponse('directory: /dummy/foo')
        self.assertInResponse('directory: /dummy/album')
        self.assertInResponse('directory: /dummy/artist')
        self.assertInResponse('directory: /dummy/pl')
        self.assertInResponse('file: dummy:/foo/b')
        self.assertInResponse('Title: b')
        self.assertInResponse('OK')
Ejemplo n.º 15
0
 def as_list(self):
     self.refresh()
     refs = [
         Ref.playlist(uri=pl.uri, name=pl.name)
         for pl in self._playlists.values()
     ]
     return sorted(refs, key=operator.attrgetter('name'))
Ejemplo n.º 16
0
def spotify_browse_process_results(results):
    logger.debug('Processing spotify browse result')
    if 'categories' in results:
        result_list = results['categories']
        browse_uri = 'spotifyweb:browse:categories:'
        arr = [
            Ref.directory(uri=browse_uri + cat['id'], name=cat['name'])
            for cat in result_list['items']
        ]
    elif 'playlists' in results:
        result_list = results['playlists']
        arr = [
            Ref.playlist(uri=playlist['uri'], name=playlist['name'])
            for playlist in result_list['items']
        ]
    elif 'albums' in results:
        result_list = results['albums']
        arr = [
            Ref.album(uri=album['uri'], name=album['name'])
            for album in result_list['items']
        ]
    else:
        result_list = None
        arr = []

    cont = result_list is not None and result_list['next'] is not None
    logger.debug('Spotify browse result cont: %s' % cont)
    return arr, cont
Ejemplo n.º 17
0
def test_as_list_when_playlist_container_isnt_loaded(session_mock, provider):
    session_mock.playlist_container = None

    result = provider.as_list()

    assert len(result) == 1

    assert result[0] == Ref.playlist(uri='spotify:user:alice:starred',
                                     name='Starred')
Ejemplo n.º 18
0
    def browse(self, uri):
        logger.debug("Request to browse %s in SpotifyWebLibraryProvider", uri)
        if uri == self.root_directory.uri:
            return self._root
        elif uri == 'spotifyweb:artists':
            return self._cache.sortedArtists
            # return Ref directory with all artists
        elif uri.startswith('spotifyweb:artist:'):
            # get artist uri
            return self._cache.artists2albums.get(uri)
            # return Ref directory with all albums for artist
        elif uri.startswith('spotifyweb:album:'):
            # get album uri
            return self._cache.albums2tracks.get(uri)
            # return Ref directory with all tracks for album
        elif uri == 'spotifyweb:albums':
            return self._cache.sortedAlbums
            # return Ref directory for all albums
        elif uri.startswith('spotifyweb:featured-playlists') or \
             uri.startswith('spotifyweb:new-releases') or \
             uri.startswith('spotifyweb:categories') :
            
            ids = uri.split(':')
            webapi_url = 'browse/' + '/'.join(ids[1:])

            # we browse the /playlists endpoint for categories
            if len(ids) == 3 and ids[1] == 'categories':
                webapi_url += '/playlists'

            try:
                offset = 0
                arr = []

                while True:
                    results = self.sp_webapi()._get(webapi_url, limit=50, offset=offset)
                    if results.has_key('categories'):
                        result_list = results['categories']
                        arr += [ Ref.directory(uri='spotifyweb:categories:'+cat['id'],
                                        name=cat['name']) for cat in result_list['items']]
                    elif results.has_key('playlists'):
                        result_list = results['playlists']
                        arr += [ Ref.playlist(uri=playlist['uri'],
                                        name=playlist['name']) for playlist in result_list['items']]
                    elif results.has_key('albums'):
                        result_list = results['albums']
                        arr += [ Ref.album(uri=album['uri'],
                                        name=album['name']) for album in result_list['items']]
                    if result_list['next'] is None:
                        break
                    offset = len(arr)

                return arr
            except spotipy.SpotifyException as e:
                logger.info('spotipy called failed')
                return []
        else:
            return []
Ejemplo n.º 19
0
    def as_list(self):
        if self._playlists is None:
            self.refresh()

        logger.debug("Listing TIDAL playlists..")
        refs = [
            Ref.playlist(uri=pl.uri, name=pl.name)
            for pl in self._playlists.values()
        ]
        return sorted(refs, key=operator.attrgetter('name'))
def test_as_list_when_playlist_container_isnt_loaded(
        session_mock, provider):
    session_mock.playlist_container = None

    result = provider.as_list()

    assert len(result) == 1

    assert result[0] == Ref.playlist(
        uri='spotify:user:alice:starred', name='Starred')
Ejemplo n.º 21
0
    def as_list(self):
        '''
        Returns a list of playlist names sorted in alpha order
        '''
        refs = [
            Ref.playlist(uri=i.uri, name=i.name)
            for i in self._playlists.values()
        ]

        return sorted(refs, key=operator.attrgetter('name'))
Ejemplo n.º 22
0
    def setUp(self):  # noqa: N802
        self.plr1a = Ref.playlist(name="A", uri="dummy1:pl:a")
        self.plr1b = Ref.playlist(name="B", uri="dummy1:pl:b")
        self.plr2a = Ref.playlist(name="A", uri="dummy2:pl:a")
        self.plr2b = Ref.playlist(name="B", uri="dummy2:pl:b")

        self.pl1a = Playlist(name="A", tracks=[Track(uri="dummy1:t:a")])
        self.pl1b = Playlist(name="B", tracks=[Track(uri="dummy1:t:b")])
        self.pl2a = Playlist(name="A", tracks=[Track(uri="dummy2:t:a")])
        self.pl2b = Playlist(name="B", tracks=[Track(uri="dummy2:t:b")])

        self.sp1 = mock.Mock(spec=backend.PlaylistsProvider)
        self.sp1.as_list.return_value.get.return_value = [
            self.plr1a,
            self.plr1b,
        ]
        self.sp1.lookup.return_value.get.side_effect = [self.pl1a, self.pl1b]

        self.sp2 = mock.Mock(spec=backend.PlaylistsProvider)
        self.sp2.as_list.return_value.get.return_value = [
            self.plr2a,
            self.plr2b,
        ]
        self.sp2.lookup.return_value.get.side_effect = [self.pl2a, self.pl2b]

        self.backend1 = mock.Mock()
        self.backend1.actor_ref.actor_class.__name__ = "Backend1"
        self.backend1.uri_schemes.get.return_value = ["dummy1"]
        self.backend1.playlists = self.sp1

        self.backend2 = mock.Mock()
        self.backend2.actor_ref.actor_class.__name__ = "Backend2"
        self.backend2.uri_schemes.get.return_value = ["dummy2"]
        self.backend2.playlists = self.sp2

        # A backend without the optional playlists provider
        self.backend3 = mock.Mock()
        self.backend3.uri_schemes.get.return_value = ["dummy3"]
        self.backend3.has_playlists().get.return_value = False
        self.backend3.playlists = None

        self.core = core.Core(
            mixer=None, backends=[self.backend3, self.backend1, self.backend2])
Ejemplo n.º 23
0
 def as_list(self):
     logger.debug("YoutubeMusic getting user playlists")
     refs = []
     try:
         playlists = self.backend.api.get_library_playlists(limit=100)
     except Exception:
         logger.exception("YoutubeMusic failed getting a list of playlists")
         playlists = []
     for pls in playlists:
         refs.append(Ref.playlist(
             uri=f"youtubemusic:playlist:{pls['playlistId']}", name=pls["title"],
         ))
     return refs
Ejemplo n.º 24
0
    def test(self):
        self.backend.library.dummy_browse_result = {
            'dummy:/': [Ref.playlist(name='Top 100 tracks', uri='dummy:/1')],
        }
        self.backend.playlists.set_dummy_playlists([
            Playlist(name='Top 100 tracks', uri='dummy:/1', last_modified=123),
        ])

        response1 = self.send_request('lsinfo "/"')
        self.send_request('lsinfo "/dummy"')

        response2 = self.send_request('lsinfo "/"')
        self.assertEqual(response1, response2)
Ejemplo n.º 25
0
    def test(self):
        self.backend.library.dummy_browse_result = {
            'dummy:/': [Ref.playlist(name='Top 100 tracks', uri='dummy:/1')],
        }
        self.backend.playlists.set_dummy_playlists([
            Playlist(name='Top 100 tracks', uri='dummy:/1'),
        ])

        response1 = self.send_request('lsinfo "/"')
        self.send_request('lsinfo "/dummy"')

        response2 = self.send_request('lsinfo "/"')
        self.assertEqual(response1, response2)
Ejemplo n.º 26
0
    def setUp(self):  # noqa: N802
        self.plr1a = Ref.playlist(name='A', uri='dummy1:pl:a')
        self.plr1b = Ref.playlist(name='B', uri='dummy1:pl:b')
        self.plr2a = Ref.playlist(name='A', uri='dummy2:pl:a')
        self.plr2b = Ref.playlist(name='B', uri='dummy2:pl:b')

        self.pl1a = Playlist(name='A', tracks=[Track(uri='dummy1:t:a')])
        self.pl1b = Playlist(name='B', tracks=[Track(uri='dummy1:t:b')])
        self.pl2a = Playlist(name='A', tracks=[Track(uri='dummy2:t:a')])
        self.pl2b = Playlist(name='B', tracks=[Track(uri='dummy2:t:b')])

        self.sp1 = mock.Mock(spec=backend.PlaylistsProvider)
        self.sp1.as_list.return_value.get.return_value = [
            self.plr1a, self.plr1b]
        self.sp1.lookup.return_value.get.side_effect = [self.pl1a, self.pl1b]

        self.sp2 = mock.Mock(spec=backend.PlaylistsProvider)
        self.sp2.as_list.return_value.get.return_value = [
            self.plr2a, self.plr2b]
        self.sp2.lookup.return_value.get.side_effect = [self.pl2a, self.pl2b]

        self.backend1 = mock.Mock()
        self.backend1.actor_ref.actor_class.__name__ = 'Backend1'
        self.backend1.uri_schemes.get.return_value = ['dummy1']
        self.backend1.playlists = self.sp1

        self.backend2 = mock.Mock()
        self.backend2.actor_ref.actor_class.__name__ = 'Backend2'
        self.backend2.uri_schemes.get.return_value = ['dummy2']
        self.backend2.playlists = self.sp2

        # A backend without the optional playlists provider
        self.backend3 = mock.Mock()
        self.backend3.uri_schemes.get.return_value = ['dummy3']
        self.backend3.has_playlists().get.return_value = False
        self.backend3.playlists = None

        self.core = core.Core(mixer=None, backends=[
            self.backend3, self.backend1, self.backend2])
Ejemplo n.º 27
0
 def as_list(self):
     logger.info("YTMusic getting user playlists")
     refs = []
     try:
         playlists = API.get_library_playlists(limit=100)
     except Exception:
         logger.exception("YTMusic failed getting a list of playlists")
         playlists = []
     for pls in playlists:
         refs.append(Ref.playlist(
             uri=f"ytm:playlist?id={pls['playlistId']}", name=pls["title"],
         ))
     return refs
Ejemplo n.º 28
0
    def test(self, last_modified_mock):
        last_modified_mock.return_value = "2015-08-05T22:51:06Z"
        self.backend.library.dummy_browse_result = {
            "dummy:/": [Ref.playlist(name="Top 100 tracks", uri="dummy:/1")],
        }
        self.backend.playlists.set_dummy_playlists(
            [Playlist(name="Top 100 tracks", uri="dummy:/1")])

        response1 = self.send_request('lsinfo "/"')
        self.send_request('lsinfo "/dummy"')

        response2 = self.send_request('lsinfo "/"')
        assert response1 == response2
Ejemplo n.º 29
0
def make_ref(data):
    if isinstance(data, Track):
        ref = Ref.track(uri=data.uri, name=data.name)
    elif isinstance(data, Album):
        ref = Ref.album(uri=data.uri, name=data.name)
    elif isinstance(data, Artist):
        ref = Ref.artist(uri=data.uri, name=data.name)
    elif isinstance(data, Playlist):
        ref = Ref.playlist(uri=data.uri, name=data.name)
    elif isinstance(data, Directory):
        ref = Ref.directory(uri=data.uri, name=data.name)

    return RefWithData(ref, data)
Ejemplo n.º 30
0
    def test(self, last_modified_mock):
        last_modified_mock.return_value = '2015-08-05T22:51:06Z'
        self.backend.library.dummy_browse_result = {
            'dummy:/': [Ref.playlist(name='Top 100 tracks', uri='dummy:/1')],
        }
        self.backend.playlists.set_dummy_playlists([
            Playlist(name='Top 100 tracks', uri='dummy:/1'),
        ])

        response1 = self.send_request('lsinfo "/"')
        self.send_request('lsinfo "/dummy"')

        response2 = self.send_request('lsinfo "/"')
        self.assertEqual(response1, response2)
Ejemplo n.º 31
0
    def test(self, last_modified_mock):
        last_modified_mock.return_value = '2015-08-05T22:51:06Z'
        self.backend.library.dummy_browse_result = {
            'dummy:/': [Ref.playlist(name='Top 100 tracks', uri='dummy:/1')],
        }
        self.backend.playlists.set_dummy_playlists([
            Playlist(name='Top 100 tracks', uri='dummy:/1'),
        ])

        response1 = self.send_request('lsinfo "/"')
        self.send_request('lsinfo "/dummy"')

        response2 = self.send_request('lsinfo "/"')
        self.assertEqual(response1, response2)
Ejemplo n.º 32
0
    def as_list(self):
        logger.info("YTMusic getting user playlists")
        refs = []

        # playlist with songs similar to the last played
        refs.append(
            Ref.playlist(
                uri=f"ytm:playlist?id=watch",
                name="Similar to last played",
            ))

        # system playlists
        try:
            playlists = API.get_library_playlists(limit=100)
        except Exception:
            logger.exception("YTMusic failed getting a list of playlists")
            playlists = []
        for pls in playlists:
            refs.append(
                Ref.playlist(
                    uri=f"ytm:playlist?id={pls['playlistId']}",
                    name=pls["title"],
                ))
        return refs
Ejemplo n.º 33
0
    def test_listall_without_uri(self):
        tracks = [Track(uri='dummy:/a', name='a'),
                  Track(uri='dummy:/foo/b', name='b')]
        self.backend.library.dummy_library = tracks
        self.backend.library.dummy_browse_result = {
            'dummy:/': [Ref.track(uri='dummy:/a', name='a'),
                        Ref.directory(uri='dummy:/foo', name='foo'),
                        Ref.album(uri='dummy:/album', name='album'),
                        Ref.playlist(uri='dummy:/pl', name='pl')],
            'dummy:/foo': [Ref.track(uri='dummy:/foo/b', name='b')]}

        self.sendRequest('listall')

        self.assertInResponse('file: dummy:/a')
        self.assertInResponse('directory: /dummy/foo')
        self.assertInResponse('directory: /dummy/album')
        self.assertInResponse('directory: /dummy/pl')
        self.assertInResponse('file: dummy:/foo/b')
        self.assertInResponse('OK')
Ejemplo n.º 34
0
    def test_listall_without_uri(self):
        tracks = [Track(uri="dummy:/a", name="a"), Track(uri="dummy:/foo/b", name="b")]
        self.backend.library.dummy_library = tracks
        self.backend.library.dummy_browse_result = {
            "dummy:/": [
                Ref.track(uri="dummy:/a", name="a"),
                Ref.directory(uri="dummy:/foo", name="foo"),
                Ref.album(uri="dummy:/album", name="album"),
                Ref.playlist(uri="dummy:/pl", name="pl"),
            ],
            "dummy:/foo": [Ref.track(uri="dummy:/foo/b", name="b")],
        }

        self.sendRequest("listall")

        self.assertInResponse("file: dummy:/a")
        self.assertInResponse("directory: /dummy/foo")
        self.assertInResponse("directory: /dummy/album")
        self.assertInResponse("directory: /dummy/pl")
        self.assertInResponse("file: dummy:/foo/b")
        self.assertInResponse("OK")
Ejemplo n.º 35
0
 def as_list(self):
     refs = [
         Ref.playlist(uri=pl.uri, name=pl.name)
         for pl in self._playlists.values()]
     return sorted(refs, key=operator.attrgetter('name'))
Ejemplo n.º 36
0
 def as_list(self):
     return [
         Ref.playlist(uri=pl.uri, name=pl.name) for pl in self._playlists]
Ejemplo n.º 37
0
 def raw_playlist_to_ref(self, playlist):
     if playlist is None:
         return None
     return Ref.playlist(uri=uri.get_playlist_uri(playlist.get('id')),
                         name=playlist.get('name'))
Ejemplo n.º 38
0
def to_mopidy_playlists(wimpy_playlists):
    playlists = []
    for playlist in wimpy_playlists:
        playlists.append(Ref.playlist(uri=playlist.id, name=playlist.name))
    return playlists
Ejemplo n.º 39
0
def create_mood(tidal_mood):
    return Ref.playlist(uri="tidal:mood:" + str(tidal_mood.id),
                        name=tidal_mood.name)
Ejemplo n.º 40
0
def to_mopidy_playlists(tunigo_playlists):
    playlists = []
    for playlist in tunigo_playlists:
        playlists.append(Ref.playlist(uri=playlist.uri, name=playlist.title))
    return playlists
Ejemplo n.º 41
0
 def lookup(self, uri):
     uri = Ref.playlist(uri=uri).uri
     for playlist in self._playlists:
         if playlist.uri == uri:
             return playlist
Ejemplo n.º 42
0
 def as_list(self):
     return [
         Ref.playlist(uri=pl.uri, name=pl.name) for pl in self._playlists
     ]
Ejemplo n.º 43
0
 def test_playlist_constructor(self):
     ref = Ref.playlist(uri='foo', name='bar')
     self.assertEqual(ref.uri, 'foo')
     self.assertEqual(ref.name, 'bar')
     self.assertEqual(ref.type, Ref.PLAYLIST)
Ejemplo n.º 44
0
def create_playlist(tidal_playlist):
    return Ref.playlist(uri="tidal:playlist:" + str(tidal_playlist.id),
                        name=tidal_playlist.name)
Ejemplo n.º 45
0
def create_playlist(tidal_playlist):
    return Ref.playlist(uri="tidal:playlist:" + str(tidal_playlist.id),
                        name=tidal_playlist.name)
Ejemplo n.º 46
0
def create_genre(tidal_genre):
    return Ref.playlist(uri="tidal:genre:" + str(tidal_genre.id),
                        name=tidal_genre.name)
Ejemplo n.º 47
0
def to_mopidy_playlists(wimpy_playlists):
	playlists = []
	for playlist in wimpy_playlists:
		playlists.append(Ref.playlist(uri=playlist.id, name=playlist.name))
	return playlists
Ejemplo n.º 48
0
 def test_playlist_constructor(self):
     ref = Ref.playlist(uri='foo', name='bar')
     self.assertEqual(ref.uri, 'foo')
     self.assertEqual(ref.name, 'bar')
     self.assertEqual(ref.type, Ref.PLAYLIST)
Ejemplo n.º 49
0
 def as_list(self):
     logger.error('FilePlaylistsProvider as_list')
     refs = [
         Ref.playlist(uri=pl.uri, name=pl.name)
         for pl in self._playlists.values()]
     return refs