当前位置: 首页>>代码示例>>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;未经允许,请勿转载。