]>
Commit | Line | Data |
---|---|---|
29f7c58a | 1 | import re |
2 | ||
df43389a | 3 | from .common import InfoExtractor |
44cca168 RA |
4 | from ..utils import ( |
5 | extract_attributes, | |
44cca168 | 6 | strip_or_none, |
44cca168 | 7 | ) |
df43389a RA |
8 | |
9 | ||
71ebd35d | 10 | class SkyBaseIE(InfoExtractor): |
29f7c58a | 11 | BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/%s_default/index.html?videoId=%s' |
12 | _SDC_EL_REGEX = r'(?s)(<div[^>]+data-(?:component-name|fn)="sdc-(?:articl|sit)e-video"[^>]*>)' | |
13 | ||
9751a457 | 14 | def _process_video_element(self, webpage, sdc_el, url): |
29f7c58a | 15 | sdc = extract_attributes(sdc_el) |
16 | provider = sdc.get('data-provider') | |
9751a457 | 17 | if provider == 'brightcove': |
29f7c58a | 18 | video_id = sdc['data-video-id'] |
19 | account_id = sdc.get('data-account-id') or '6058004172001' | |
20 | player_id = sdc.get('data-player-id') or 'RC9PQUaJ6' | |
21 | video_url = self.BRIGHTCOVE_URL_TEMPLATE % (account_id, player_id, video_id) | |
22 | ie_key = 'BrightcoveNew' | |
df43389a RA |
23 | |
24 | return { | |
25 | '_type': 'url_transparent', | |
26 | 'id': video_id, | |
44cca168 | 27 | 'url': video_url, |
29f7c58a | 28 | 'ie_key': ie_key, |
29 | } | |
30 | ||
31 | def _real_extract(self, url): | |
32 | video_id = self._match_id(url) | |
33 | webpage = self._download_webpage(url, video_id) | |
9751a457 | 34 | info = self._process_video_element(webpage, self._search_regex( |
29f7c58a | 35 | self._SDC_EL_REGEX, webpage, 'sdc element'), url) |
36 | info.update({ | |
df43389a | 37 | 'title': self._og_search_title(webpage), |
a814da3f | 38 | 'description': strip_or_none(self._og_search_description(webpage)), |
29f7c58a | 39 | }) |
40 | return info | |
71ebd35d RA |
41 | |
42 | ||
43 | class SkySportsIE(SkyBaseIE): | |
29f7c58a | 44 | IE_NAME = 'sky:sports' |
45 | _VALID_URL = r'https?://(?:www\.)?skysports\.com/watch/video/([^/]+/)*(?P<id>[0-9]+)' | |
46 | _TESTS = [{ | |
71ebd35d RA |
47 | 'url': 'http://www.skysports.com/watch/video/10328419/bale-its-our-time-to-shine', |
48 | 'md5': '77d59166cddc8d3cb7b13e35eaf0f5ec', | |
49 | 'info_dict': { | |
50 | 'id': 'o3eWJnNDE6l7kfNO8BOoBlRxXRQ4ANNQ', | |
51 | 'ext': 'mp4', | |
52 | 'title': 'Bale: It\'s our time to shine', | |
53 | 'description': 'md5:e88bda94ae15f7720c5cb467e777bb6d', | |
54 | }, | |
9751a457 | 55 | 'add_ie': ['BrightcoveNew'], |
29f7c58a | 56 | }, { |
57 | 'url': 'https://www.skysports.com/watch/video/sports/f1/12160544/abu-dhabi-gp-the-notebook', | |
58 | 'only_matching': True, | |
59 | }, { | |
60 | 'url': 'https://www.skysports.com/watch/video/tv-shows/12118508/rainford-brent-how-ace-programme-helps', | |
61 | 'only_matching': True, | |
62 | }] | |
71ebd35d RA |
63 | |
64 | ||
65 | class SkyNewsIE(SkyBaseIE): | |
29f7c58a | 66 | IE_NAME = 'sky:news' |
71ebd35d RA |
67 | _VALID_URL = r'https?://news\.sky\.com/video/[0-9a-z-]+-(?P<id>[0-9]+)' |
68 | _TEST = { | |
69 | 'url': 'https://news.sky.com/video/russian-plane-inspected-after-deadly-fire-11712962', | |
29f7c58a | 70 | 'md5': '411e8893fd216c75eaf7e4c65d364115', |
71ebd35d | 71 | 'info_dict': { |
29f7c58a | 72 | 'id': 'ref:1ua21xaDE6lCtZDmbYfl8kwsKLooJbNM', |
71ebd35d RA |
73 | 'ext': 'mp4', |
74 | 'title': 'Russian plane inspected after deadly fire', | |
75 | 'description': 'The Russian Investigative Committee has released video of the wreckage of a passenger plane which caught fire near Moscow.', | |
29f7c58a | 76 | 'uploader_id': '6058004172001', |
77 | 'timestamp': 1567112345, | |
78 | 'upload_date': '20190829', | |
71ebd35d | 79 | }, |
29f7c58a | 80 | 'add_ie': ['BrightcoveNew'], |
81 | } | |
82 | ||
83 | ||
b7b186e7 | 84 | class SkyNewsStoryIE(SkyBaseIE): |
85 | IE_NAME = 'sky:news:story' | |
86 | _VALID_URL = r'https?://news\.sky\.com/story/[0-9a-z-]+-(?P<id>[0-9]+)' | |
87 | _TEST = { | |
88 | 'url': 'https://news.sky.com/story/budget-2021-chancellor-rishi-sunak-vows-address-will-deliver-strong-economy-fit-for-a-new-age-of-optimism-12445425', | |
89 | 'info_dict': { | |
90 | 'id': 'ref:0714acb9-123d-42c8-91b8-5c1bc6c73f20', | |
91 | 'title': 'md5:e408dd7aad63f31a1817bbe40c7d276f', | |
92 | 'description': 'md5:a881e12f49212f92be2befe4a09d288a', | |
93 | 'ext': 'mp4', | |
94 | 'upload_date': '20211027', | |
95 | 'timestamp': 1635317494, | |
96 | 'uploader_id': '6058004172001', | |
add96eb9 | 97 | }, |
b7b186e7 | 98 | } |
99 | ||
100 | def _real_extract(self, url): | |
101 | article_id = self._match_id(url) | |
102 | webpage = self._download_webpage(url, article_id) | |
103 | ||
9751a457 | 104 | entries = [self._process_video_element(webpage, sdc_el, url) |
b7b186e7 | 105 | for sdc_el in re.findall(self._SDC_EL_REGEX, webpage)] |
106 | ||
107 | return self.playlist_result( | |
108 | entries, article_id, self._og_search_title(webpage), | |
109 | self._html_search_meta(['og:description', 'description'], webpage)) | |
110 | ||
111 | ||
29f7c58a | 112 | class SkySportsNewsIE(SkyBaseIE): |
113 | IE_NAME = 'sky:sports:news' | |
114 | _VALID_URL = r'https?://(?:www\.)?skysports\.com/([^/]+/)*news/\d+/(?P<id>\d+)' | |
115 | _TEST = { | |
116 | 'url': 'http://www.skysports.com/golf/news/12176/10871916/dustin-johnson-ready-to-conquer-players-championship-at-tpc-sawgrass', | |
117 | 'info_dict': { | |
118 | 'id': '10871916', | |
119 | 'title': 'Dustin Johnson ready to conquer Players Championship at TPC Sawgrass', | |
120 | 'description': 'Dustin Johnson is confident he can continue his dominant form in 2017 by adding the Players Championship to his list of victories.', | |
121 | }, | |
122 | 'playlist_count': 2, | |
71ebd35d | 123 | } |
29f7c58a | 124 | |
125 | def _real_extract(self, url): | |
126 | article_id = self._match_id(url) | |
127 | webpage = self._download_webpage(url, article_id) | |
128 | ||
129 | entries = [] | |
130 | for sdc_el in re.findall(self._SDC_EL_REGEX, webpage): | |
9751a457 | 131 | entries.append(self._process_video_element(webpage, sdc_el, url)) |
29f7c58a | 132 | |
133 | return self.playlist_result( | |
134 | entries, article_id, self._og_search_title(webpage), | |
135 | self._html_search_meta(['og:description', 'description'], webpage)) |