]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/drtv.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
15 class DRTVIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?dr\.dk/(?:tv/se|nyheder)/(?:[^/]+/)*(?P<id>[\da-z-]+)(?:[/#?]|$)'
19 'url': 'https://www.dr.dk/tv/se/boern/ultra/klassen-ultra/klassen-darlig-taber-10',
20 'md5': '25e659cccc9a2ed956110a299fdf5983',
22 'id': 'klassen-darlig-taber-10',
24 'title': 'Klassen - Dårlig taber (10)',
25 'description': 'md5:815fe1b7fa656ed80580f31e8b3c79aa',
26 'timestamp': 1471991907,
27 'upload_date': '20160823',
31 'skip_download': True,
34 'url': 'https://www.dr.dk/nyheder/indland/live-christianias-rydning-af-pusher-street-er-i-gang',
35 'md5': '2c37175c718155930f939ef59952474a',
37 'id': 'christiania-pusher-street-ryddes-drdkrjpo',
39 'title': 'LIVE Christianias rydning af Pusher Street er i gang',
40 'description': '- Det er det fedeste, der er sket i 20 år, fortæller christianit til DR Nyheder.',
41 'timestamp': 1472800279,
42 'upload_date': '20160902',
47 def _real_extract(self
, url
):
48 video_id
= self
._match
_id
(url
)
50 webpage
= self
._download
_webpage
(url
, video_id
)
52 if '>Programmet er ikke længere tilgængeligt' in webpage
:
54 'Video %s is not available' % video_id
, expected
=True)
56 video_id
= self
._search
_regex
(
57 (r
'data-(?:material-identifier|episode-slug)="([^"]+)"',
58 r
'data-resource="[^>"]+mu/programcard/expanded/([^"]+)"'),
61 programcard
= self
._download
_json
(
62 'http://www.dr.dk/mu/programcard/expanded/%s' % video_id
,
63 video_id
, 'Downloading video JSON')
64 data
= programcard
['Data'][0]
66 title
= remove_end(self
._og
_search
_title
(
67 webpage
, default
=None), ' | TV | DR') or data
['Title']
68 description
= self
._og
_search
_description
(
69 webpage
, default
=None) or data
.get('Description')
71 timestamp
= parse_iso8601(data
.get('CreatedTime'))
76 restricted_to_denmark
= False
81 for asset
in data
['Assets']:
82 if asset
.get('Kind') == 'Image':
83 thumbnail
= asset
.get('Uri')
84 elif asset
.get('Kind') == 'VideoResource':
85 duration
= float_or_none(asset
.get('DurationInMilliseconds'), 1000)
86 restricted_to_denmark
= asset
.get('RestrictedToDenmark')
87 spoken_subtitles
= asset
.get('Target') == 'SpokenSubtitles'
88 for link
in asset
.get('Links', []):
92 target
= link
.get('Target')
93 format_id
= target
or ''
97 format_id
+= '-spoken-subtitles'
99 formats
.extend(self
._extract
_f
4m
_formats
(
100 uri
+ '?hdcore=3.3.0&plugin=aasp-3.3.0.99.43',
101 video_id
, preference
, f4m_id
=format_id
))
102 elif target
== 'HLS':
103 formats
.extend(self
._extract
_m
3u8_formats
(
104 uri
, video_id
, 'mp4', entry_protocol
='m3u8_native',
105 preference
=preference
, m3u8_id
=format_id
))
107 bitrate
= link
.get('Bitrate')
109 format_id
+= '-%s' % bitrate
112 'format_id': format_id
,
113 'tbr': int_or_none(bitrate
),
114 'ext': link
.get('FileFormat'),
116 subtitles_list
= asset
.get('SubtitlesList')
117 if isinstance(subtitles_list
, list):
121 for subs
in subtitles_list
:
122 if not subs
.get('Uri'):
124 lang
= subs
.get('Language') or 'da'
125 subtitles
.setdefault(LANGS
.get(lang
, lang
), []).append({
127 'ext': mimetype2ext(subs
.get('MimeType')) or 'vtt'
130 if not formats
and restricted_to_denmark
:
131 self
.raise_geo_restricted(
132 'Unfortunately, DR is not allowed to show this program outside Denmark.',
135 self
._sort
_formats
(formats
)
140 'description': description
,
141 'thumbnail': thumbnail
,
142 'timestamp': timestamp
,
143 'duration': duration
,
145 'subtitles': subtitles
,