本文整理汇总了Python中song.Song.save_lyrics方法的典型用法代码示例。如果您正苦于以下问题:Python Song.save_lyrics方法的具体用法?Python Song.save_lyrics怎么用?Python Song.save_lyrics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类song.Song
的用法示例。
在下文中一共展示了Song.save_lyrics方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Player
# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import save_lyrics [as 别名]
#.........这里部分代码省略.........
# if no time tags, return
if (not self.isPlaying() or not self.song.m_song.lyrics_tags or self.listcontrol is None or
not self.m_addon.getSetting("enable_karaoke_mode") or
(not self.use_gui and not xbmc.getCondVisibility("Window.IsActive({id})".format(id=self.window_id)))):
return
#FIXME: make sure this is necessary, I don't believe it is
# cance only lyric timer
self.cancel_timers(fetch=False)
# get current time
current = self.getTime()
# get position
pos = [count for count, tag in enumerate(self.song.m_song.lyrics_tags + [current + 1]) if (tag > current)][0]
# select listitem
self.listcontrol.selectItem(pos - 1)
# return if no more lyrics
if (pos == len(self.song.m_song.lyrics_tags)): return
# calculate update time, additional time necessary to limit the number of repeat timer events
update = self.song.m_song.lyrics_tags[pos] - current + 0.02
# set new timer
self._lyric_timer = Timer(update, self._update_lyric)
# start timer
self._lyric_timer.start()
def cancel_timers(self, fetch=True):
# if there's a timer cancel it
if (self._lyric_timer is not None):
self._lyric_timer.cancel()
if (self._fetch_timer is not None and fetch):
self._fetch_timer.cancel()
def _fetch_lyrics(self):
# set fetching lyrics message
self._set_properties(
message=self.m_addon.getLocalizedString(30800).format(
title=unicode(xbmc.getInfoLabel("MusicPlayer.Title"), "UTF-8"))
)
# if prefetching failed, we go straight to song list
songlist = self.prefetched_song is not None and not self.prefetched_song.m_song.status
# fetch lyrics
self.song.get_song_info(songlist=songlist)
# set lyrics and messages
self._set_properties(
self.song.m_song.lyrics,
self.song.m_song.lyrics_tags,
self.song.m_song.lrc_lyrics,
self.song.m_song.message,
self.song.m_song.website,
self.song.m_song.status,
self.song.m_song.prefetched
)
# prefetch next song
if (self.prefetched_song is not None and xbmc.getCondVisibility("MusicPlayer.HasNext")):
# set new prefetch delay timer
self._fetch_timer = Timer(
self.PREFETCH_DELAY_TIME,
self._prefetch_lyrics,
(self.song.m_song.message, self.song.m_song.website, self.song.m_song.status, self.song.m_song.prefetched,)
)
# start timer
self._fetch_timer.start()
def _prefetch_lyrics(self, message, website, status, prefetched):
# set prefetching message
self.set_info_properties(
message=self.m_addon.getLocalizedString(30805).format(
title=unicode(xbmc.getInfoLabel("MusicPlayer.Offset(1).Title"), "UTF-8")),
status=status,
prefetching=True
)
# fetch next songs lyrics
self.prefetched_song.get_song_info()
# set previous properties
self.set_info_properties(message, website, status, prefetched)
def save_user_tagged_lyrics(self, lyrics):
# set default saved lyrics message
self.song.m_song.message = self.m_addon.getLocalizedString(30863)
# set song's lyrics
self.song.m_song.lyrics = lyrics
# save lyrics
self.song.save_lyrics()
# set new message
self._set_properties(lyrics=None, message=self.song.m_song.message)
def finish_up(self):
# cancel any timer
self.cancel_timers()
# close dialog
if (self.use_gui):
# close the GUI
self._gui.close_dialog()
else:
# set to False so script will exit
self._loop = False
# close window
xbmc.executebuiltin("Dialog.Close({id})".format(id=self.window_id))
# clear existing properties
self._set_properties()
# log ended action
self._log_addon_action("ended")