]>
Commit | Line | Data |
---|---|---|
90e3f18f S |
1 | import re |
2 | ||
5f3e0b69 | 3 | from .common import InfoExtractor |
80c2126e | 4 | from ..utils import extract_attributes |
5f3e0b69 E |
5 | |
6 | ||
7 | class TheSunIE(InfoExtractor): | |
0181b9a1 HTL |
8 | _VALID_URL = r'https?://(?:www\.)?the-?sun(\.co\.uk|\.com)/[^/]+/(?P<id>\d+)' |
9 | _TESTS = [{ | |
5f3e0b69 | 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, | |
0181b9a1 HTL |
16 | }, { |
17 | 'url': 'https://www.the-sun.com/entertainment/7611415/1000lb-sisters-fans-rip-amy-dangerous-health-decision/', | |
18 | 'info_dict': { | |
19 | 'id': '7611415', | |
20 | 'title': 'md5:e0b9b976f79dc770e5c80f22f40bb844', | |
21 | }, | |
22 | 'playlist_count': 1, | |
23 | }] | |
80c2126e | 24 | BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s' |
5f3e0b69 E |
25 | |
26 | def _real_extract(self, url): | |
90e3f18f S |
27 | article_id = self._match_id(url) |
28 | ||
29 | webpage = self._download_webpage(url, article_id) | |
5f3e0b69 | 30 | |
90e3f18f | 31 | entries = [] |
80c2126e RA |
32 | for video in re.findall( |
33 | r'<video[^>]+data-video-id-pending=[^>]+>', | |
90e3f18f | 34 | webpage): |
80c2126e RA |
35 | attrs = extract_attributes(video) |
36 | video_id = attrs['data-video-id-pending'] | |
37 | account_id = attrs.get('data-account', '5067014667001') | |
38 | entries.append(self.url_result( | |
39 | self.BRIGHTCOVE_URL_TEMPLATE % (account_id, video_id), | |
40 | 'BrightcoveNew', video_id)) | |
5f3e0b69 | 41 | |
90e3f18f S |
42 | return self.playlist_result( |
43 | entries, article_id, self._og_search_title(webpage, fatal=False)) |