aboutsummaryrefslogtreecommitdiffstats
path: root/youtube_dlc/extractor
diff options
context:
space:
mode:
authorpukkandan <pukkandan@gmail.com>2021-02-12 10:04:04 +0530
committerpukkandan <pukkandan@gmail.com>2021-02-12 20:32:49 +0530
commit068693675ef45c6f0b752c53d8810193d33dc712 (patch)
tree9c7093d8610a1be34290fc7f74799ccc36feb590 /youtube_dlc/extractor
parent1ea241292770c6027b951aa045e00eadd140b9f5 (diff)
downloadhypervideo-pre-068693675ef45c6f0b752c53d8810193d33dc712.tar.lz
hypervideo-pre-068693675ef45c6f0b752c53d8810193d33dc712.tar.xz
hypervideo-pre-068693675ef45c6f0b752c53d8810193d33dc712.zip
Cleanup some code and fix typos
:ci skip dl
Diffstat (limited to 'youtube_dlc/extractor')
-rw-r--r--youtube_dlc/extractor/brightcove.py8
-rw-r--r--youtube_dlc/extractor/ceskatelevize.py3
-rw-r--r--youtube_dlc/extractor/common.py11
-rw-r--r--youtube_dlc/extractor/ivi.py5
-rw-r--r--youtube_dlc/extractor/limelight.py4
-rw-r--r--youtube_dlc/extractor/ninecninemedia.py3
-rw-r--r--youtube_dlc/extractor/ruutu.py4
-rw-r--r--youtube_dlc/extractor/toggle.py3
-rw-r--r--youtube_dlc/extractor/wakanim.py13
9 files changed, 34 insertions, 20 deletions
diff --git a/youtube_dlc/extractor/brightcove.py b/youtube_dlc/extractor/brightcove.py
index 091992ebd..8b29ca993 100644
--- a/youtube_dlc/extractor/brightcove.py
+++ b/youtube_dlc/extractor/brightcove.py
@@ -478,11 +478,12 @@ class BrightcoveNewIE(AdobePassIE):
container = source.get('container')
ext = mimetype2ext(source.get('type'))
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
- 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
continue
- elif ext == 'ism' and not self._downloader.params.get('allow_unplayable_formats'):
+ elif ext == 'ism' and skip_unplayable:
continue
elif ext == 'm3u8' or container == 'M2TS':
if not src:
@@ -546,7 +547,8 @@ class BrightcoveNewIE(AdobePassIE):
error = errors[0]
raise ExtractorError(
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)
self._sort_formats(formats)
diff --git a/youtube_dlc/extractor/ceskatelevize.py b/youtube_dlc/extractor/ceskatelevize.py
index dc8b04ec6..6bfb760fa 100644
--- a/youtube_dlc/extractor/ceskatelevize.py
+++ b/youtube_dlc/extractor/ceskatelevize.py
@@ -147,7 +147,8 @@ class CeskaTelevizeIE(InfoExtractor):
is_live = item.get('type') == 'LIVE'
formats = []
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
if 'playerType=flash' in stream_url:
stream_formats = self._extract_m3u8_formats(
diff --git a/youtube_dlc/extractor/common.py b/youtube_dlc/extractor/common.py
index 1fe2d0a93..371c34929 100644
--- a/youtube_dlc/extractor/common.py
+++ b/youtube_dlc/extractor/common.py
@@ -2358,7 +2358,7 @@ class InfoExtractor(object):
extract_Initialization(segment_template)
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'))
formats = []
@@ -2369,11 +2369,11 @@ class InfoExtractor(object):
'timescale': 1,
})
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
adaption_set_ms_info = extract_multisegment_info(adaptation_set, period_ms_info)
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
representation_attrib = adaptation_set.attrib.copy()
representation_attrib.update(representation.attrib)
@@ -2587,7 +2587,10 @@ class InfoExtractor(object):
1. [MS-SSTR]: Smooth Streaming Protocol,
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 []
duration = int(ism_doc.attrib['Duration'])
diff --git a/youtube_dlc/extractor/ivi.py b/youtube_dlc/extractor/ivi.py
index 7952ab9e6..580cf41cd 100644
--- a/youtube_dlc/extractor/ivi.py
+++ b/youtube_dlc/extractor/ivi.py
@@ -163,7 +163,10 @@ class IviIE(InfoExtractor):
for f in result.get('files', []):
f_url = f.get('url')
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
formats.append({
'url': f_url,
diff --git a/youtube_dlc/extractor/limelight.py b/youtube_dlc/extractor/limelight.py
index 6592f60da..b95b001ad 100644
--- a/youtube_dlc/extractor/limelight.py
+++ b/youtube_dlc/extractor/limelight.py
@@ -96,7 +96,9 @@ class LimelightBaseIE(InfoExtractor):
urls = []
for stream in pc_item.get('streams', []):
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
urls.append(stream_url)
ext = determine_ext(stream_url)
diff --git a/youtube_dlc/extractor/ninecninemedia.py b/youtube_dlc/extractor/ninecninemedia.py
index 39ae4c66e..f98e8396b 100644
--- a/youtube_dlc/extractor/ninecninemedia.py
+++ b/youtube_dlc/extractor/ninecninemedia.py
@@ -36,7 +36,8 @@ class NineCNineMediaIE(InfoExtractor):
'$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)
manifest_base_url = content_package_url + 'manifest.'
diff --git a/youtube_dlc/extractor/ruutu.py b/youtube_dlc/extractor/ruutu.py
index 5db83a4e1..f9f30e3dd 100644
--- a/youtube_dlc/extractor/ruutu.py
+++ b/youtube_dlc/extractor/ruutu.py
@@ -200,8 +200,8 @@ class RuutuIE(InfoExtractor):
return node.get('value')
if not formats:
- drm = xpath_text(video_xml, './Clip/DRM', default=None)
- if not self._downloader.params.get('allow_unplayable_formats') and drm:
+ if (not self._downloader.params.get('allow_unplayable_formats')
+ and xpath_text(video_xml, './Clip/DRM', default=None)):
raise ExtractorError('This video is DRM protected.', expected=True)
ns_st_cds = pv('ns_st_cds')
if ns_st_cds != 'free':
diff --git a/youtube_dlc/extractor/toggle.py b/youtube_dlc/extractor/toggle.py
index 1ba55b555..1e2a2d819 100644
--- a/youtube_dlc/extractor/toggle.py
+++ b/youtube_dlc/extractor/toggle.py
@@ -154,7 +154,8 @@ class ToggleIE(InfoExtractor):
})
if not formats:
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(
'This video is DRM protected.', expected=True)
# Most likely because geo-blocked
diff --git a/youtube_dlc/extractor/wakanim.py b/youtube_dlc/extractor/wakanim.py
index a8963d769..507a28feb 100644
--- a/youtube_dlc/extractor/wakanim.py
+++ b/youtube_dlc/extractor/wakanim.py
@@ -41,12 +41,13 @@ class WakanimIE(InfoExtractor):
m3u8_url = urljoin(url, self._search_regex(
r'file\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'm3u8 url',
group='url'))
- # https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-content-protection-overview#streaming-urls
- encryption = self._search_regex(
- r'encryption%3D(c(?:enc|bc(?:s-aapl)?))',
- m3u8_url, 'encryption', default=None)
- if not self._downloader.params.get('allow_unplayable_formats') and encryption and encryption in ('cenc', 'cbcs-aapl'):
- raise ExtractorError('This video is DRM protected.', expected=True)
+ if not self._downloader.params.get('allow_unplayable_formats'):
+ # https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-content-protection-overview#streaming-urls
+ encryption = self._search_regex(
+ r'encryption%3D(c(?:enc|bc(?:s-aapl)?))',
+ m3u8_url, 'encryption', default=None)
+ if encryption in ('cenc', 'cbcs-aapl'):
+ raise ExtractorError('This video is DRM protected.', expected=True)
formats = self._extract_m3u8_formats(
m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native',