]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/rds.py
Update changelog.
[youtubedl] / youtube_dl / extractor / rds.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import (
8 parse_duration,
9 parse_iso8601,
10 )
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<display_id>[^/]+)-(?P<id>\d+\.\d+)'
16
17 _TESTS = [{
18 'url': 'http://www.rds.ca/videos/football/nfl/fowler-jr-prend-la-direction-de-jacksonville-3.1132799',
19 'info_dict': {
20 'id': '3.1132799',
21 'display_id': 'fowler-jr-prend-la-direction-de-jacksonville',
22 'ext': 'mp4',
23 'title': 'Fowler Jr. prend la direction de Jacksonville',
24 'description': 'Dante Fowler Jr. est le troisième choix du repêchage 2015 de la NFL. ',
25 'timestamp': 1430397346,
26 'upload_date': '20150430',
27 'duration': 154.354,
28 'age_limit': 0,
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 mobj = re.match(self._VALID_URL, url)
37 video_id = mobj.group('id')
38 display_id = mobj.group('display_id')
39
40 webpage = self._download_webpage(url, display_id)
41
42 # TODO: extract f4m from 9c9media.com
43 video_url = self._search_regex(
44 r'<span[^>]+itemprop="contentURL"[^>]+content="([^"]+)"',
45 webpage, 'video url')
46
47 title = self._og_search_title(webpage) or self._html_search_meta(
48 'title', webpage, 'title', fatal=True)
49 description = self._og_search_description(webpage) or self._html_search_meta(
50 'description', webpage, 'description')
51 thumbnail = self._og_search_thumbnail(webpage) or self._search_regex(
52 [r'<link[^>]+itemprop="thumbnailUrl"[^>]+href="([^"]+)"',
53 r'<span[^>]+itemprop="thumbnailUrl"[^>]+content="([^"]+)"'],
54 webpage, 'thumbnail', fatal=False)
55 timestamp = parse_iso8601(self._search_regex(
56 r'<span[^>]+itemprop="uploadDate"[^>]+content="([^"]+)"',
57 webpage, 'upload date', fatal=False))
58 duration = parse_duration(self._search_regex(
59 r'<span[^>]+itemprop="duration"[^>]+content="([^"]+)"',
60 webpage, 'duration', fatal=False))
61 age_limit = self._family_friendly_search(webpage)
62
63 return {
64 'id': video_id,
65 'display_id': display_id,
66 'url': video_url,
67 'title': title,
68 'description': description,
69 'thumbnail': thumbnail,
70 'timestamp': timestamp,
71 'duration': duration,
72 'age_limit': age_limit,
73 }