2 from __future__ import unicode_literals
6 from .common import InfoExtractor
15 class TVPlayIE(InfoExtractor):
16 IE_DESC = 'TV3Play and related services'
17 _VALID_URL = r'''(?x)http://(?:www\.)?
18 (?:tvplay\.lv/parraides|
19 tv3play\.lt/programos|
25 tv3play\.no/programmer|
26 viasat4play\.no/programmer|
27 tv6play\.no/programmer|
28 tv3play\.dk/programmer|
33 'url': 'http://www.tvplay.lv/parraides/vinas-melo-labak/418113?autostart=true',
37 'title': 'Kādi ir īri? - Viņas melo labāk',
38 'description': 'Baiba apsmej īrus, kādi tie ir un ko viņi dara.',
40 'timestamp': 1406097056,
41 'upload_date': '20140723',
45 'skip_download': True,
49 'url': 'http://www.tv3play.lt/programos/moterys-meluoja-geriau/409229?autostart=true',
53 'title': 'Moterys meluoja geriau',
54 'description': 'md5:9aec0fc68e2cbc992d2a140bd41fa89e',
56 'timestamp': 1403769181,
57 'upload_date': '20140626',
61 'skip_download': True,
65 'url': 'http://www.tv3play.ee/sisu/kodu-keset-linna/238551?autostart=true',
69 'title': 'Kodu keset linna 398537',
70 'description': 'md5:7df175e3c94db9e47c0d81ffa5d68701',
72 'timestamp': 1292449761,
73 'upload_date': '20101215',
77 'skip_download': True,
81 'url': 'http://www.tv3play.se/program/husraddarna/395385?autostart=true',
85 'title': 'Husräddarna S02E07',
86 'description': 'md5:f210c6c89f42d4fc39faa551be813777',
88 'timestamp': 1400596321,
89 'upload_date': '20140520',
93 'skip_download': True,
97 'url': 'http://www.tv6play.se/program/den-sista-dokusapan/266636?autostart=true',
101 'title': 'Den sista dokusåpan S01E08',
102 'description': 'md5:295be39c872520221b933830f660b110',
104 'timestamp': 1330522854,
105 'upload_date': '20120229',
109 'skip_download': True,
113 'url': 'http://www.tv8play.se/program/antikjakten/282756?autostart=true',
117 'title': 'Antikjakten S01E10',
118 'description': 'md5:1b201169beabd97e20c5ad0ad67b13b8',
120 'timestamp': 1348575868,
121 'upload_date': '20120925',
125 'skip_download': True,
129 'url': 'http://www.tv3play.no/programmer/anna-anka-soker-assistent/230898?autostart=true',
133 'title': 'Anna Anka søker assistent - Ep. 8',
134 'description': 'md5:f80916bf5bbe1c5f760d127f8dd71474',
136 'timestamp': 1277720005,
137 'upload_date': '20100628',
141 'skip_download': True,
145 'url': 'http://www.viasat4play.no/programmer/budbringerne/21873?autostart=true',
149 'title': 'Budbringerne program 10',
150 'description': 'md5:4db78dc4ec8a85bb04fd322a3ee5092d',
152 'timestamp': 1254205102,
153 'upload_date': '20090929',
157 'skip_download': True,
161 'url': 'http://www.tv6play.no/programmer/hotelinspektor-alex-polizzi/361883?autostart=true',
165 'title': 'Hotelinspektør Alex Polizzi - Ep. 10',
166 'description': 'md5:3ecf808db9ec96c862c8ecb3a7fdaf81',
168 'timestamp': 1393236292,
169 'upload_date': '20140224',
173 'skip_download': True,
178 def _real_extract(self, url):
179 mobj = re.match(self._VALID_URL, url)
180 video_id = mobj.group('id')
182 video = self._download_json(
183 'http://playapi.mtgx.tv/v1/videos/%s' % video_id, video_id, 'Downloading video JSON')
185 if video['is_geo_blocked']:
186 raise ExtractorError(
187 'This content is not available in your country due to copyright reasons', expected=True)
189 streams = self._download_json(
190 'http://playapi.mtgx.tv/v1/videos/stream/%s' % video_id, video_id, 'Downloading streams JSON')
192 quality = qualities(['hls', 'medium', 'high'])
194 for format_id, video_url in streams['streams'].items():
195 if not video_url or not isinstance(video_url, compat_str):
198 'format_id': format_id,
199 'preference': quality(format_id),
201 if video_url.startswith('rtmp'):
202 m = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', video_url)
207 'url': m.group('url'),
208 'app': m.group('app'),
209 'play_path': m.group('playpath'),
217 self._sort_formats(formats)
221 'title': video['title'],
222 'description': video['description'],
223 'duration': video['duration'],
224 'timestamp': parse_iso8601(video['created_at']),
225 'view_count': video['views']['total'],
226 'age_limit': video.get('age_limit', 0),