本文整理汇总了Python中track.Track.albumarturl方法的典型用法代码示例。如果您正苦于以下问题:Python Track.albumarturl方法的具体用法?Python Track.albumarturl怎么用?Python Track.albumarturl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类track.Track
的用法示例。
在下文中一共展示了Track.albumarturl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initthread
# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import albumarturl [as 别名]
def initthread(mwc, mc):
library = mwc.library
mwc.status_msg("Initializing..")
wc = Webclient()
wc.login(config.user, config.password)
devices = wc.get_registered_devices()
mwc.status_msg("Retrieving usable device ID..")
for dev in devices:
if dev["type"] == "PHONE":
# strip 0x if present
config.devid = dev["id"][2:] if dev["id"].startswith("0x") else dev["id"]
print("Found a usable device id: " + config.devid)
break
else:
md = Gtk.MessageDialog(parent=mwc.ui, buttons=Gtk.ButtonsType.OK, message_type=Gtk.MessageType.ERROR, message_format="Could not find a usable device id. Please run the Google Play Music app at least once on your phone.")
GLib.idle_add(modal_dialog_func, md)
mc.login(config.user, config.password)
player = Player(mc, config.devid)
mwc.setplayer(player)
def getalbumart(structure):
if "albumArtRef" in structure:
a = structure["albumArtRef"]
for entry in a:
if "url" in entry:
return entry["url"]
return None
mwc.status_msg("Retrieving library..")
songs = mc.get_all_songs()
for song in songs:
track = Track(song["id"], song["title"], song["artist"], song["album"],
song["trackNumber"] if "trackNumber" in song else 0)
track.albumarturl = getalbumart(song)
library.add_track(track)
mwc.status_msg("Retrieving playlists..")
playlists = mc.get_all_user_playlist_contents()
for x in playlists:
tracks = []
for t in x["tracks"]:
if t["trackId"].startswith("T"): # all access track
trackEntry = t["track"]
track = Track(t["trackId"], trackEntry["title"], trackEntry["artist"], trackEntry["album"], trackEntry["trackNumber"])
track.albumarturl = getalbumart(trackEntry)
tracks.append(track)
else:
libtrack = library.find_track(t["trackId"])
if libtrack is not None:
tracks.append(libtrack)
library.add_list(Playlist(x["name"], tracks))
mwc.status_msg("Idle")