]>
Commit | Line | Data |
---|---|---|
59040888 PH |
1 | # coding: utf-8 |
2 | import re | |
3 | import xml.etree.ElementTree | |
4 | ||
5 | from .common import InfoExtractor | |
6 | from ..utils import ( | |
7 | ExtractorError, | |
8 | unified_strdate, | |
9 | ) | |
10 | ||
11 | ||
12 | class TouTvIE(InfoExtractor): | |
13 | IE_NAME = u'tou.tv' | |
14 | _VALID_URL = r'https?://www\.tou\.tv/(?P<id>[a-zA-Z0-9_-]+(?:/(?P<episode>S[0-9]+E[0-9]+)))' | |
15 | ||
16 | _TEST = { | |
17 | u'url': u'http://www.tou.tv/30-vies/S04E41', | |
18 | u'file': u'30-vies_S04E41.mp4', | |
19 | u'info_dict': { | |
20 | u'title': u'30 vies Saison 4 / Épisode 41', | |
21 | u'description': u'md5:da363002db82ccbe4dafeb9cab039b09', | |
22 | u'age_limit': 8, | |
23 | u'uploader': u'Groupe des Nouveaux Médias', | |
24 | u'duration': 1296, | |
25 | u'upload_date': u'20131118', | |
26 | u'thumbnail': u'http://static.tou.tv/medias/images/2013-11-18_19_00_00_30VIES_0341_01_L.jpeg', | |
27 | }, | |
28 | u'params': { | |
29 | u'skip_download': True, # Requires rtmpdump | |
30 | }, | |
9a98a466 | 31 | u'skip': 'Only available in Canada' |
59040888 PH |
32 | } |
33 | ||
34 | def _real_extract(self, url): | |
35 | mobj = re.match(self._VALID_URL, url) | |
36 | video_id = mobj.group('id') | |
37 | webpage = self._download_webpage(url, video_id) | |
38 | ||
39 | mediaId = self._search_regex( | |
40 | r'"idMedia":\s*"([^"]+)"', webpage, u'media ID') | |
41 | ||
59040888 PH |
42 | streams_url = u'http://release.theplatform.com/content.select?pid=' + mediaId |
43 | streams_webpage = self._download_webpage( | |
44 | streams_url, video_id, note=u'Downloading stream list') | |
45 | ||
46 | streams_doc = xml.etree.ElementTree.fromstring( | |
47 | streams_webpage.encode('utf-8')) | |
48 | video_url = next(n.text | |
49 | for n in streams_doc.findall('.//choice/url') | |
50 | if u'//ad.doubleclick' not in n.text) | |
51 | if video_url.endswith('/Unavailable.flv'): | |
52 | raise ExtractorError( | |
53 | u'Access to this video is blocked from outside of Canada', | |
54 | expected=True) | |
55 | ||
56 | duration_str = self._html_search_meta( | |
57 | 'video:duration', webpage, u'duration') | |
58 | duration = int(duration_str) if duration_str else None | |
59 | upload_date_str = self._html_search_meta( | |
60 | 'video:release_date', webpage, u'upload date') | |
61 | upload_date = unified_strdate(upload_date_str) if upload_date_str else None | |
62 | ||
63 | return { | |
64 | 'id': video_id, | |
65 | 'title': self._og_search_title(webpage), | |
66 | 'url': video_url, | |
67 | 'description': self._og_search_description(webpage), | |
68 | 'uploader': self._dc_search_uploader(webpage), | |
69 | 'thumbnail': self._og_search_thumbnail(webpage), | |
70 | 'age_limit': self._media_rating_search(webpage), | |
71 | 'duration': duration, | |
72 | 'upload_date': upload_date, | |
73 | 'ext': 'mp4', | |
74 | } |