当前位置: 首页>>代码示例>>Python>>正文


Python MediaFile.lyrics方法代码示例

本文整理汇总了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()
开发者ID:Kiger333,项目名称:headphones,代码行数:27,代码来源:postprocessor.py

示例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()
开发者ID:JohnPostlethwait,项目名称:headphones,代码行数:23,代码来源:postprocessor.py


注:本文中的lib.beets.mediafile.MediaFile.lyrics方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。