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