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