add param "--postfix" to postfix downloaded files with unique identifiers

This commit is contained in:
Mort Yao 2021-11-18 18:21:11 +01:00
parent 3f47a215bf
commit 5a12118c83
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251
2 changed files with 11 additions and 1 deletions

View File

@ -137,6 +137,7 @@ output_filename = None
auto_rename = False
insecure = False
m3u8 = False
postfix = False
fake_headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', # noqa
@ -984,6 +985,8 @@ def download_urls(
pass
title = tr(get_filename(title))
if postfix and 'vid' in kwargs:
title = "%s [%s]" % (title, kwargs['vid'])
output_filename = get_output_filename(urls, title, ext, output_dir, merge)
output_filepath = os.path.join(output_dir, output_filename)
@ -1532,6 +1535,10 @@ def script_main(download, download_playlist, **kwargs):
'--no-caption', action='store_true',
help='Do not download captions (subtitles, lyrics, danmaku, ...)'
)
download_grp.add_argument(
'--postfix', action='store_true', default=False,
help='Postfix downloaded files with unique identifiers'
)
download_grp.add_argument(
'-f', '--force', action='store_true', default=False,
help='Force overwriting existing files'
@ -1654,6 +1661,7 @@ def script_main(download, download_playlist, **kwargs):
global auto_rename
global insecure
global m3u8
global postfix
output_filename = args.output_filename
extractor_proxy = args.extractor_proxy
@ -1690,6 +1698,7 @@ def script_main(download, download_playlist, **kwargs):
# ignore ssl
insecure = True
postfix = args.postfix
if args.no_proxy:
set_http_proxy('')

View File

@ -238,7 +238,8 @@ class VideoExtractor():
download_urls(urls, self.title, ext, total_size, headers=headers,
output_dir=kwargs['output_dir'],
merge=kwargs['merge'],
av=stream_id in self.dash_streams)
av=stream_id in self.dash_streams,
vid=self.vid)
if 'caption' not in kwargs or not kwargs['caption']:
print('Skipping captions or danmaku.')