]>
Raphaƫl G. Git Repositories - youtubedl/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
'https?://(?: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 webpage
= self
._download
_webpage
(url
, video_id
)
30 video_id
= self
._search
_regex
(
31 r
'data-(?:material-identifier|episode-slug)="([^"]+)"',
34 programcard
= self
._download
_json
(
35 'http://www.dr.dk/mu/programcard/expanded/%s' % video_id
,
36 video_id
, 'Downloading video JSON')
37 data
= programcard
['Data'][0]
40 description
= data
['Description']
41 timestamp
= parse_iso8601(data
['CreatedTime'])
46 restricted_to_denmark
= False
51 for asset
in data
['Assets']:
52 if asset
['Kind'] == 'Image':
53 thumbnail
= asset
['Uri']
54 elif asset
['Kind'] == 'VideoResource':
55 duration
= asset
['DurationInMilliseconds'] / 1000.0
56 restricted_to_denmark
= asset
['RestrictedToDenmark']
57 spoken_subtitles
= asset
['Target'] == 'SpokenSubtitles'
58 for link
in asset
['Links']:
59 target
= link
['Target']
62 preference
= -1 if target
== 'HDS' else -2
65 format_id
+= '-spoken-subtitles'
67 'url': uri
+ '?hdcore=3.3.0&plugin=aasp-3.3.0.99.43' if target
== 'HDS' else uri
,
68 'format_id': format_id
,
69 'ext': link
['FileFormat'],
70 'preference': preference
,
72 subtitles_list
= asset
.get('SubtitlesList')
73 if isinstance(subtitles_list
, list):
77 for subs
in subtitles_list
:
78 lang
= subs
['Language']
79 subtitles
[LANGS
.get(lang
, lang
)] = subs
['Uri']
81 if not formats
and restricted_to_denmark
:
83 'Unfortunately, DR is not allowed to show this program outside Denmark.', expected
=True)
85 self
._sort
_formats
(formats
)
87 if self
._downloader
.params
.get('listsubtitles', False):
88 self
._list
_available
_subtitles
(video_id
, subtitles
)
94 'description': description
,
95 'thumbnail': thumbnail
,
96 'timestamp': timestamp
,
99 'subtitles': self
.extract_subtitles(video_id
, subtitles
),