mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-26 21:59:08 +01:00
Cleanup some code and fix typos
:ci skip dl
This commit is contained in:
parent
1ea2412927
commit
068693675e
15 changed files with 50 additions and 31 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -55,6 +55,9 @@ youtube-dlc
|
||||||
*.swf
|
*.swf
|
||||||
*.part
|
*.part
|
||||||
*.ytdl
|
*.ytdl
|
||||||
|
*.frag
|
||||||
|
*.frag.urls
|
||||||
|
*.aria2
|
||||||
*.swp
|
*.swp
|
||||||
*.ogg
|
*.ogg
|
||||||
*.opus
|
*.opus
|
||||||
|
|
|
@ -205,7 +205,7 @@
|
||||||
* Changed video format sorting to show video only files and video+audio files together.
|
* Changed video format sorting to show video only files and video+audio files together.
|
||||||
* Added `--video-multistreams`, `--no-video-multistreams`, `--audio-multistreams`, `--no-audio-multistreams`
|
* Added `--video-multistreams`, `--no-video-multistreams`, `--audio-multistreams`, `--no-audio-multistreams`
|
||||||
* Added `b`,`w`,`v`,`a` as alias for `best`, `worst`, `video` and `audio` respectively
|
* Added `b`,`w`,`v`,`a` as alias for `best`, `worst`, `video` and `audio` respectively
|
||||||
* **Shortcut Options:** Added `--write-link`, `--write-url-link`, `--write-webloc-link`, `--write-desktop-link` by [h-h-h-h](https://github.com/h-h-h-h) - See [Internet Shortcut Options]README.md(#internet-shortcut-options) for details
|
* **Shortcut Options:** Added `--write-link`, `--write-url-link`, `--write-webloc-link`, `--write-desktop-link` by [h-h-h-h](https://github.com/h-h-h-h) - See [Internet Shortcut Options](README.md#internet-shortcut-options) for details
|
||||||
* **Sponskrub integration:** Added `--sponskrub`, `--sponskrub-cut`, `--sponskrub-force`, `--sponskrub-location`, `--sponskrub-args` - See [SponSkrub Options](README.md#sponskrub-options-sponsorblock) for details
|
* **Sponskrub integration:** Added `--sponskrub`, `--sponskrub-cut`, `--sponskrub-force`, `--sponskrub-location`, `--sponskrub-args` - See [SponSkrub Options](README.md#sponskrub-options-sponsorblock) for details
|
||||||
* Added `--force-download-archive` (`--force-write-archive`) by [h-h-h-h](https://github.com/h-h-h-h)
|
* Added `--force-download-archive` (`--force-write-archive`) by [h-h-h-h](https://github.com/h-h-h-h)
|
||||||
* Added `--list-formats-as-table`, `--list-formats-old`
|
* Added `--list-formats-as-table`, `--list-formats-old`
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -4,7 +4,7 @@ man: README.txt youtube-dlc.1 youtube-dlc.bash-completion youtube-dlc.zsh youtub
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf youtube-dlc.1.temp.md youtube-dlc.1 youtube-dlc.bash-completion README.txt MANIFEST build/ dist/ .coverage cover/ youtube-dlc.tar.gz youtube-dlc.zsh youtube-dlc.fish youtube_dlc/extractor/lazy_extractors.py *.dump *.part* *.ytdl *.info.json *.mp4 *.m4a *.flv *.mp3 *.avi *.mkv *.webm *.3gp *.wav *.ape *.swf *.jpg *.png *.spec CONTRIBUTING.md.tmp youtube-dlc youtube-dlc.exe
|
rm -rf youtube-dlc.1.temp.md youtube-dlc.1 youtube-dlc.bash-completion README.txt MANIFEST build/ dist/ .coverage cover/ youtube-dlc.tar.gz youtube-dlc.zsh youtube-dlc.fish youtube_dlc/extractor/lazy_extractors.py *.dump *.part* *.ytdl *.info.json *.mp4 *.m4a *.flv *.mp3 *.avi *.mkv *.webm *.3gp *.wav *.ape *.swf *.jpg *.png *.spec *.frag *.frag.urls *.frag.aria2 CONTRIBUTING.md.tmp youtube-dlc youtube-dlc.exe
|
||||||
find . -name "*.pyc" -delete
|
find . -name "*.pyc" -delete
|
||||||
find . -name "*.class" -delete
|
find . -name "*.class" -delete
|
||||||
|
|
||||||
|
|
|
@ -379,12 +379,15 @@ def _real_main(argv=None):
|
||||||
'when': 'aftermove'
|
'when': 'aftermove'
|
||||||
})
|
})
|
||||||
|
|
||||||
_args_compat_warning = 'WARNING: %s given without specifying name. The arguments will be given to all %s\n'
|
def report_args_compat(arg, name):
|
||||||
|
write_string(
|
||||||
|
'WARNING: %s given without specifying name. The arguments will be given to all %s\n' % (arg, name),
|
||||||
|
out=sys.stderr)
|
||||||
if 'default' in opts.external_downloader_args:
|
if 'default' in opts.external_downloader_args:
|
||||||
write_string(_args_compat_warning % ('--external-downloader-args', 'external downloaders'), out=sys.stderr),
|
report_args_compat('--external-downloader-args', 'external downloaders')
|
||||||
|
|
||||||
if 'default-compat' in opts.postprocessor_args and 'default' not in opts.postprocessor_args:
|
if 'default-compat' in opts.postprocessor_args and 'default' not in opts.postprocessor_args:
|
||||||
write_string(_args_compat_warning % ('--post-processor-args', 'post-processors'), out=sys.stderr),
|
report_args_compat('--post-processor-args', 'post-processors')
|
||||||
opts.postprocessor_args.setdefault('sponskrub', [])
|
opts.postprocessor_args.setdefault('sponskrub', [])
|
||||||
opts.postprocessor_args['default'] = opts.postprocessor_args['default-compat']
|
opts.postprocessor_args['default'] = opts.postprocessor_args['default-compat']
|
||||||
|
|
||||||
|
|
|
@ -478,11 +478,12 @@ class BrightcoveNewIE(AdobePassIE):
|
||||||
container = source.get('container')
|
container = source.get('container')
|
||||||
ext = mimetype2ext(source.get('type'))
|
ext = mimetype2ext(source.get('type'))
|
||||||
src = source.get('src')
|
src = source.get('src')
|
||||||
|
skip_unplayable = not self._downloader.params.get('allow_unplayable_formats')
|
||||||
# https://support.brightcove.com/playback-api-video-fields-reference#key_systems_object
|
# https://support.brightcove.com/playback-api-video-fields-reference#key_systems_object
|
||||||
if not self._downloader.params.get('allow_unplayable_formats') and (container == 'WVM' or source.get('key_systems')):
|
if skip_unplayable and (container == 'WVM' or source.get('key_systems')):
|
||||||
num_drm_sources += 1
|
num_drm_sources += 1
|
||||||
continue
|
continue
|
||||||
elif ext == 'ism' and not self._downloader.params.get('allow_unplayable_formats'):
|
elif ext == 'ism' and skip_unplayable:
|
||||||
continue
|
continue
|
||||||
elif ext == 'm3u8' or container == 'M2TS':
|
elif ext == 'm3u8' or container == 'M2TS':
|
||||||
if not src:
|
if not src:
|
||||||
|
@ -546,7 +547,8 @@ class BrightcoveNewIE(AdobePassIE):
|
||||||
error = errors[0]
|
error = errors[0]
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
error.get('message') or error.get('error_subcode') or error['error_code'], expected=True)
|
error.get('message') or error.get('error_subcode') or error['error_code'], expected=True)
|
||||||
if not self._downloader.params.get('allow_unplayable_formats') and sources and num_drm_sources == len(sources):
|
if (not self._downloader.params.get('allow_unplayable_formats')
|
||||||
|
and sources and num_drm_sources == len(sources)):
|
||||||
raise ExtractorError('This video is DRM protected.', expected=True)
|
raise ExtractorError('This video is DRM protected.', expected=True)
|
||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
|
@ -147,7 +147,8 @@ class CeskaTelevizeIE(InfoExtractor):
|
||||||
is_live = item.get('type') == 'LIVE'
|
is_live = item.get('type') == 'LIVE'
|
||||||
formats = []
|
formats = []
|
||||||
for format_id, stream_url in item.get('streamUrls', {}).items():
|
for format_id, stream_url in item.get('streamUrls', {}).items():
|
||||||
if not self._downloader.params.get('allow_unplayable_formats') and 'drmOnly=true' in stream_url:
|
if (not self._downloader.params.get('allow_unplayable_formats')
|
||||||
|
and 'drmOnly=true' in stream_url):
|
||||||
continue
|
continue
|
||||||
if 'playerType=flash' in stream_url:
|
if 'playerType=flash' in stream_url:
|
||||||
stream_formats = self._extract_m3u8_formats(
|
stream_formats = self._extract_m3u8_formats(
|
||||||
|
|
|
@ -2358,7 +2358,7 @@ class InfoExtractor(object):
|
||||||
extract_Initialization(segment_template)
|
extract_Initialization(segment_template)
|
||||||
return ms_info
|
return ms_info
|
||||||
|
|
||||||
allow_unplayable_formats = self._downloader.params.get('allow_unplayable_formats')
|
skip_unplayable = not self._downloader.params.get('allow_unplayable_formats')
|
||||||
|
|
||||||
mpd_duration = parse_duration(mpd_doc.get('mediaPresentationDuration'))
|
mpd_duration = parse_duration(mpd_doc.get('mediaPresentationDuration'))
|
||||||
formats = []
|
formats = []
|
||||||
|
@ -2369,11 +2369,11 @@ class InfoExtractor(object):
|
||||||
'timescale': 1,
|
'timescale': 1,
|
||||||
})
|
})
|
||||||
for adaptation_set in period.findall(_add_ns('AdaptationSet')):
|
for adaptation_set in period.findall(_add_ns('AdaptationSet')):
|
||||||
if is_drm_protected(adaptation_set) and allow_unplayable_formats is False:
|
if skip_unplayable and is_drm_protected(adaptation_set):
|
||||||
continue
|
continue
|
||||||
adaption_set_ms_info = extract_multisegment_info(adaptation_set, period_ms_info)
|
adaption_set_ms_info = extract_multisegment_info(adaptation_set, period_ms_info)
|
||||||
for representation in adaptation_set.findall(_add_ns('Representation')):
|
for representation in adaptation_set.findall(_add_ns('Representation')):
|
||||||
if is_drm_protected(representation) and allow_unplayable_formats is False:
|
if skip_unplayable and is_drm_protected(representation):
|
||||||
continue
|
continue
|
||||||
representation_attrib = adaptation_set.attrib.copy()
|
representation_attrib = adaptation_set.attrib.copy()
|
||||||
representation_attrib.update(representation.attrib)
|
representation_attrib.update(representation.attrib)
|
||||||
|
@ -2587,7 +2587,10 @@ class InfoExtractor(object):
|
||||||
1. [MS-SSTR]: Smooth Streaming Protocol,
|
1. [MS-SSTR]: Smooth Streaming Protocol,
|
||||||
https://msdn.microsoft.com/en-us/library/ff469518.aspx
|
https://msdn.microsoft.com/en-us/library/ff469518.aspx
|
||||||
"""
|
"""
|
||||||
if ism_doc.get('IsLive') == 'TRUE' or (ism_doc.find('Protection') is not None and not self._downloader.params.get('allow_unplayable_formats')):
|
if ism_doc.get('IsLive') == 'TRUE':
|
||||||
|
return []
|
||||||
|
if (not self._downloader.params.get('allow_unplayable_formats')
|
||||||
|
and ism_doc.find('Protection') is not None):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
duration = int(ism_doc.attrib['Duration'])
|
duration = int(ism_doc.attrib['Duration'])
|
||||||
|
|
|
@ -163,7 +163,10 @@ class IviIE(InfoExtractor):
|
||||||
for f in result.get('files', []):
|
for f in result.get('files', []):
|
||||||
f_url = f.get('url')
|
f_url = f.get('url')
|
||||||
content_format = f.get('content_format')
|
content_format = f.get('content_format')
|
||||||
if not f_url or (not self._downloader.params.get('allow_unplayable_formats') and ('-MDRM-' in content_format or '-FPS-' in content_format)):
|
if not f_url:
|
||||||
|
continue
|
||||||
|
if (not self._downloader.params.get('allow_unplayable_formats')
|
||||||
|
and ('-MDRM-' in content_format or '-FPS-' in content_format)):
|
||||||
continue
|
continue
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': f_url,
|
'url': f_url,
|
||||||
|
|
|
@ -96,7 +96,9 @@ class LimelightBaseIE(InfoExtractor):
|
||||||
urls = []
|
urls = []
|
||||||
for stream in pc_item.get('streams', []):
|
for stream in pc_item.get('streams', []):
|
||||||
stream_url = stream.get('url')
|
stream_url = stream.get('url')
|
||||||
if not stream_url or (not self._downloader.params.get('allow_unplayable_formats') and stream.get('drmProtected')) or stream_url in urls:
|
if not stream_url or stream_url in urls:
|
||||||
|
continue
|
||||||
|
if not self._downloader.params.get('allow_unplayable_formats') and stream.get('drmProtected'):
|
||||||
continue
|
continue
|
||||||
urls.append(stream_url)
|
urls.append(stream_url)
|
||||||
ext = determine_ext(stream_url)
|
ext = determine_ext(stream_url)
|
||||||
|
|
|
@ -36,7 +36,8 @@ class NineCNineMediaIE(InfoExtractor):
|
||||||
'$include': '[HasClosedCaptions]',
|
'$include': '[HasClosedCaptions]',
|
||||||
})
|
})
|
||||||
|
|
||||||
if not self._downloader.params.get('allow_unplayable_formats') and try_get(content_package, lambda x: x['Constraints']['Security']['Type']):
|
if (not self._downloader.params.get('allow_unplayable_formats')
|
||||||
|
and try_get(content_package, lambda x: x['Constraints']['Security']['Type'])):
|
||||||
raise ExtractorError('This video is DRM protected.', expected=True)
|
raise ExtractorError('This video is DRM protected.', expected=True)
|
||||||
|
|
||||||
manifest_base_url = content_package_url + 'manifest.'
|
manifest_base_url = content_package_url + 'manifest.'
|
||||||
|
|
|
@ -200,8 +200,8 @@ class RuutuIE(InfoExtractor):
|
||||||
return node.get('value')
|
return node.get('value')
|
||||||
|
|
||||||
if not formats:
|
if not formats:
|
||||||
drm = xpath_text(video_xml, './Clip/DRM', default=None)
|
if (not self._downloader.params.get('allow_unplayable_formats')
|
||||||
if not self._downloader.params.get('allow_unplayable_formats') and drm:
|
and xpath_text(video_xml, './Clip/DRM', default=None)):
|
||||||
raise ExtractorError('This video is DRM protected.', expected=True)
|
raise ExtractorError('This video is DRM protected.', expected=True)
|
||||||
ns_st_cds = pv('ns_st_cds')
|
ns_st_cds = pv('ns_st_cds')
|
||||||
if ns_st_cds != 'free':
|
if ns_st_cds != 'free':
|
||||||
|
|
|
@ -154,7 +154,8 @@ class ToggleIE(InfoExtractor):
|
||||||
})
|
})
|
||||||
if not formats:
|
if not formats:
|
||||||
for meta in (info.get('Metas') or []):
|
for meta in (info.get('Metas') or []):
|
||||||
if not self._downloader.params.get('allow_unplayable_formats') and meta.get('Key') == 'Encryption' and meta.get('Value') == '1':
|
if (not self._downloader.params.get('allow_unplayable_formats')
|
||||||
|
and meta.get('Key') == 'Encryption' and meta.get('Value') == '1'):
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
'This video is DRM protected.', expected=True)
|
'This video is DRM protected.', expected=True)
|
||||||
# Most likely because geo-blocked
|
# Most likely because geo-blocked
|
||||||
|
|
|
@ -41,12 +41,13 @@ class WakanimIE(InfoExtractor):
|
||||||
m3u8_url = urljoin(url, self._search_regex(
|
m3u8_url = urljoin(url, self._search_regex(
|
||||||
r'file\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'm3u8 url',
|
r'file\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'm3u8 url',
|
||||||
group='url'))
|
group='url'))
|
||||||
# https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-content-protection-overview#streaming-urls
|
if not self._downloader.params.get('allow_unplayable_formats'):
|
||||||
encryption = self._search_regex(
|
# https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-content-protection-overview#streaming-urls
|
||||||
r'encryption%3D(c(?:enc|bc(?:s-aapl)?))',
|
encryption = self._search_regex(
|
||||||
m3u8_url, 'encryption', default=None)
|
r'encryption%3D(c(?:enc|bc(?:s-aapl)?))',
|
||||||
if not self._downloader.params.get('allow_unplayable_formats') and encryption and encryption in ('cenc', 'cbcs-aapl'):
|
m3u8_url, 'encryption', default=None)
|
||||||
raise ExtractorError('This video is DRM protected.', expected=True)
|
if encryption in ('cenc', 'cbcs-aapl'):
|
||||||
|
raise ExtractorError('This video is DRM protected.', expected=True)
|
||||||
|
|
||||||
formats = self._extract_m3u8_formats(
|
formats = self._extract_m3u8_formats(
|
||||||
m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
||||||
|
|
|
@ -221,8 +221,7 @@ class FFmpegPostProcessor(PostProcessor):
|
||||||
|
|
||||||
cmd += opts
|
cmd += opts
|
||||||
cmd.append(encodeFilename(self._ffmpeg_filename_argument(path), True))
|
cmd.append(encodeFilename(self._ffmpeg_filename_argument(path), True))
|
||||||
if self._downloader.params.get('verbose', False):
|
self.write_debug('ffprobe command line: %s' % shell_quote(cmd))
|
||||||
self._downloader.to_screen('[debug] ffprobe command line: %s' % shell_quote(cmd))
|
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
return json.loads(stdout.decode('utf-8', 'replace'))
|
return json.loads(stdout.decode('utf-8', 'replace'))
|
||||||
|
@ -261,7 +260,7 @@ class FFmpegPostProcessor(PostProcessor):
|
||||||
stdout, stderr = process_communicate_or_kill(p)
|
stdout, stderr = process_communicate_or_kill(p)
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
stderr = stderr.decode('utf-8', 'replace').strip()
|
stderr = stderr.decode('utf-8', 'replace').strip()
|
||||||
if self._downloader.params.get('verbose', False):
|
if self.get_param('verbose', False):
|
||||||
self.report_error(stderr)
|
self.report_error(stderr)
|
||||||
raise FFmpegPostProcessorError(stderr.split('\n')[-1])
|
raise FFmpegPostProcessorError(stderr.split('\n')[-1])
|
||||||
self.try_utime(out_path, oldest_mtime, oldest_mtime)
|
self.try_utime(out_path, oldest_mtime, oldest_mtime)
|
||||||
|
|
|
@ -59,7 +59,7 @@ def update_self(to_screen, verbose, opener):
|
||||||
if verbose:
|
if verbose:
|
||||||
to_screen(encode_compat_str(traceback.format_exc()))
|
to_screen(encode_compat_str(traceback.format_exc()))
|
||||||
to_screen('ERROR: can\'t obtain versions info. Please try again later.')
|
to_screen('ERROR: can\'t obtain versions info. Please try again later.')
|
||||||
to_screen('Visit https://github.com/pukkandan/yt-dlp/releases/lastest')
|
to_screen('Visit https://github.com/pukkandan/yt-dlp/releases/latest')
|
||||||
return
|
return
|
||||||
|
|
||||||
version_id = version_info['tag_name']
|
version_id = version_info['tag_name']
|
||||||
|
@ -107,7 +107,7 @@ def update_self(to_screen, verbose, opener):
|
||||||
if verbose:
|
if verbose:
|
||||||
to_screen(encode_compat_str(traceback.format_exc()))
|
to_screen(encode_compat_str(traceback.format_exc()))
|
||||||
to_screen('ERROR: unable to download latest version')
|
to_screen('ERROR: unable to download latest version')
|
||||||
to_screen('Visit https://github.com/pukkandan/yt-dlp/releases/lastest')
|
to_screen('Visit https://github.com/pukkandan/yt-dlp/releases/latest')
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -150,7 +150,7 @@ def update_self(to_screen, verbose, opener):
|
||||||
if verbose:
|
if verbose:
|
||||||
to_screen(encode_compat_str(traceback.format_exc()))
|
to_screen(encode_compat_str(traceback.format_exc()))
|
||||||
to_screen('ERROR: unable to download latest version')
|
to_screen('ERROR: unable to download latest version')
|
||||||
to_screen('Visit https://github.com/pukkandan/yt-dlp/releases/lastest')
|
to_screen('Visit https://github.com/pukkandan/yt-dlp/releases/latest')
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue