本文整理汇总了Python中lib.beets.mediafile.MediaFile.lyrics方法的典型用法代码示例。如果您正苦于以下问题:Python MediaFile.lyrics方法的具体用法?Python MediaFile.lyrics怎么用?Python MediaFile.lyrics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.beets.mediafile.MediaFile
的用法示例。
在下文中一共展示了MediaFile.lyrics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: embedLyrics
# 需要导入模块: from lib.beets.mediafile import MediaFile [as 别名]
# 或者: from lib.beets.mediafile.MediaFile import lyrics [as 别名]
def embedLyrics(downloaded_track_list):
logger.info('Adding lyrics')
# TODO: If adding lyrics for flac & lossy, only fetch the lyrics once
# and apply it to both files
for downloaded_track in downloaded_track_list:
try:
f = MediaFile(downloaded_track)
except:
logger.error('Could not read %s. Not checking lyrics' % downloaded_track.decode(headphones.SYS_ENCODING, 'replace'))
continue
if f.albumartist and f.title:
metalyrics = lyrics.getLyrics(f.albumartist, f.title)
elif f.artist and f.title:
metalyrics = lyrics.getLyrics(f.artist, f.title)
else:
logger.info('No artist/track metadata found for track: %s. Not fetching lyrics' % downloaded_track.decode(headphones.SYS_ENCODING, 'replace'))
metalyrics = None
if lyrics:
logger.debug('Adding lyrics to: %s' % downloaded_track.decode(headphones.SYS_ENCODING, 'replace'))
f.lyrics = metalyrics
f.save()
示例2: embedLyrics
# 需要导入模块: from lib.beets.mediafile import MediaFile [as 别名]
# 或者: from lib.beets.mediafile.MediaFile import lyrics [as 别名]
def embedLyrics(downloaded_track_list):
logger.info('Adding lyrics')
for downloaded_track in downloaded_track_list:
try:
f = MediaFile(downloaded_track)
except:
logger.error('Could not read %s. Not checking lyrics' % downloaded_track)
if f.albumartist and f.title:
metalyrics = lyrics.getLyrics(f.albumartist, f.title)
elif f.artist and f.title:
metalyrics = lyrics.getLyrics(f.artist, f.title)
else:
logger.info('No artist/track metadata found for track: %s. Not fetching lyrics' % downloaded_track)
metalyrics = None
if lyrics:
logger.debug('Adding lyrics to: %s' % downloaded_track)
f.lyrics = metalyrics
f.save()