本文整理汇总了Python中mutagen.flac.FLAC.clear方法的典型用法代码示例。如果您正苦于以下问题:Python FLAC.clear方法的具体用法?Python FLAC.clear怎么用?Python FLAC.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutagen.flac.FLAC
的用法示例。
在下文中一共展示了FLAC.clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: standardize
# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import clear [as 别名]
def standardize(self):
"""
"""
# 1. Is the album already standardized?
scanner = scan.Scanner()
if scanner.scan_album(self.abs_album_dir):
print 'Valid Album Detected'
return
# 2. Categories all files within the album subdir
self.find_files()
if not self.cue_file:
sys.stderr.write('Cue file not found\n')
return
# 3. Parse the cue file so we have enough info
cue = CueParser().parse(self.cue_file)
# 4. Do we have all split tracks present?
track_count = len(self.track_files)
if track_count != len(cue):
sys.stderr.write('Wrong number of tracks: {0}\n'.format(track_count))
return
# 5. Fix track metadata and rename them
# TODO: Deal with multi-CD releases (but this also on top-level)
track_data = dict([(v, getattr(cue,k)) for k,v in const.CUE_TO_TRACK.items()])
track_data['tracktotal'] = '{0:0>2}'.format(len(cue))
for i, track in enumerate(cue):
track_number = '{0:0>2}'.format(i+1)
track_data['tracknumber'] = track_number
track_data['title'] = track['TITLE']
track_file = self.track_files[i]
audio = FLAC(track_file)
audio.clear()
audio.update(track_data)
audio.save()
# Build proper track name
track_name = const.TRACK_FMT.format(track_number,
self.sanitize_title(track_data['title']),
)
os.rename(track_file, os.path.join(self.abs_album_dir, track_name))
# 6. Clean up other files
map(os.remove, self.rm_files+[self.cue_file])
map(shutil.rmtree, self.subdirs)
# 7. Rename album folder if necessary
album_parent = os.path.dirname(self.abs_album_dir)
abs_album_dir = os.path.join(os.path.dirname(self.abs_album_dir),
const.ALBUM_FMT.format(cue.REM_DATE,
self.sanitize_title(cue.TITLE)))
if self.abs_album_dir != abs_album_dir:
os.rename(self.abs_album_dir, abs_album_dir)
示例2: prepare_track
# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import clear [as 别名]
def prepare_track(self, album, track):
temp_path = os.path.join(self.temp_dir, track.temp_filename)
track_path = os.path.join(self.temp_dir, track.filename)
meta_file = FLAC(q_enc(temp_path))
meta_file.clear()
meta_file['album'] = album.title
meta_file['albumartist'] = album.joined_artists
meta_file['artist'] = track.joined_artists
meta_file['title'] = track.title
meta_file['date'] = str(album.year)
meta_file['genre'] = album.genre
meta_file['tracknumber'] = str(track.track_number)
meta_file['totaltracks'] = str(track.track_total)
meta_file['discnumber'] = str(track.media_number)
meta_file['totaldiscs'] = str(album.media_total)
meta_file.save()
conditional_rename(temp_path, track_path)
示例3: add
# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import clear [as 别名]
def add(self, filename, artist, title, extension, clear):
'''
Adds metadata to a file
:param file: The already-title-cased file in its new destination
:param artist: The artist to be set in the metadata
:param title: The title to be set in the metadata
:param extension: The extension of the file
:param clear: boolean if the tags should be cleared beforehand or not
'''
if extension == 'mp3':
audio = MP3(filename, ID3=EasyID3)
try:
audio.add_tags(ID3=EasyID3)
except mutagen.id3.error:
pass
if clear: audio.clear()
audio['title'] = title
audio['artist'] = artist
audio.save()
audio.save(v1=2, v2_version=3)
elif extension == 'flac':
try:
audio = FLAC(filename)
except FLACNoHeaderError:
audio = FLAC()
if clear: audio.clear()
audio['TITLE'] = title
audio['ARTIST'] = artist
audio.save(filename)
elif extension == 'ogg':
try:
audio = OggVorbis(filename)
except OggVorbisHeaderError:
audio = OggVorbis()
if clear: audio.clear()
audio['title'] = artist
audio['artist'] = artist
audio['ALBUMARTIST'] = artist
audio.save(filename)