diff options
author | nixxo <nixxo@protonmail.com> | 2021-01-07 16:49:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-07 16:49:07 +0100 |
commit | 1c3a61baae8f9aea1fa5610317e9bfd63a259d2d (patch) | |
tree | 27b312678d5eb1bed87ebb0af9f453fbfa94a424 /youtube_dlc/extractor/cspan.py | |
parent | 727006d9515441ae44dd034955fd220d5afed9a6 (diff) | |
parent | 9d88274ca2e5248481204e753b458e3a4eeac60e (diff) | |
download | hypervideo-pre-1c3a61baae8f9aea1fa5610317e9bfd63a259d2d.tar.lz hypervideo-pre-1c3a61baae8f9aea1fa5610317e9bfd63a259d2d.tar.xz hypervideo-pre-1c3a61baae8f9aea1fa5610317e9bfd63a259d2d.zip |
Merge branch 'master' into akamai-fix
Diffstat (limited to 'youtube_dlc/extractor/cspan.py')
-rw-r--r-- | youtube_dlc/extractor/cspan.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/youtube_dlc/extractor/cspan.py b/youtube_dlc/extractor/cspan.py index 67d6df4b0..766942146 100644 --- a/youtube_dlc/extractor/cspan.py +++ b/youtube_dlc/extractor/cspan.py @@ -10,6 +10,8 @@ from ..utils import ( find_xpath_attr, get_element_by_class, int_or_none, + js_to_json, + merge_dicts, smuggle_url, unescapeHTML, ) @@ -98,6 +100,26 @@ class CSpanIE(InfoExtractor): bc_attr['data-bcid']) return self.url_result(smuggle_url(bc_url, {'source_url': url})) + def add_referer(formats): + for f in formats: + f.setdefault('http_headers', {})['Referer'] = url + + # As of 01.12.2020 this path looks to cover all cases making the rest + # of the code unnecessary + jwsetup = self._parse_json( + self._search_regex( + r'(?s)jwsetup\s*=\s*({.+?})\s*;', webpage, 'jwsetup', + default='{}'), + video_id, transform_source=js_to_json, fatal=False) + if jwsetup: + info = self._parse_jwplayer_data( + jwsetup, video_id, require_title=False, m3u8_id='hls', + base_url=url) + add_referer(info['formats']) + ld_info = self._search_json_ld(webpage, video_id, default={}) + return merge_dicts(info, ld_info) + + # Obsolete # We first look for clipid, because clipprog always appears before patterns = [r'id=\'clip(%s)\'\s*value=\'([0-9]+)\'' % t for t in ('id', 'prog')] results = list(filter(None, (re.search(p, webpage) for p in patterns))) @@ -165,6 +187,7 @@ class CSpanIE(InfoExtractor): formats = self._extract_m3u8_formats( path, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls') if determine_ext(path) == 'm3u8' else [{'url': path, }] + add_referer(formats) self._sort_formats(formats) entries.append({ 'id': '%s_%d' % (video_id, partnum + 1), |