[embedthumbnail] Fixed a bug causing the rest of the code to be unreachable.
This commit is contained in:
parent
01d84b7db5
commit
5e10411546
@ -100,30 +100,30 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
raise EmbedThumbnailPPError('mutagen was not found. Please install.')
|
raise EmbedThumbnailPPError('mutagen was not found. Please install.')
|
||||||
|
|
||||||
shutil.copyfile(filename, temp_filename)
|
shutil.copyfile(filename, temp_filename)
|
||||||
aufile = {'opus': OggOpus, 'flac': FLAC, 'ogg': OggVorbis} \
|
aufile = {'opus': OggOpus, 'flac': FLAC, 'ogg': OggVorbis} \
|
||||||
[info['ext']](temp_filename)
|
[info['ext']](temp_filename)
|
||||||
|
|
||||||
covart = Picture()
|
covart = Picture()
|
||||||
covart.data = open(thumbnail_filename, 'rb').read()
|
covart.data = open(thumbnail_filename, 'rb').read()
|
||||||
covart.type = 3 # Cover (front)
|
covart.type = 3 # Cover (front)
|
||||||
|
|
||||||
# Since, OGGOpus and OGGVorbis doesn't natively support
|
# Since, OGGOpus and OGGVorbis doesn't natively support
|
||||||
# (coverart / thumbnail)s, it's wrapped in if..else
|
# (coverart / thumbnail)s, it's wrapped in if..else
|
||||||
if info['ext'] == 'flac':
|
if info['ext'] == 'flac':
|
||||||
aufile.add_picture(covart)
|
aufile.add_picture(covart)
|
||||||
else:
|
else:
|
||||||
aufile['metadata_block_picture'] = \
|
aufile['metadata_block_picture'] = \
|
||||||
b64encode(covart.write()).decode('ascii')
|
b64encode(covart.write()).decode('ascii')
|
||||||
|
|
||||||
# Save changes to temporary file, it'd be overlapped as the
|
# Save changes to temporary file, it'd be overlapped as the
|
||||||
# original one.
|
# original one.
|
||||||
aufile.save()
|
aufile.save()
|
||||||
|
|
||||||
if not self._already_have_thumbnail:
|
if not self._already_have_thumbnail:
|
||||||
os.remove(encodeFilename(thumbnail_filename))
|
os.remove(encodeFilename(thumbnail_filename))
|
||||||
os.remove(encodeFilename(filename))
|
os.remove(encodeFilename(filename))
|
||||||
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
|
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
|
||||||
else:
|
else:
|
||||||
raise EmbedThumbnailPPError('Only mp3, m4a/mp4, ogg, opus and flac are supported for thumbnail embedding for now.')
|
raise EmbedThumbnailPPError('Only mp3, m4a/mp4, ogg, opus and flac are supported for thumbnail embedding for now.')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user