]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/drtv.py
1 from __future__
import unicode_literals
3 from .subtitles
import SubtitlesInfoExtractor
4 from .common
import ExtractorError
5 from ..utils
import parse_iso8601
8 class DRTVIE(SubtitlesInfoExtractor
):
9 _VALID_URL
= r
'http://(?:www\.)?dr\.dk/tv/se/(?:[^/]+/)+(?P<id>[\da-z-]+)(?:[/#?]|$)'
12 'url': 'http://www.dr.dk/tv/se/partiets-mand/partiets-mand-7-8',
13 'md5': '4a7e1dd65cdb2643500a3f753c942f25',
15 'id': 'partiets-mand-7-8',
17 'title': 'Partiets mand (7:8)',
18 'description': 'md5:a684b90a8f9336cd4aab94b7647d7862',
19 'timestamp': 1403047940,
20 'upload_date': '20140617',
25 def _real_extract(self
, url
):
26 video_id
= self
._match
_id
(url
)
28 programcard
= self
._download
_json
(
29 'http://www.dr.dk/mu/programcard/expanded/%s' % video_id
, video_id
, 'Downloading video JSON')
31 data
= programcard
['Data'][0]
34 description
= data
['Description']
35 timestamp
= parse_iso8601(data
['CreatedTime'])
40 restricted_to_denmark
= False
45 for asset
in data
['Assets']:
46 if asset
['Kind'] == 'Image':
47 thumbnail
= asset
['Uri']
48 elif asset
['Kind'] == 'VideoResource':
49 duration
= asset
['DurationInMilliseconds'] / 1000.0
50 restricted_to_denmark
= asset
['RestrictedToDenmark']
51 for link
in asset
['Links']:
52 target
= link
['Target']
55 'url': uri
+ '?hdcore=3.3.0&plugin=aasp-3.3.0.99.43' if target
== 'HDS' else uri
,
57 'ext': link
['FileFormat'],
58 'preference': -1 if target
== 'HDS' else -2,
60 subtitles_list
= asset
.get('SubtitlesList')
61 if isinstance(subtitles_list
, list):
65 for subs
in subtitles_list
:
66 lang
= subs
['Language']
67 subtitles
[LANGS
.get(lang
, lang
)] = subs
['Uri']
69 if not formats
and restricted_to_denmark
:
71 'Unfortunately, DR is not allowed to show this program outside Denmark.', expected
=True)
73 self
._sort
_formats
(formats
)
75 if self
._downloader
.params
.get('listsubtitles', False):
76 self
._list
_available
_subtitles
(video_id
, subtitles
)
82 'description': description
,
83 'thumbnail': thumbnail
,
84 'timestamp': timestamp
,
87 'subtitles': self
.extract_subtitles(video_id
, subtitles
),