]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/medialaan.py
f8c30052f32486f511622656bdadbcf91f80717c
1 from __future__
import unicode_literals
5 from .gigya
import GigyaBaseIE
7 from ..compat
import compat_str
16 class MedialaanIE(GigyaBaseIE
):
21 (?P<site_id>vtm|q2|vtmkzoom)\.be/
23 video(?:/[^/]+/id/|/?\?.*?\baid=)|
29 _NETRC_MACHINE
= 'medialaan'
30 _APIKEY
= '3_HZ0FtkMW_gOyKlqQzW5_0FHRC7Nd5XpXJZcDdXY4pk5eES2ZWmejRW5egwVm4ug-'
34 'vtmkzoom': 'vtmkzoom',
38 'url': 'http://vtm.be/video/volledige-afleveringen/id/vtm_20170219_VM0678361_vtmwatch',
40 'id': 'vtm_20170219_VM0678361_vtmwatch',
42 'title': 'Allemaal Chris afl. 6',
43 'description': 'md5:4be86427521e7b07e0adb0c9c554ddb2',
44 'timestamp': 1487533280,
45 'upload_date': '20170219',
47 'series': 'Allemaal Chris',
48 'season': 'Allemaal Chris',
50 'season_id': '256936078124527',
51 'episode': 'Allemaal Chris afl. 6',
53 'episode_id': '256936078591527',
56 'skip_download': True,
58 'skip': 'Requires account credentials',
61 'url': 'http://vtm.be/video?aid=168332',
65 'title': '"Veronique liegt!"',
66 'description': 'md5:1385e2b743923afe54ba4adc38476155',
67 'timestamp': 1489002029,
68 'upload_date': '20170308',
73 'url': 'http://vtm.be/video/volledige-afleveringen/id/257107153551000',
74 'only_matching': True,
77 'url': 'http://vtm.be/video?aid=163157',
78 'only_matching': True,
81 'url': 'http://www.q2.be/video/volledige-afleveringen/id/2be_20170301_VM0684442_q2',
82 'only_matching': True,
85 'url': 'http://vtmkzoom.be/k3-dansstudio/een-nieuw-seizoen-van-k3-dansstudio',
86 'only_matching': True,
89 'url': 'https://vtmkzoom.be/video?aid=45724',
91 'id': '257136373657000',
93 'title': 'K3 Dansstudio Ushuaia afl.6',
96 'skip_download': True,
98 'skip': 'Requires account credentials',
101 'url': 'https://nieuws.vtm.be/stadion/stadion/genk-nog-moeilijk-programma',
102 'only_matching': True,
105 def _real_initialize(self
):
106 self
._logged
_in
= False
109 username
, password
= self
._get
_login
_info
()
111 self
.raise_login_required()
114 'APIKey': self
._APIKEY
,
118 'password': password
,
121 auth_info
= self
._gigya
_login
(auth_data
)
123 self
._uid
= auth_info
['UID']
124 self
._uid
_signature
= auth_info
['UIDSignature']
125 self
._signature
_timestamp
= auth_info
['signatureTimestamp']
127 self
._logged
_in
= True
129 def _real_extract(self
, url
):
130 mobj
= re
.match(self
._VALID
_URL
, url
)
131 video_id
, site_id
= mobj
.group('id', 'site_id')
133 webpage
= self
._download
_webpage
(url
, video_id
)
135 config
= self
._parse
_json
(
137 r
'videoJSConfig\s*=\s*JSON\.parse\(\'({.+?
})\'\
);',
138 webpage, 'config
', default='{}'), video_id,
139 transform_source=lambda s: s.replace(
140 '\\\\', '\\').replace(r'\"', '"').replace(r"\'", "'"))
142 vod_id = config.get('vodId
') or self._search_regex(
143 (r'\\"vodId\\"\s
*:\s
*\\"(.+?)\\"',
144 r'<[^
>]+id=["\']vod-(\d+)'),
145 webpage, 'video_id', default=None)
147 # clip, no authentication required
149 player = self._parse_json(
151 r'vmmaplayer\(({.+?})\);', webpage, 'vmma player',
153 video_id, transform_source=lambda s: '[%s]' % s, fatal=False)
156 if video['videoUrl'] in ('http', 'https'):
157 return self.url_result(video['url'], MedialaanIE.ie_key())
160 'url': video['videoUrl'],
161 'title': video['title'],
162 'thumbnail': video.get('imageUrl'),
163 'timestamp': int_or_none(video.get('createdDate')),
164 'duration': int_or_none(video.get('duration')),
167 info = self._parse_html5_media_entries(
168 url, webpage, video_id, m3u8_id='hls')[0]
171 'title': self._html_search_meta('description', webpage),
172 'duration': parse_duration(self._html_search_meta('duration', webpage)),
174 # vod, authentication required
176 if not self._logged_in:
179 settings = self._parse_json(
181 r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);',
182 webpage, 'drupal settings', default='{}'),
185 def get(container, item):
187 settings, lambda x: x[container][item],
188 compat_str) or self._search_regex(
189 r'"%s"\s*:\s*"([^
"]+)' % item, webpage, item,
192 app_id = get('vod', 'app_id') or self._SITE_TO_APP_ID.get(site_id, 'vtm_watch')
193 sso = get('vod', 'gigyaDatabase') or 'vtm-sso'
195 data = self._download_json(
196 'http://vod.medialaan.io/api/1.0/item/%s/video' % vod_id,
201 'UIDSignature': self._uid_signature,
202 'signatureTimestamp': self._signature_timestamp,
205 formats = self._extract_m3u8_formats(
206 data['response']['uri'], video_id, entry_protocol='m3u8_native',
207 ext='mp4', m3u8_id='hls')
209 self._sort_formats(formats)
216 api_key = get('vod', 'apiKey')
217 channel = get('medialaanGigya', 'channel')
220 videos = self._download_json(
221 'http://vod.medialaan.io/vod/v2/videos', video_id, fatal=False,
230 videos, lambda x: x['response']['videos'][0], dict)
232 def get(container, item, expected_type=None):
234 video, lambda x: x[container][item], expected_type)
236 def get_string(container, item):
237 return get(container, item, compat_str)
240 'series': get_string('program', 'title'),
241 'season': get_string('season', 'title'),
242 'season_number': int_or_none(get('season', 'number')),
243 'season_id': get_string('season', 'id'),
244 'episode': get_string('episode', 'title'),
245 'episode_number': int_or_none(get('episode', 'number')),
246 'episode_id': get_string('episode', 'id'),
247 'duration': int_or_none(
248 video.get('duration')) or int_or_none(
249 video.get('durationMillis'), scale=1000),
250 'title': get_string('episode', 'title'),
251 'description': get_string('episode', 'text'),
252 'timestamp': unified_timestamp(get_string(
253 'publication', 'begin')),
256 if not info.get('title'):
257 info['title'] = try_get(
258 config, lambda x: x['videoConfig']['title'],
259 compat_str) or self._html_search_regex(
260 r'\\"title
\\"\s*:\s*\\"(.+?
)\\"', webpage, 'title',
261 default=None) or self._og_search_title(webpage)
263 if not info.get('description'):
264 info['description'] = self._html_search_regex(
265 r'<div[^>]+class="field
-item\s
+even
">\s*<p>(.+?)</p>',
266 webpage, 'description', default=None)