mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-05 02:52:50 +08:00
Maintain extension in parts filenames so that they are recognized as videos
This commit is contained in:
parent
b3f258ca57
commit
4a247aa0c4
@ -11,6 +11,7 @@ from .utils import (
|
|||||||
PostProcessingError,
|
PostProcessingError,
|
||||||
shell_quote,
|
shell_quote,
|
||||||
subtitles_filename,
|
subtitles_filename,
|
||||||
|
build_part_filename,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -518,7 +519,7 @@ class FFmpegJoinVideosPP(FFmpegPostProcessor):
|
|||||||
parts = information.get('parts')
|
parts = information.get('parts')
|
||||||
if parts is None or len(parts) == 1:
|
if parts is None or len(parts) == 1:
|
||||||
return (True, information)
|
return (True, information)
|
||||||
parts_files = [u'%s.%s' % (filename, i) for (i, _) in enumerate(parts)]
|
parts_files = [build_part_filename(filename, i) for (i, _) in enumerate(parts)]
|
||||||
files_file = u'%s.videos' % filename
|
files_file = u'%s.videos' % filename
|
||||||
with io.open(encodeFilename(files_file), 'w', encoding='utf-8') as f:
|
with io.open(encodeFilename(files_file), 'w', encoding='utf-8') as f:
|
||||||
for video in parts_files:
|
for video in parts_files:
|
||||||
@ -527,7 +528,7 @@ class FFmpegJoinVideosPP(FFmpegPostProcessor):
|
|||||||
try:
|
try:
|
||||||
self.run_ffmpeg(files_file, filename, ['-c', 'copy'], ['-f', 'concat'])
|
self.run_ffmpeg(files_file, filename, ['-c', 'copy'], ['-f', 'concat'])
|
||||||
except FFmpegPostProcessorError:
|
except FFmpegPostProcessorError:
|
||||||
return False
|
return False, information
|
||||||
os.remove(encodeFilename(files_file))
|
os.remove(encodeFilename(files_file))
|
||||||
# We have to manually remove the parts if requested
|
# We have to manually remove the parts if requested
|
||||||
if not self._downloader.params.get('keepvideo', False):
|
if not self._downloader.params.get('keepvideo', False):
|
||||||
|
@ -43,6 +43,7 @@ from .utils import (
|
|||||||
SameFileError,
|
SameFileError,
|
||||||
sanitize_filename,
|
sanitize_filename,
|
||||||
subtitles_filename,
|
subtitles_filename,
|
||||||
|
build_part_filename,
|
||||||
takewhile_inclusive,
|
takewhile_inclusive,
|
||||||
UnavailableVideoError,
|
UnavailableVideoError,
|
||||||
write_json_file,
|
write_json_file,
|
||||||
@ -790,7 +791,7 @@ class YoutubeDL(object):
|
|||||||
for (i, part) in enumerate(parts):
|
for (i, part) in enumerate(parts):
|
||||||
part_info = dict(info_dict)
|
part_info = dict(info_dict)
|
||||||
part_info.update(part)
|
part_info.update(part)
|
||||||
part_filename = u'%s.%s' % (filename, i)
|
part_filename = build_part_filename(filename, i)
|
||||||
parts_success.append(self.fd._do_download(part_filename, part_info))
|
parts_success.append(self.fd._do_download(part_filename, part_info))
|
||||||
success = all(parts_success)
|
success = all(parts_success)
|
||||||
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
||||||
|
@ -775,6 +775,10 @@ def determine_ext(url, default_ext=u'unknown_video'):
|
|||||||
def subtitles_filename(filename, sub_lang, sub_format):
|
def subtitles_filename(filename, sub_lang, sub_format):
|
||||||
return filename.rsplit('.', 1)[0] + u'.' + sub_lang + u'.' + sub_format
|
return filename.rsplit('.', 1)[0] + u'.' + sub_lang + u'.' + sub_format
|
||||||
|
|
||||||
|
def build_part_filename(final_filename, part_index):
|
||||||
|
(name, ext) = os.path.splitext(final_filename)
|
||||||
|
return '%s.%d%s' % (name, part_index, ext)
|
||||||
|
|
||||||
def date_from_str(date_str):
|
def date_from_str(date_str):
|
||||||
"""
|
"""
|
||||||
Return a datetime object from a string in the format YYYYMMDD or
|
Return a datetime object from a string in the format YYYYMMDD or
|
||||||
|
Loading…
Reference in New Issue
Block a user