]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/thesun.py
Allow extractors to specify section_start/end for clips
[yt-dlp.git] / yt_dlp / extractor / thesun.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import extract_attributes
5
6
7 class TheSunIE(InfoExtractor):
8 _VALID_URL = r'https://(?:www\.)?thesun\.co\.uk/[^/]+/(?P<id>\d+)'
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/',
11 'info_dict': {
12 'id': '2261604',
13 'title': 'md5:cba22f48bad9218b64d5bbe0e16afddf',
14 },
15 'playlist_count': 2,
16 }
17 BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s'
18
19 def _real_extract(self, url):
20 article_id = self._match_id(url)
21
22 webpage = self._download_webpage(url, article_id)
23
24 entries = []
25 for video in re.findall(
26 r'<video[^>]+data-video-id-pending=[^>]+>',
27 webpage):
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))
34
35 return self.playlist_result(
36 entries, article_id, self._og_search_title(webpage, fatal=False))