0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-17 01:25:11 +00:00

[npo] Validate and filter format URLs (closes #15709)

This commit is contained in:
Sergey M․ 2018-02-26 21:50:51 +07:00
parent 6ab35f5e16
commit d1b6187012
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D

View file

@ -195,6 +195,10 @@ def _get_info(self, video_id):
formats = [] formats = []
urls = set() urls = set()
def is_legal_url(format_url):
return format_url and format_url not in urls and re.match(
r'^(?:https?:)?//', format_url)
QUALITY_LABELS = ('Laag', 'Normaal', 'Hoog') QUALITY_LABELS = ('Laag', 'Normaal', 'Hoog')
QUALITY_FORMATS = ('adaptive', 'wmv_sb', 'h264_sb', 'wmv_bb', 'h264_bb', 'wvc1_std', 'h264_std') QUALITY_FORMATS = ('adaptive', 'wmv_sb', 'h264_sb', 'wmv_bb', 'h264_bb', 'wvc1_std', 'h264_std')
@ -208,7 +212,7 @@ def _get_info(self, video_id):
})['items'][0] })['items'][0]
for num, item in enumerate(items): for num, item in enumerate(items):
item_url = item.get('url') item_url = item.get('url')
if not item_url or item_url in urls: if not is_legal_url(item_url):
continue continue
urls.add(item_url) urls.add(item_url)
format_id = self._search_regex( format_id = self._search_regex(
@ -279,7 +283,7 @@ def add_format_url(format_url):
if not is_live: if not is_live:
for num, stream in enumerate(metadata.get('streams', [])): for num, stream in enumerate(metadata.get('streams', [])):
stream_url = stream.get('url') stream_url = stream.get('url')
if not stream_url or stream_url in urls: if not is_legal_url(stream_url):
continue continue
urls.add(stream_url) urls.add(stream_url)
# smooth streaming is not supported # smooth streaming is not supported