本文整理汇总了Python中mutagen.mp3.EasyMP3方法的典型用法代码示例。如果您正苦于以下问题:Python mp3.EasyMP3方法的具体用法?Python mp3.EasyMP3怎么用?Python mp3.EasyMP3使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutagen.mp3
的用法示例。
在下文中一共展示了mp3.EasyMP3方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_details
# 需要导入模块: from mutagen import mp3 [as 别名]
# 或者: from mutagen.mp3 import EasyMP3 [as 别名]
def add_details(file_name, title, artist, album, lyrics=""):
'''
Adds the details to song
'''
tags = EasyMP3(file_name)
tags["title"] = title
tags["artist"] = artist
tags["album"] = album
tags.save()
tags = ID3(file_name)
uslt_output = USLT(encoding=3, lang=u'eng', desc=u'desc', text=lyrics)
tags["USLT::'eng'"] = uslt_output
tags.save(file_name)
log.log("> Adding properties")
log.log_indented("[*] Title: %s" % title)
log.log_indented("[*] Artist: %s" % artist)
log.log_indented("[*] Album: %s " % album)
示例2: add_album_art
# 需要导入模块: from mutagen import mp3 [as 别名]
# 或者: from mutagen.mp3 import EasyMP3 [as 别名]
def add_album_art(file_name, album_art):
"""
Add album_art in .mp3's tags
"""
img = requests.get(album_art, stream=True) # Gets album art from url
img = img.raw
audio = EasyMP3(file_name, ID3=ID3)
try:
audio.add_tags()
except _util.error:
pass
audio.tags.add(
APIC(
encoding=3, # UTF-8
mime='image/png',
type=3, # 3 is for album art
desc='Cover',
data=img.read() # Reads and adds album art
)
)
audio.save()
return album_art
示例3: add_metadata
# 需要导入模块: from mutagen import mp3 [as 别名]
# 或者: from mutagen.mp3 import EasyMP3 [as 别名]
def add_metadata(file_name, title, artist, album):
"""
As the method name suggests
"""
tags = EasyMP3(file_name)
if title:
tags["title"] = title
if artist:
tags["artist"] = artist
if album:
tags["album"] = album
tags.save()
return file_name
示例4: get_current_metadata_tag
# 需要导入模块: from mutagen import mp3 [as 别名]
# 或者: from mutagen.mp3 import EasyMP3 [as 别名]
def get_current_metadata_tag(file_name, tag):
tags = EasyMP3(file_name)
if tag in tags:
return tags[tag].pop()
else:
return "The metadata tag could not be found."
示例5: revert_metadata
# 需要导入模块: from mutagen import mp3 [as 别名]
# 或者: from mutagen.mp3 import EasyMP3 [as 别名]
def revert_metadata(files):
"""
Removes all tags from a mp3 file
"""
for file_path in files:
tags = EasyMP3(file_path)
tags.delete()
tags.save()
示例6: add_albumart
# 需要导入模块: from mutagen import mp3 [as 别名]
# 或者: from mutagen.mp3 import EasyMP3 [as 别名]
def add_albumart(albumart, song_title):
'''
Adds the album art to the song
'''
try:
img = urlopen(albumart) # Gets album art from url
except Exception:
log.log_error("* Could not add album art", indented=True)
return None
audio = EasyMP3(song_title, ID3=ID3)
try:
audio.add_tags()
except _util.error:
pass
audio.tags.add(
APIC(
encoding=3, # UTF-8
mime='image/png',
type=3, # 3 is for album art
desc='Cover',
data=img.read() # Reads and adds album art
)
)
audio.save()
log.log("> Added album art")
示例7: get_from_files
# 需要导入模块: from mutagen import mp3 [as 别名]
# 或者: from mutagen.mp3 import EasyMP3 [as 别名]
def get_from_files(self, img_url, img_name):
logger.info('extract image from {}'.format(img_url))
if img_url.endswith('mp3') or img_url.endswith('ogg') or img_url.endswith('wma'):
from mutagen.mp3 import EasyMP3
metadata = EasyMP3(img_url)
content = metadata.tags._EasyID3__id3._DictProxy__dict['APIC:'].data
elif img_url.endswith('m4a'):
from mutagen.easymp4 import EasyMP4
metadata = EasyMP4(img_url)
content = metadata.tags._EasyMP4Tags__mp4._DictProxy__dict['covr'][0]
return content