本文整理汇总了Python中mutagen.asf.ASF.has_key方法的典型用法代码示例。如果您正苦于以下问题:Python ASF.has_key方法的具体用法?Python ASF.has_key怎么用?Python ASF.has_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutagen.asf.ASF
的用法示例。
在下文中一共展示了ASF.has_key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getFileInfo
# 需要导入模块: from mutagen.asf import ASF [as 别名]
# 或者: from mutagen.asf.ASF import has_key [as 别名]
def getFileInfo(file, fileExtension, fileID):
trackXML = ""
skip = False
if fileExtension == ".mp3":
try:
audio = EasyID3(file)
except mutagen.id3.ID3NoHeaderError as noid3ex:
skip = True
fileType = "mp3"
# print EasyID3.pprint(audio)
else:
if fileExtension == ".wma":
audio = ASF(file)
fileType = "wma"
# print ASF.pprint(audio)
if skip == False:
title = "unknown"
albumTitle = "unknown"
artist = "unknown"
trackNumber = "0"
performer = "unknown"
# get file info
if audio.has_key("title"):
title = audio["title"][0]
else:
if audio.has_key("Title"):
title = audio["Title"][0]
if audio.has_key("WM/AlbumTitle"):
albumTitle = audio["WM/AlbumTitle"][0]
else:
if audio.has_key("album"):
albumTitle = audio["album"][0]
if audio.has_key("artist"):
artist = audio["artist"][0]
else:
if audio.has_key("Author"):
artist = audio["Author"][0]
if audio.has_key("performer"):
performer = audio["performer"][0]
if audio.has_key("WM/AlbumArtist"):
performer = audio["WM/AlbumArtist"][0]
if audio.has_key("tracknumber"):
trackNumber = audio["tracknumber"][0]
else:
if audio.has_key("WM/TrackNumber"):
trackNumber = audio["WM/TrackNumber"][0]
# If we don't have a performer by now then use the artist field
if performer == "unknown":
performer = artist
if albumTitle == "James Bond":
print audio.keys
# look up file in xml, if exists get playcount, lastplayed etc or mark as new
try:
trackXML = trackXML + getTrackToXML(
fileID, file, title, albumTitle, artist, trackNumber, performer, fileType
)
except Exception as ex:
print file
raise
else:
print "Skipping " + file
# print "added " + file
# print file
# print fileID
# print title
# print albumTitle
# print artist
# print trackNumber
# print performer
return trackXML