]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/rte.py
Merge pull request #8061 from dstftw/introduce-chapter-and-series-fields
[yt-dlp.git] / youtube_dl / extractor / rte.py
CommitLineData
25fadd06 1# coding: utf-8
2from __future__ import unicode_literals
3
4from .common import InfoExtractor
5
6from ..utils import (
7 float_or_none,
8)
9
10
11class RteIE(InfoExtractor):
6df7179e 12 _VALID_URL = r'https?://(?:www\.)?rte\.ie/player/[^/]{2,3}/show/[^/]+/(?P<id>[0-9]+)'
25fadd06 13 _TEST = {
36eb802b 14 'url': 'http://www.rte.ie/player/ie/show/iwitness-862/10478715/',
25fadd06 15 'info_dict': {
36eb802b 16 'id': '10478715',
25fadd06 17 'ext': 'mp4',
36eb802b 18 'title': 'Watch iWitness online',
25fadd06 19 'thumbnail': 're:^https?://.*\.jpg$',
36eb802b
JMF
20 'description': 'iWitness : The spirit of Ireland, one voice and one minute at a time.',
21 'duration': 60.046,
ea1d5bdc
PH
22 },
23 'params': {
24 'skip_download': 'f4m fails with --test atm'
25fadd06 25 }
26 }
3462af03 27
25fadd06 28 def _real_extract(self, url):
29 video_id = self._match_id(url)
25fadd06 30 webpage = self._download_webpage(url, video_id)
ea1d5bdc 31
25fadd06 32 title = self._og_search_title(webpage)
ea1d5bdc
PH
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
25fadd06 41 feeds_url = self._html_search_meta("feeds-prefix", webpage, 'feeds url') + video_id
42 json_string = self._download_json(feeds_url, video_id)
ea1d5bdc 43
25fadd06 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)
0551a02b 47 f4m_formats = [{
48 'format_id': f['format_id'],
49 'url': f['url'],
50 'ext': 'mp4',
51 'width': f['width'],
52 'height': f['height'],
ea1d5bdc
PH
53 } for f in f4m_formats]
54
25fadd06 55 return {
56 'id': video_id,
57 'title': title,
58 'formats': f4m_formats,
59 'description': description,
60 'thumbnail': thumbnail,
61 'duration': duration,
ea1d5bdc 62 }