]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | parse_duration, | |
4 | parse_iso8601, | |
5 | js_to_json, | |
6 | ) | |
7 | from ..compat import compat_str | |
8 | ||
9 | ||
10 | class RDSIE(InfoExtractor): | |
11 | IE_DESC = 'RDS.ca' | |
12 | _VALID_URL = r'https?://(?:www\.)?rds\.ca/vid(?:[eé]|%C3%A9)os/(?:[^/]+/)*(?P<id>[^/]+)-\d+\.\d+' | |
13 | ||
14 | _TESTS = [{ | |
15 | # has two 9c9media ContentPackages, the web player selects the first ContentPackage | |
16 | 'url': 'https://www.rds.ca/videos/Hockey/NationalHockeyLeague/teams/9/forum-du-5-a-7-jesperi-kotkaniemi-de-retour-de-finlande-3.1377606', | |
17 | 'info_dict': { | |
18 | 'id': '2083309', | |
19 | 'display_id': 'forum-du-5-a-7-jesperi-kotkaniemi-de-retour-de-finlande', | |
20 | 'ext': 'flv', | |
21 | 'title': 'Forum du 5 à 7 : Kotkaniemi de retour de Finlande', | |
22 | 'description': 'md5:83fa38ecc4a79b19e433433254077f25', | |
23 | 'timestamp': 1606129030, | |
24 | 'upload_date': '20201123', | |
25 | 'duration': 773.039, | |
26 | } | |
27 | }, { | |
28 | 'url': 'http://www.rds.ca/vid%C3%A9os/un-voyage-positif-3.877934', | |
29 | 'only_matching': True, | |
30 | }] | |
31 | ||
32 | def _real_extract(self, url): | |
33 | display_id = self._match_id(url) | |
34 | ||
35 | webpage = self._download_webpage(url, display_id) | |
36 | ||
37 | item = self._parse_json(self._search_regex(r'(?s)itemToPush\s*=\s*({.+?});', webpage, 'item'), display_id, js_to_json) | |
38 | video_id = compat_str(item['id']) | |
39 | title = item.get('title') or self._og_search_title(webpage) or self._html_search_meta( | |
40 | 'title', webpage, 'title', fatal=True) | |
41 | description = self._og_search_description(webpage) or self._html_search_meta( | |
42 | 'description', webpage, 'description') | |
43 | thumbnail = item.get('urlImageBig') or self._og_search_thumbnail(webpage) or self._search_regex( | |
44 | [r'<link[^>]+itemprop="thumbnailUrl"[^>]+href="([^"]+)"', | |
45 | r'<span[^>]+itemprop="thumbnailUrl"[^>]+content="([^"]+)"'], | |
46 | webpage, 'thumbnail', fatal=False) | |
47 | timestamp = parse_iso8601(self._search_regex( | |
48 | r'<span[^>]+itemprop="uploadDate"[^>]+content="([^"]+)"', | |
49 | webpage, 'upload date', fatal=False)) | |
50 | duration = parse_duration(self._search_regex( | |
51 | r'<span[^>]+itemprop="duration"[^>]+content="([^"]+)"', | |
52 | webpage, 'duration', fatal=False)) | |
53 | age_limit = self._family_friendly_search(webpage) | |
54 | ||
55 | return { | |
56 | '_type': 'url_transparent', | |
57 | 'id': video_id, | |
58 | 'display_id': display_id, | |
59 | 'url': '9c9media:rds_web:%s' % video_id, | |
60 | 'title': title, | |
61 | 'description': description, | |
62 | 'thumbnail': thumbnail, | |
63 | 'timestamp': timestamp, | |
64 | 'duration': duration, | |
65 | 'age_limit': age_limit, | |
66 | 'ie_key': 'NineCNineMedia', | |
67 | } |