|
|
@ -603,8 +603,7 @@ def _real_main(argv=None):
|
|
|
|
u' file! Use "%%(ext)s" instead of %r' %
|
|
|
|
u' file! Use "%%(ext)s" instead of %r' %
|
|
|
|
determine_ext(outtmpl, u''))
|
|
|
|
determine_ext(outtmpl, u''))
|
|
|
|
|
|
|
|
|
|
|
|
# YoutubeDL
|
|
|
|
ydl_opts = {
|
|
|
|
ydl = YoutubeDL({
|
|
|
|
|
|
|
|
'usenetrc': opts.usenetrc,
|
|
|
|
'usenetrc': opts.usenetrc,
|
|
|
|
'username': opts.username,
|
|
|
|
'username': opts.username,
|
|
|
|
'password': opts.password,
|
|
|
|
'password': opts.password,
|
|
|
@ -667,61 +666,63 @@ def _real_main(argv=None):
|
|
|
|
'youtube_print_sig_code': opts.youtube_print_sig_code,
|
|
|
|
'youtube_print_sig_code': opts.youtube_print_sig_code,
|
|
|
|
'age_limit': opts.age_limit,
|
|
|
|
'age_limit': opts.age_limit,
|
|
|
|
'download_archive': opts.download_archive,
|
|
|
|
'download_archive': opts.download_archive,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if opts.verbose:
|
|
|
|
with YoutubeDL(ydl_opts) as ydl:
|
|
|
|
write_string(u'[debug] youtube-dl version ' + __version__ + u'\n')
|
|
|
|
if opts.verbose:
|
|
|
|
try:
|
|
|
|
write_string(u'[debug] youtube-dl version ' + __version__ + u'\n')
|
|
|
|
sp = subprocess.Popen(
|
|
|
|
|
|
|
|
['git', 'rev-parse', '--short', 'HEAD'],
|
|
|
|
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
|
|
|
|
|
|
|
cwd=os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
|
|
out, err = sp.communicate()
|
|
|
|
|
|
|
|
out = out.decode().strip()
|
|
|
|
|
|
|
|
if re.match('[0-9a-f]+', out):
|
|
|
|
|
|
|
|
write_string(u'[debug] Git HEAD: ' + out + u'\n')
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
sys.exc_clear()
|
|
|
|
sp = subprocess.Popen(
|
|
|
|
|
|
|
|
['git', 'rev-parse', '--short', 'HEAD'],
|
|
|
|
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
|
|
|
|
|
|
|
cwd=os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
|
|
out, err = sp.communicate()
|
|
|
|
|
|
|
|
out = out.decode().strip()
|
|
|
|
|
|
|
|
if re.match('[0-9a-f]+', out):
|
|
|
|
|
|
|
|
write_string(u'[debug] Git HEAD: ' + out + u'\n')
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
write_string(u'[debug] Python version %s - %s' %(platform.python_version(), platform_name()) + u'\n')
|
|
|
|
sys.exc_clear()
|
|
|
|
|
|
|
|
except:
|
|
|
|
proxy_map = {}
|
|
|
|
pass
|
|
|
|
for handler in opener.handlers:
|
|
|
|
write_string(u'[debug] Python version %s - %s' %
|
|
|
|
if hasattr(handler, 'proxies'):
|
|
|
|
(platform.python_version(), platform_name()) + u'\n')
|
|
|
|
proxy_map.update(handler.proxies)
|
|
|
|
|
|
|
|
write_string(u'[debug] Proxy map: ' + compat_str(proxy_map) + u'\n')
|
|
|
|
proxy_map = {}
|
|
|
|
|
|
|
|
for handler in opener.handlers:
|
|
|
|
ydl.add_default_info_extractors()
|
|
|
|
if hasattr(handler, 'proxies'):
|
|
|
|
|
|
|
|
proxy_map.update(handler.proxies)
|
|
|
|
# PostProcessors
|
|
|
|
write_string(u'[debug] Proxy map: ' + compat_str(proxy_map) + u'\n')
|
|
|
|
# Add the metadata pp first, the other pps will copy it
|
|
|
|
|
|
|
|
if opts.addmetadata:
|
|
|
|
ydl.add_default_info_extractors()
|
|
|
|
ydl.add_post_processor(FFmpegMetadataPP())
|
|
|
|
|
|
|
|
if opts.extractaudio:
|
|
|
|
# PostProcessors
|
|
|
|
ydl.add_post_processor(FFmpegExtractAudioPP(preferredcodec=opts.audioformat, preferredquality=opts.audioquality, nopostoverwrites=opts.nopostoverwrites))
|
|
|
|
# Add the metadata pp first, the other pps will copy it
|
|
|
|
if opts.recodevideo:
|
|
|
|
if opts.addmetadata:
|
|
|
|
ydl.add_post_processor(FFmpegVideoConvertor(preferedformat=opts.recodevideo))
|
|
|
|
ydl.add_post_processor(FFmpegMetadataPP())
|
|
|
|
if opts.embedsubtitles:
|
|
|
|
if opts.extractaudio:
|
|
|
|
ydl.add_post_processor(FFmpegEmbedSubtitlePP(subtitlesformat=opts.subtitlesformat))
|
|
|
|
ydl.add_post_processor(FFmpegExtractAudioPP(preferredcodec=opts.audioformat, preferredquality=opts.audioquality, nopostoverwrites=opts.nopostoverwrites))
|
|
|
|
|
|
|
|
if opts.recodevideo:
|
|
|
|
# Update version
|
|
|
|
ydl.add_post_processor(FFmpegVideoConvertor(preferedformat=opts.recodevideo))
|
|
|
|
if opts.update_self:
|
|
|
|
if opts.embedsubtitles:
|
|
|
|
update_self(ydl.to_screen, opts.verbose)
|
|
|
|
ydl.add_post_processor(FFmpegEmbedSubtitlePP(subtitlesformat=opts.subtitlesformat))
|
|
|
|
|
|
|
|
|
|
|
|
# Maybe do nothing
|
|
|
|
# Update version
|
|
|
|
if len(all_urls) < 1:
|
|
|
|
if opts.update_self:
|
|
|
|
if not opts.update_self:
|
|
|
|
update_self(ydl.to_screen, opts.verbose)
|
|
|
|
parser.error(u'you must provide at least one URL')
|
|
|
|
|
|
|
|
else:
|
|
|
|
# Maybe do nothing
|
|
|
|
sys.exit()
|
|
|
|
if len(all_urls) < 1:
|
|
|
|
|
|
|
|
if not opts.update_self:
|
|
|
|
|
|
|
|
parser.error(u'you must provide at least one URL')
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
retcode = ydl.download(all_urls)
|
|
|
|
retcode = ydl.download(all_urls)
|
|
|
|
except MaxDownloadsReached:
|
|
|
|
except MaxDownloadsReached:
|
|
|
|
ydl.to_screen(u'--max-download limit reached, aborting.')
|
|
|
|
ydl.to_screen(u'--max-download limit reached, aborting.')
|
|
|
|
retcode = 101
|
|
|
|
retcode = 101
|
|
|
|
|
|
|
|
|
|
|
|
# Dump cookie jar if requested
|
|
|
|
# Dump cookie jar if requested
|
|
|
|
if opts.cookiefile is not None:
|
|
|
|
if opts.cookiefile is not None:
|
|
|
|