Skip to content

Commit

Permalink
Fix BBCCoUkIPlayerPlaylistIE
Browse files Browse the repository at this point in the history
The playlist metadata is now sent in a JSON expression within a <script> element.
  • Loading branch information
dirkf committed Mar 16, 2021
1 parent 7c7d42e commit dc43160
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions youtube_dl/extractor/bbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ class BBCCoUkIPlayerPlaylistIE(BBCCoUkPlaylistBaseIE):
IE_NAME = 'bbc.co.uk:iplayer:playlist'
_VALID_URL = r'https?://(?:www\.)?bbc\.co\.uk/iplayer/(?:episodes|group)/(?P<id>%s)' % BBCCoUkIE._ID_REGEX
_URL_TEMPLATE = 'http://www.bbc.co.uk/iplayer/episode/%s'
_VIDEO_ID_TEMPLATE = r'data-ip-id=["\'](%s)'
_VIDEO_ID_TEMPLATE = r'"href":\s*"/iplayer/episode/(%s)/'
_TESTS = [{
'url': 'http://www.bbc.co.uk/iplayer/episodes/b05rcz9v',
'info_dict': {
Expand All @@ -1363,11 +1363,18 @@ class BBCCoUkIPlayerPlaylistIE(BBCCoUkPlaylistBaseIE):
'playlist_mincount': 10,
}]

def _extract_title_and_description(self, webpage):
title = self._search_regex(r'<h1>([^<]+)</h1>', webpage, 'title', fatal=False)
description = self._search_regex(
r'<p[^>]+class=(["\'])subtitle\1[^>]*>(?P<value>[^<]+)</p>',
webpage, 'description', fatal=False, group='value')
def _extract_title_and_description(self, webpage, playlist_id):
redux_state = self._parse_json(self._html_search_regex(
r'<script[^>]+id=(["\'])tvip-script-app-store\1[^>]*>[^<]*_REDUX_STATE__\s*=\s*(?P<json>[^<]+)\s*;\s*<',
webpage, 'redux state', default='{}', group='json'), playlist_id, fatal=False)
if redux_state:
redux_hdr = redux_state.get('header') or {}
redux_hdr.update(redux_state.get('page') or {})
redux_state = redux_hdr
title = redux_state.get('title') or self._og_search_title(webpage, fatal=False)
description = redux_state.get('description') or \
self._html_search_meta('description', webpage, default=None) or \
self._og_search_description(webpage)
return title, description


Expand Down

0 comments on commit dc43160

Please sign in to comment.