]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/thesun.py
[cleanup] Upgrade syntax
[yt-dlp.git] / yt_dlp / extractor / thesun.py
CommitLineData
90e3f18f
S
1import re
2
5f3e0b69 3from .common import InfoExtractor
80c2126e 4from ..utils import extract_attributes
5f3e0b69
E
5
6
7class TheSunIE(InfoExtractor):
90e3f18f 8 _VALID_URL = r'https://(?:www\.)?thesun\.co\.uk/[^/]+/(?P<id>\d+)'
5f3e0b69
E
9 _TEST = {
10 'url': 'https://www.thesun.co.uk/tvandshowbiz/2261604/orlando-bloom-and-katy-perry-post-adorable-instagram-video-together-celebrating-thanksgiving-after-split-rumours/',
5f3e0b69 11 'info_dict': {
90e3f18f
S
12 'id': '2261604',
13 'title': 'md5:cba22f48bad9218b64d5bbe0e16afddf',
14 },
15 'playlist_count': 2,
5f3e0b69 16 }
80c2126e 17 BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s'
5f3e0b69
E
18
19 def _real_extract(self, url):
90e3f18f
S
20 article_id = self._match_id(url)
21
22 webpage = self._download_webpage(url, article_id)
5f3e0b69 23
90e3f18f 24 entries = []
80c2126e
RA
25 for video in re.findall(
26 r'<video[^>]+data-video-id-pending=[^>]+>',
90e3f18f 27 webpage):
80c2126e
RA
28 attrs = extract_attributes(video)
29 video_id = attrs['data-video-id-pending']
30 account_id = attrs.get('data-account', '5067014667001')
31 entries.append(self.url_result(
32 self.BRIGHTCOVE_URL_TEMPLATE % (account_id, video_id),
33 'BrightcoveNew', video_id))
5f3e0b69 34
90e3f18f
S
35 return self.playlist_result(
36 entries, article_id, self._og_search_title(webpage, fatal=False))