本文整理匯總了Python中lollypop.radios.Radios.get_name方法的典型用法代碼示例。如果您正苦於以下問題:Python Radios.get_name方法的具體用法?Python Radios.get_name怎麽用?Python Radios.get_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lollypop.radios.Radios
的用法示例。
在下文中一共展示了Radios.get_name方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: restore_state
# 需要導入模塊: from lollypop.radios import Radios [as 別名]
# 或者: from lollypop.radios.Radios import get_name [as 別名]
def restore_state(self):
"""
Restore player state
"""
if Lp().settings.get_value('save-state'):
track_id = Lp().settings.get_value('track-id').get_int32()
playlist_ids = Lp().settings.get_value('playlist-ids')
if playlist_ids and playlist_ids[0] == Type.RADIOS:
radios = Radios()
track = Track()
name = radios.get_name(track_id)
url = radios.get_url(name)
track.set_radio(name, url)
self.load(track)
elif Lp().tracks.get_path(track_id) != "":
track = Track(track_id)
self._load_track(track)
if playlist_ids:
try:
pids = []
for playlist_id in playlist_ids:
pids.append(int(playlist_id))
track_ids = []
for playlist_id in playlist_ids:
if playlist_id == Type.POPULARS:
tracks = Lp().tracks.get_populars()
elif playlist_id == Type.RECENTS:
tracks = Lp().tracks.get_recently_listened_to()
elif playlist_id == Type.NEVER:
tracks = Lp().tracks.get_never_listened_to()
elif playlist_id == Type.RANDOMS:
tracks = Lp().tracks.get_randoms()
else:
tracks = Lp().playlists.get_tracks_ids(
playlist_id)
for track_id in tracks:
if track_id not in track_ids:
track_ids.append(track_id)
self.populate_user_playlist_by_tracks(track_ids,
pids)
except:
pass # User set non int in gsettings
else:
self._albums = Lp().artists.get_albums(
track.album_artist_ids)
for album_id in self._albums:
self.context.genre_ids[album_id] = []
self.context.artist_ids[album_id] = []
self.set_next()
self.set_prev()
if Lp().settings.get_value('repeat'):
self.context.next = NextContext.NONE
else:
self.context.next = NextContext.STOP_ALL
self.emit('current-changed')
else:
print("Player::restore_state(): track missing")
示例2: restore_state
# 需要導入模塊: from lollypop.radios import Radios [as 別名]
# 或者: from lollypop.radios.Radios import get_name [as 別名]
def restore_state(self):
"""
Restore player state
"""
try:
if Lp().settings.get_value('save-state'):
track_id = load(open(DataPath + "/track_id.bin", "rb"))
playlist_ids = load(open(DataPath + "/playlist_ids.bin",
"rb"))
if playlist_ids and playlist_ids[0] == Type.RADIOS:
radios = Radios()
track = Track()
name = radios.get_name(track_id)
url = radios.get_url(name)
track.set_radio(name, url)
self.load(track)
elif Lp().tracks.get_path(track_id) != "":
track = Track(track_id)
if Lp().notify is not None:
Lp().notify.inhibit()
self._load_track(track)
# We set this initial state
# because seek while failed otherwise
self.pause()
if playlist_ids:
pids = []
for playlist_id in playlist_ids:
pids.append(int(playlist_id))
track_ids = []
for playlist_id in playlist_ids:
if playlist_id == Type.POPULARS:
tracks = Lp().tracks.get_populars()
elif playlist_id == Type.RECENTS:
tracks = Lp().tracks.get_recently_listened_to()
elif playlist_id == Type.NEVER:
tracks = Lp().tracks.get_never_listened_to()
elif playlist_id == Type.RANDOMS:
tracks = Lp().tracks.get_randoms()
else:
tracks = Lp().playlists.get_track_ids(
playlist_id)
for track_id in tracks:
if track_id not in track_ids:
track_ids.append(track_id)
self.populate_user_playlist_by_tracks(track_ids,
pids)
else:
self._albums = load(open(
DataPath + "/albums.bin",
"rb"))
self.shuffle_albums(True)
self._context.genre_ids = load(open(
DataPath + "/genre_ids.bin",
"rb"))
self._context.artist_ids = load(open(
DataPath + "/artist_ids.bin",
"rb"))
self.set_next()
self.set_prev()
if Lp().settings.get_value('repeat'):
self._context.next = NextContext.NONE
else:
self._context.next = NextContext.STOP_ALL
else:
print("Player::restore_state(): track missing")
except Exception as e:
print("Player::restore_state()", e)