]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/drtv.py
1 from __future__
import unicode_literals
3 from .common
import InfoExtractor
, ExtractorError
4 from ..utils
import parse_iso8601
7 class DRTVIE(InfoExtractor
):
8 _VALID_URL
= r
'https?://(?:www\.)?dr\.dk/tv/se/(?:[^/]+/)*(?P<id>[\da-z-]+)(?:[/#?]|$)'
11 'url': 'http://www.dr.dk/tv/se/partiets-mand/partiets-mand-7-8',
12 'md5': '4a7e1dd65cdb2643500a3f753c942f25',
14 'id': 'partiets-mand-7-8',
16 'title': 'Partiets mand (7:8)',
17 'description': 'md5:a684b90a8f9336cd4aab94b7647d7862',
18 'timestamp': 1403047940,
19 'upload_date': '20140617',
24 def _real_extract(self
, url
):
25 video_id
= self
._match
_id
(url
)
27 webpage
= self
._download
_webpage
(url
, video_id
)
29 video_id
= self
._search
_regex
(
30 r
'data-(?:material-identifier|episode-slug)="([^"]+)"',
33 programcard
= self
._download
_json
(
34 'http://www.dr.dk/mu/programcard/expanded/%s' % video_id
,
35 video_id
, 'Downloading video JSON')
36 data
= programcard
['Data'][0]
39 description
= data
['Description']
40 timestamp
= parse_iso8601(data
['CreatedTime'])
45 restricted_to_denmark
= False
50 for asset
in data
['Assets']:
51 if asset
['Kind'] == 'Image':
52 thumbnail
= asset
['Uri']
53 elif asset
['Kind'] == 'VideoResource':
54 duration
= asset
['DurationInMilliseconds'] / 1000.0
55 restricted_to_denmark
= asset
['RestrictedToDenmark']
56 spoken_subtitles
= asset
['Target'] == 'SpokenSubtitles'
57 for link
in asset
['Links']:
58 target
= link
['Target']
61 preference
= -1 if target
== 'HDS' else -2
64 format_id
+= '-spoken-subtitles'
66 'url': uri
+ '?hdcore=3.3.0&plugin=aasp-3.3.0.99.43' if target
== 'HDS' else uri
,
67 'format_id': format_id
,
68 'ext': link
['FileFormat'],
69 'preference': preference
,
71 subtitles_list
= asset
.get('SubtitlesList')
72 if isinstance(subtitles_list
, list):
76 for subs
in subtitles_list
:
77 lang
= subs
['Language']
78 subtitles
[LANGS
.get(lang
, lang
)] = [{'url': subs
['Uri'], 'ext': 'vtt'}]
80 if not formats
and restricted_to_denmark
:
82 'Unfortunately, DR is not allowed to show this program outside Denmark.', expected
=True)
84 self
._sort
_formats
(formats
)
89 'description': description
,
90 'thumbnail': thumbnail
,
91 'timestamp': timestamp
,
94 'subtitles': subtitles
,