]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/rtlnl.py
Prepare for upload.
[youtubedl] / youtube_dl / extractor / rtlnl.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import parse_duration
7
8
9 class RtlXlIE(InfoExtractor):
10 IE_NAME = 'rtlxl.nl'
11 _VALID_URL = r'https?://www\.rtlxl\.nl/#!/[^/]+/(?P<uuid>[^/?]+)'
12
13 _TEST = {
14 'url': 'http://www.rtlxl.nl/#!/rtl-nieuws-132237/6e4203a6-0a5e-3596-8424-c599a59e0677',
15 'md5': 'cc16baa36a6c169391f0764fa6b16654',
16 'info_dict': {
17 'id': '6e4203a6-0a5e-3596-8424-c599a59e0677',
18 'ext': 'mp4',
19 'title': 'RTL Nieuws - Laat',
20 'description': 'md5:6b61f66510c8889923b11f2778c72dc5',
21 'timestamp': 1408051800,
22 'upload_date': '20140814',
23 'duration': 576.880,
24 },
25 }
26
27 def _real_extract(self, url):
28 mobj = re.match(self._VALID_URL, url)
29 uuid = mobj.group('uuid')
30
31 info = self._download_json(
32 'http://www.rtl.nl/system/s4m/vfd/version=2/uuid=%s/fmt=flash/' % uuid,
33 uuid)
34
35 material = info['material'][0]
36 episode_info = info['episodes'][0]
37
38 progname = info['abstracts'][0]['name']
39 subtitle = material['title'] or info['episodes'][0]['name']
40
41 videopath = material['videopath']
42 f4m_url = 'http://manifest.us.rtl.nl' + videopath
43
44 formats = self._extract_f4m_formats(f4m_url, uuid)
45
46 video_urlpart = videopath.split('/flash/')[1][:-4]
47 PG_URL_TEMPLATE = 'http://pg.us.rtl.nl/rtlxl/network/%s/progressive/%s.mp4'
48
49 formats.extend([
50 {
51 'url': PG_URL_TEMPLATE % ('a2m', video_urlpart),
52 'format_id': 'pg-sd',
53 },
54 {
55 'url': PG_URL_TEMPLATE % ('a3m', video_urlpart),
56 'format_id': 'pg-hd',
57 }
58 ])
59
60 return {
61 'id': uuid,
62 'title': '%s - %s' % (progname, subtitle),
63 'formats': formats,
64 'timestamp': material['original_date'],
65 'description': episode_info['synopsis'],
66 'duration': parse_duration(material.get('duration')),
67 }