actually use new mimetype to change downloaded file extension
needed for youtube-dl downloading to .mkv for some combinations of audio+video codecs. Before this fix the new mimetype was ignored in download.py because episode.extension() would use the existing download filename instead of using the updated mime type
This commit is contained in:
parent
a4546b463f
commit
bc5327dd2a
|
@ -95,9 +95,6 @@ class YoutubeCustomDownload(download.CustomDownload):
|
|||
# youtube-dl doesn't return a content-type but an extension
|
||||
if 'ext' in res:
|
||||
dot_ext = '.{}'.format(res['ext'])
|
||||
ext_filetype = mimetype_from_extension(dot_ext)
|
||||
if ext_filetype:
|
||||
headers['content-type'] = ext_filetype
|
||||
# See #673 when merging multiple formats, the extension is appended to the tempname
|
||||
# by YoutubeDL resulting in empty .partial file + .partial.mp4 exists
|
||||
# and #796 .mkv is chosen by ytdl sometimes
|
||||
|
@ -111,7 +108,11 @@ class YoutubeCustomDownload(download.CustomDownload):
|
|||
os.path.basename(tempname))
|
||||
os.remove(tempname)
|
||||
os.rename(tempname_with_ext, tempname)
|
||||
dot_ext = try_ext
|
||||
break
|
||||
ext_filetype = mimetype_from_extension(dot_ext)
|
||||
if ext_filetype:
|
||||
headers['content-type'] = ext_filetype
|
||||
return headers, res.get('url', self._url)
|
||||
|
||||
def _my_hook(self, d):
|
||||
|
|
|
@ -869,7 +869,8 @@ class DownloadTask(object):
|
|||
logger.info('Updating mime type: %s => %s', old_mimetype, new_mimetype)
|
||||
old_extension = self.__episode.extension()
|
||||
self.__episode.mime_type = new_mimetype
|
||||
new_extension = self.__episode.extension()
|
||||
# don't call local_filename because we'll get the old download name
|
||||
new_extension = self.__episode.extension(may_call_local_filename=False)
|
||||
|
||||
# If the desired filename extension changed due to the new
|
||||
# mimetype, we force an update of the local filename to fix the
|
||||
|
|
Loading…
Reference in New Issue