]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/rte.py
04158b9931c09d9d028175dc895e90cf7da6a7f3
[youtubedl] / youtube_dl / extractor / rte.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6 from ..utils import (
7 float_or_none,
8 )
9
10
11 class RteIE(InfoExtractor):
12 _VALID_URL = r'http?://(?:www\.)?rte\.ie/player/[^/]{2,3}/show/(?P<id>[0-9]+)/'
13 _TEST = {
14 'url': 'http://www.rte.ie/player/de/show/10363114/',
15 'info_dict': {
16 'id': '10363114',
17 'ext': 'mp4',
18 'title': 'One News',
19 'thumbnail': 're:^https?://.*\.jpg$',
20 'description': 'The One O\'Clock News followed by Weather.',
21 'duration': 436.844,
22 },
23 'params': {
24 'skip_download': 'f4m fails with --test atm'
25 }
26 }
27
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
30 webpage = self._download_webpage(url, video_id)
31
32 title = self._og_search_title(webpage)
33 description = self._html_search_meta('description', webpage, 'description')
34 duration = float_or_none(self._html_search_meta(
35 'duration', webpage, 'duration', fatal=False), 1000)
36
37 thumbnail_id = self._search_regex(
38 r'<meta name="thumbnail" content="uri:irus:(.*?)" />', webpage, 'thumbnail')
39 thumbnail = 'http://img.rasset.ie/' + thumbnail_id + '.jpg'
40
41 feeds_url = self._html_search_meta("feeds-prefix", webpage, 'feeds url') + video_id
42 json_string = self._download_json(feeds_url, video_id)
43
44 # f4m_url = server + relative_url
45 f4m_url = json_string['shows'][0]['media:group'][0]['rte:server'] + json_string['shows'][0]['media:group'][0]['url']
46 f4m_formats = self._extract_f4m_formats(f4m_url, video_id)
47 f4m_formats = [{
48 'format_id': f['format_id'],
49 'url': f['url'],
50 'ext': 'mp4',
51 'width': f['width'],
52 'height': f['height'],
53 } for f in f4m_formats]
54
55 return {
56 'id': video_id,
57 'title': title,
58 'formats': f4m_formats,
59 'description': description,
60 'thumbnail': thumbnail,
61 'duration': duration,
62 }