Merge remote-tracking branch 'JGjorgji/fix-leading-zeroes'
[youtube-dl] / 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         'info_dict': {
16             'id': '6e4203a6-0a5e-3596-8424-c599a59e0677',
17             'ext': 'flv',
18             'title': 'RTL Nieuws - Laat',
19             'description': 'Dagelijks het laatste nieuws uit binnen- en '
20                 'buitenland. Voor nog meer nieuws kunt u ook gebruikmaken van '
21                 'onze mobiele apps.',
22             'timestamp': 1408051800,
23             'upload_date': '20140814',
24             'duration': 576.880,
25         },
26         'params': {
27             # We download the first bytes of the first fragment, it can't be
28             # processed by the f4m downloader beacuse it isn't complete
29             'skip_download': True,
30         },
31     }
32
33     def _real_extract(self, url):
34         mobj = re.match(self._VALID_URL, url)
35         uuid = mobj.group('uuid')
36
37         info = self._download_json(
38             'http://www.rtl.nl/system/s4m/vfd/version=2/uuid=%s/fmt=flash/' % uuid,
39             uuid)
40
41         material = info['material'][0]
42         episode_info = info['episodes'][0]
43
44         f4m_url = 'http://manifest.us.rtl.nl' + material['videopath']
45         progname = info['abstracts'][0]['name']
46         subtitle = material['title'] or info['episodes'][0]['name']
47
48         return {
49             'id': uuid,
50             'title': '%s - %s' % (progname, subtitle),
51             'formats': self._extract_f4m_formats(f4m_url, uuid),
52             'timestamp': material['original_date'],
53             'description': episode_info['synopsis'],
54             'duration': parse_duration(material.get('duration')),
55         }