Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support BBC Reel URIs #28268

Closed
wants to merge 16 commits into from
26 changes: 26 additions & 0 deletions youtube_dl/extractor/bbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,32 @@ def _real_extract(self, url):
r'videoId\s*:\s*["\'](%s)["\']' % self._ID_REGEX],
webpage, 'vpid', default=None)

# bbc reel (e.g. https://www.bbc.com/reel/video/p07c6sb6/how-positive-thinking-is-harming-your-happiness)
if not programme_id:
initial_data = self._search_regex(
dirkf marked this conversation as resolved.
Show resolved Hide resolved
r'<script[^>]+id="initial-data"[^>]+data-json=\'(.+)\'>',
dirkf marked this conversation as resolved.
Show resolved Hide resolved
webpage, 'initial data', default=None)
if initial_data:
# let's see if it actually is, or ExtractorError
initial_data = self._parse_json(unescapeHTML(initial_data), 'initial data')
dirkf marked this conversation as resolved.
Show resolved Hide resolved

def _extract_pid(data):
if isinstance(data, dict):
if data.get('kind', '') == 'programme' and 'versionID' in data:
return data['versionID']
else:
for k in data:
pid = _extract_pid(data[k])
if pid:
return pid
elif isinstance(data, list):
for v in data:
pid = _extract_pid(v)
if pid:
return pid
return None
programme_id = _extract_pid(initial_data)
dirkf marked this conversation as resolved.
Show resolved Hide resolved

if programme_id:
formats, subtitles = self._download_media_selector(programme_id)
self._sort_formats(formats)
Expand Down