當前位置: 首頁>>代碼示例>>Python>>正文


Python uri.PandoraUri類代碼示例

本文整理匯總了Python中mopidy_pandora.uri.PandoraUri的典型用法代碼示例。如果您正苦於以下問題:Python PandoraUri類的具體用法?Python PandoraUri怎麽用?Python PandoraUri使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PandoraUri類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_search_uri_parse

def test_search_uri_parse():

    obj = PandoraUri._from_uri('pandora:search:S1234567')
    assert type(obj) is SearchUri

    assert obj.uri_type == SearchUri.uri_type
    assert obj.token == 'S1234567'

    obj = PandoraUri._from_uri('pandora:search:R123456')
    assert type(obj) is SearchUri

    assert obj.uri_type == SearchUri.uri_type
    assert obj.token == 'R123456'

    obj = PandoraUri._from_uri('pandora:search:C12345')
    assert type(obj) is SearchUri

    assert obj.uri_type == SearchUri.uri_type
    assert obj.token == 'C12345'

    obj = PandoraUri._from_uri('pandora:search:G123')
    assert type(obj) is SearchUri

    assert obj.uri_type == SearchUri.uri_type
    assert obj.token == 'G123'
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:25,代碼來源:test_uri.py

示例2: _browse_genre_stations

 def _browse_genre_stations(self, uri):
     return [
         models.Ref.directory(name=station.name, uri=PandoraUri.factory(station).uri)
         for station in self.backend.api.get_genre_stations()[
             PandoraUri.factory(uri).category_name
         ]
     ]
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:7,代碼來源:library.py

示例3: test_factory_returns_correct_station_uri_types

def test_factory_returns_correct_station_uri_types():
        station_mock = mock.PropertyMock(spec=GenreStation)
        station_mock.id = 'G100'
        station_mock.token = 'G100'
        assert type(PandoraUri.factory(station_mock)) is GenreStationUri

        station_mock = mock.PropertyMock(spec=Station)
        station_mock.id = 'id_mock'
        station_mock.token = 'token_mock'
        assert type(PandoraUri.factory(station_mock)) is StationUri
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:10,代碼來源:test_uri.py

示例4: test_track_uri_is_ad

def test_track_uri_is_ad(playlist_item_mock, ad_item_mock):
    track_uri = TrackUri._from_track(ad_item_mock)
    obj = PandoraUri._from_uri(track_uri.uri)

    assert type(obj) is AdItemUri

    track_uri = TrackUri._from_track(playlist_item_mock)
    obj = PandoraUri._from_uri(track_uri.uri)

    assert type(obj) is not AdItemUri
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:10,代碼來源:test_uri.py

示例5: is_station_changed

 def is_station_changed(self, track):
     try:
         previous_track_uri = PandoraUri.factory(
             self.core.history.get_history().get()[1][1].uri
         )
         if (
             previous_track_uri.station_id
             != PandoraUri.factory(track.uri).station_id
         ):
             return True
     except (IndexError, NotImplementedError):
         # No tracks in history, or last played track was not a Pandora track. Ignore
         pass
     return False
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:14,代碼來源:frontend.py

示例6: change_track

    def change_track(self, track):
        if track.uri is None:
            logger.warning(
                "No URI for Pandora track '{}'. Track cannot be played.".format(track)
            )
            return False

        pandora_uri = PandoraUri.factory(track.uri)
        if isinstance(pandora_uri, StationUri):
            # Change to first track in station playlist.
            logger.warning(
                "Cannot play Pandora stations directly. Retrieving tracks for station with ID: {}...".format(
                    pandora_uri.station_id
                )
            )
            self.backend.end_of_tracklist_reached(
                station_id=pandora_uri.station_id, auto_play=True
            )
            return False
        try:
            self._trigger_track_changing(track)
            self.check_skip_limit()
            self.change_pandora_track(track)
            return super(PandoraPlaybackProvider, self).change_track(track)

        except KeyError:
            logger.exception(
                "Error changing Pandora track: failed to lookup '{}'.".format(track.uri)
            )
            return False
        except (MaxSkipLimitExceeded, Unplayable) as e:
            logger.warning(e)
            return False
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:33,代碼來源:playback.py

示例7: get_images

 def get_images(self, uris):
     result = {}
     for uri in uris:
         image_uris = set()
         try:
             track = self.lookup_pandora_track(uri)
             if track.is_ad is True:
                 image_uri = track.image_url
             else:
                 image_uri = track.album_art_url
             if image_uri:
                 image_uris.update([image_uri])
         except (TypeError, KeyError):
             pandora_uri = PandoraUri.factory(uri)
             if isinstance(pandora_uri, TrackUri):
                 # Could not find the track as expected - exception.
                 logger.exception(
                     "Failed to lookup image for Pandora URI '{}'.".format(uri)
                 )
             else:
                 # Lookup
                 logger.warning(
                     "No images available for Pandora URIs of type '{}'.".format(
                         pandora_uri.uri_type
                     )
                 )
             pass
         result[uri] = [models.Image(uri=u) for u in image_uris]
     return result
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:29,代碼來源:library.py

示例8: test_change_track_skips_if_track_not_available_in_buffer

def test_change_track_skips_if_track_not_available_in_buffer(provider, playlist_item_mock, caplog):
    track = PandoraUri.factory(playlist_item_mock)

    provider.backend.prepare_next_track = mock.PropertyMock()

    assert provider.change_track(track) is False
    assert "Error changing Pandora track: failed to lookup '{}'.".format(track.uri) in caplog.text
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:7,代碼來源:test_playback.py

示例9: test_pandora_parse_mock_uri

def test_pandora_parse_mock_uri():
    uri = 'pandora:station:id_mock:token_mock'
    obj = PandoraUri._from_uri(uri)

    assert isinstance(obj, PandoraUri)
    assert type(obj) is StationUri
    assert obj.uri == uri
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:7,代碼來源:test_uri.py

示例10: test_factory_track

def test_factory_track():
    track = models.Track(name='name_mock', uri='pandora:track:station_id_mock:track_token_mock')

    obj = PandoraUri.factory(track)

    assert type(obj) is PlaylistItemUri
    assert obj.uri == track.uri
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:7,代碼來源:test_uri.py

示例11: test_get_images_for_unknown_uri_returns_empty_list

def test_get_images_for_unknown_uri_returns_empty_list(config, caplog):
    backend = conftest.get_backend(config)

    track_uri = PandoraUri.factory('pandora:track:mock_id:mock_token')
    results = backend.library.get_images([track_uri.uri])
    assert len(results[track_uri.uri]) == 0
    assert "Failed to lookup image for Pandora URI '{}'.".format(track_uri.uri) in caplog.text
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:7,代碼來源:test_library.py

示例12: test_get_images_for_unsupported_uri_type_issues_warning

def test_get_images_for_unsupported_uri_type_issues_warning(config, caplog):
    backend = conftest.get_backend(config)

    search_uri = PandoraUri.factory('pandora:search:R12345')
    results = backend.library.get_images([search_uri.uri])
    assert len(results[search_uri.uri]) == 0
    assert "No images available for Pandora URIs of type 'search'.".format(search_uri.uri) in caplog.text
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:7,代碼來源:test_library.py

示例13: test_lookup_of_missing_track

def test_lookup_of_missing_track(config, playlist_item_mock, caplog):
    backend = conftest.get_backend(config)

    track_uri = PandoraUri.factory(playlist_item_mock)
    results = backend.library.lookup(track_uri.uri)

    assert len(results) == 0
    assert "Failed to lookup Pandora URI '{}'.".format(track_uri.uri) in caplog.text
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:8,代碼來源:test_library.py

示例14: test_get_images_for_ad_with_images

def test_get_images_for_ad_with_images(config, ad_item_mock):
    backend = conftest.get_backend(config)

    ad_uri = PandoraUri.factory('pandora:ad:{}:{}'.format(conftest.MOCK_STATION_ID, conftest.MOCK_TRACK_AD_TOKEN))
    backend.library.pandora_track_cache[ad_uri.uri] = TrackCacheItem(mock.Mock(spec=models.Ref.track), ad_item_mock)
    results = backend.library.get_images([ad_uri.uri])
    assert len(results[ad_uri.uri]) == 1
    assert results[ad_uri.uri][0].uri == ad_item_mock.image_url
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:8,代碼來源:test_library.py

示例15: track_unplayable

    def track_unplayable(self, track):
        if self.is_end_of_tracklist_reached(track):
            self.core.playback.stop()
            self._trigger_end_of_tracklist_reached(
                PandoraUri.factory(track).station_id, auto_play=True
            )

        self.core.tracklist.remove({"uri": [track.uri]})
開發者ID:rectalogic,項目名稱:mopidy-pandora,代碼行數:8,代碼來源:frontend.py


注:本文中的mopidy_pandora.uri.PandoraUri類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。