]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/telequebec.py
fafaa826fe91e2eaddc2fe9b700c7e0367797807
[youtubedl] / youtube_dl / extractor / telequebec.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import compat_str
6 from ..utils import (
7 int_or_none,
8 smuggle_url,
9 try_get,
10 )
11
12
13 class TeleQuebecIE(InfoExtractor):
14 _VALID_URL = r'https?://zonevideo\.telequebec\.tv/media/(?P<id>\d+)'
15 _TESTS = [{
16 'url': 'http://zonevideo.telequebec.tv/media/20984/le-couronnement-de-new-york/couronnement-de-new-york',
17 'md5': 'fe95a0957e5707b1b01f5013e725c90f',
18 'info_dict': {
19 'id': '20984',
20 'ext': 'mp4',
21 'title': 'Le couronnement de New York',
22 'description': 'md5:f5b3d27a689ec6c1486132b2d687d432',
23 'upload_date': '20170201',
24 'timestamp': 1485972222,
25 }
26 }, {
27 # no description
28 'url': 'http://zonevideo.telequebec.tv/media/30261',
29 'only_matching': True,
30 }]
31
32 def _real_extract(self, url):
33 media_id = self._match_id(url)
34 media_data = self._download_json(
35 'https://mnmedias.api.telequebec.tv/api/v2/media/' + media_id,
36 media_id)['media']
37 return {
38 '_type': 'url_transparent',
39 'id': media_id,
40 'url': smuggle_url(
41 'limelight:media:' + media_data['streamInfo']['sourceId'],
42 {'geo_countries': ['CA']}),
43 'title': media_data['title'],
44 'description': try_get(
45 media_data, lambda x: x['descriptions'][0]['text'], compat_str),
46 'duration': int_or_none(
47 media_data.get('durationInMilliseconds'), 1000),
48 'ie_key': 'LimelightMedia',
49 }