]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/drtv.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
, ExtractorError
5 from ..utils
import parse_iso8601
8 class DRTVIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.)?dr\.dk/tv/se/(?:[^/]+/)*(?P<id>[\da-z-]+)(?:[/#?]|$)'
12 'url': 'https://www.dr.dk/tv/se/boern/ultra/panisk-paske/panisk-paske-5',
13 'md5': 'dc515a9ab50577fa14cc4e4b0265168f',
15 'id': 'panisk-paske-5',
17 'title': 'Panisk Påske (5)',
18 'description': 'md5:ca14173c5ab24cd26b0fcc074dff391c',
19 'timestamp': 1426984612,
20 'upload_date': '20150322',
25 def _real_extract(self
, url
):
26 video_id
= self
._match
_id
(url
)
28 webpage
= self
._download
_webpage
(url
, video_id
)
30 if '>Programmet er ikke længere tilgængeligt' in webpage
:
32 'Video %s is not available' % video_id
, expected
=True)
34 video_id
= self
._search
_regex
(
35 r
'data-(?:material-identifier|episode-slug)="([^"]+)"',
38 programcard
= self
._download
_json
(
39 'http://www.dr.dk/mu/programcard/expanded/%s' % video_id
,
40 video_id
, 'Downloading video JSON')
41 data
= programcard
['Data'][0]
44 description
= data
['Description']
45 timestamp
= parse_iso8601(data
['CreatedTime'])
50 restricted_to_denmark
= False
55 for asset
in data
['Assets']:
56 if asset
['Kind'] == 'Image':
57 thumbnail
= asset
['Uri']
58 elif asset
['Kind'] == 'VideoResource':
59 duration
= asset
['DurationInMilliseconds'] / 1000.0
60 restricted_to_denmark
= asset
['RestrictedToDenmark']
61 spoken_subtitles
= asset
['Target'] == 'SpokenSubtitles'
62 for link
in asset
['Links']:
63 target
= link
['Target']
66 preference
= -1 if target
== 'HDS' else -2
69 format_id
+= '-spoken-subtitles'
71 'url': uri
+ '?hdcore=3.3.0&plugin=aasp-3.3.0.99.43' if target
== 'HDS' else uri
,
72 'format_id': format_id
,
73 'ext': link
['FileFormat'],
74 'preference': preference
,
76 subtitles_list
= asset
.get('SubtitlesList')
77 if isinstance(subtitles_list
, list):
81 for subs
in subtitles_list
:
82 lang
= subs
['Language']
83 subtitles
[LANGS
.get(lang
, lang
)] = [{'url': subs
['Uri'], 'ext': 'vtt'}]
85 if not formats
and restricted_to_denmark
:
87 'Unfortunately, DR is not allowed to show this program outside Denmark.', expected
=True)
89 self
._sort
_formats
(formats
)
94 'description': description
,
95 'thumbnail': thumbnail
,
96 'timestamp': timestamp
,
99 'subtitles': subtitles
,