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