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