]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/drtv.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
11 class DRTVIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://(?:www\.)?dr\.dk/tv/se/(?:[^/]+/)*(?P<id>[\da-z-]+)(?:[/#?]|$)'
15 'url': 'https://www.dr.dk/tv/se/boern/ultra/panisk-paske/panisk-paske-5',
16 'md5': 'dc515a9ab50577fa14cc4e4b0265168f',
18 'id': 'panisk-paske-5',
20 'title': 'Panisk Påske (5)',
21 'description': 'md5:ca14173c5ab24cd26b0fcc074dff391c',
22 'timestamp': 1426984612,
23 'upload_date': '20150322',
28 def _real_extract(self
, url
):
29 video_id
= self
._match
_id
(url
)
31 webpage
= self
._download
_webpage
(url
, video_id
)
33 if '>Programmet er ikke længere tilgængeligt' in webpage
:
35 'Video %s is not available' % video_id
, expected
=True)
37 video_id
= self
._search
_regex
(
38 r
'data-(?:material-identifier|episode-slug)="([^"]+)"',
41 programcard
= self
._download
_json
(
42 'http://www.dr.dk/mu/programcard/expanded/%s' % video_id
,
43 video_id
, 'Downloading video JSON')
44 data
= programcard
['Data'][0]
47 description
= data
['Description']
48 timestamp
= parse_iso8601(data
['CreatedTime'])
53 restricted_to_denmark
= False
58 for asset
in data
['Assets']:
59 if asset
['Kind'] == 'Image':
60 thumbnail
= asset
['Uri']
61 elif asset
['Kind'] == 'VideoResource':
62 duration
= asset
['DurationInMilliseconds'] / 1000.0
63 restricted_to_denmark
= asset
['RestrictedToDenmark']
64 spoken_subtitles
= asset
['Target'] == 'SpokenSubtitles'
65 for link
in asset
['Links']:
67 target
= link
['Target']
72 format_id
+= '-spoken-subtitles'
74 formats
.extend(self
._extract
_f
4m
_formats
(
75 uri
+ '?hdcore=3.3.0&plugin=aasp-3.3.0.99.43',
76 video_id
, preference
, f4m_id
=format_id
))
78 formats
.extend(self
._extract
_m
3u8_formats
(
79 uri
, video_id
, 'mp4', preference
=preference
,
82 bitrate
= link
.get('Bitrate')
84 format_id
+= '-%s' % bitrate
87 'format_id': format_id
,
89 'ext': link
.get('FileFormat'),
91 subtitles_list
= asset
.get('SubtitlesList')
92 if isinstance(subtitles_list
, list):
96 for subs
in subtitles_list
:
97 lang
= subs
['Language']
98 subtitles
[LANGS
.get(lang
, lang
)] = [{'url': subs
['Uri'], 'ext': 'vtt'}]
100 if not formats
and restricted_to_denmark
:
101 raise ExtractorError(
102 'Unfortunately, DR is not allowed to show this program outside Denmark.', expected
=True)
104 self
._sort
_formats
(formats
)
109 'description': description
,
110 'thumbnail': thumbnail
,
111 'timestamp': timestamp
,
112 'duration': duration
,
114 'subtitles': subtitles
,