]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/drbonanza.py
1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
13 class DRBonanzaIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?dr\.dk/bonanza/(?:[^/]+/)+(?:[^/])+?(?:assetId=(?P<id>\d+))?(?:[#&]|$)'
17 'url': 'http://www.dr.dk/bonanza/serie/portraetter/Talkshowet.htm?assetId=65517',
18 'md5': 'fe330252ddea607635cf2eb2c99a0af3',
22 'title': 'Talkshowet - Leonard Cohen',
23 'description': 'md5:8f34194fb30cd8c8a30ad8b27b70c0ca',
24 'thumbnail': 're:^https?://.*\.(?:gif|jpg)$',
25 'timestamp': 1295537932,
26 'upload_date': '20110120',
30 'url': 'http://www.dr.dk/bonanza/radio/serie/sport/fodbold.htm?assetId=59410',
31 'md5': '6dfe039417e76795fb783c52da3de11d',
35 'title': 'EM fodbold 1992 Danmark - Tyskland finale Transmission',
36 'description': 'md5:501e5a195749480552e214fbbed16c4e',
37 'thumbnail': 're:^https?://.*\.(?:gif|jpg)$',
38 'timestamp': 1223274900,
39 'upload_date': '20081006',
44 def _real_extract(self
, url
):
45 url_id
= self
._match
_id
(url
)
46 webpage
= self
._download
_webpage
(url
, url_id
)
49 info
= json
.loads(self
._html
_search
_regex
(r
'({.*?%s.*})' % url_id
, webpage
, 'json'))
51 # Just fetch the first video on that page
52 info
= json
.loads(self
._html
_search
_regex
(r
'bonanzaFunctions.newPlaylist\(({.*})\)', webpage
, 'json'))
54 asset_id
= str(info
['AssetId'])
55 title
= info
['Title'].rstrip(' \'\"-,.:;!?')
56 duration
= int_or_none(info
.get('Duration'), scale
=1000)
57 # First published online. "FirstPublished" contains the date for original airing.
58 timestamp
= parse_iso8601(
59 re
.sub(r
'\.\d+$', '', info
['Created']))
61 def parse_filename_info(url
):
62 match
= re
.search(r
'/\d+_(?P<width>\d+)x(?P<height>\d+)x(?P<bitrate>\d+)K\.(?P<ext>\w+)$', url
)
65 'width': int(match
.group('width')),
66 'height': int(match
.group('height')),
67 'vbr': int(match
.group('bitrate')),
68 'ext': match
.group('ext')
70 match
= re
.search(r
'/\d+_(?P<bitrate>\d+)K\.(?P<ext>\w+)$', url
)
73 'vbr': int(match
.group('bitrate')),
78 video_types
= ['VideoHigh', 'VideoMid', 'VideoLow']
87 for file in info
['Files']:
88 if info
['Type'] == "Video":
89 if file['Type'] in video_types
:
90 format
= parse_filename_info(file['Location'])
92 'url': file['Location'],
93 'format_id': file['Type'].replace('Video', ''),
94 'preference': preferencemap
.get(file['Type'], -10),
96 formats
.append(format
)
97 elif file['Type'] == "Thumb":
98 thumbnail
= file['Location']
99 elif info
['Type'] == "Audio":
100 if file['Type'] == "Audio":
101 format
= parse_filename_info(file['Location'])
103 'url': file['Location'],
104 'format_id': file['Type'],
107 formats
.append(format
)
108 elif file['Type'] == "Thumb":
109 thumbnail
= file['Location']
111 description
= '%s\n%s\n%s\n' % (
112 info
['Description'], info
['Actors'], info
['Colophon'])
115 f
['url'] = f
['url'].replace('rtmp://vod-bonanza.gss.dr.dk/bonanza/', 'http://vodfiles.dr.dk/')
116 f
['url'] = f
['url'].replace('mp4:bonanza', 'bonanza')
117 self
._sort
_formats
(formats
)
119 display_id
= re
.sub(r
'[^\w\d-]', '', re
.sub(r
' ', '-', title
.lower())) + '-' + asset_id
120 display_id
= re
.sub(r
'-+', '-', display_id
)
124 'display_id': display_id
,
127 'description': description
,
128 'thumbnail': thumbnail
,
129 'timestamp': timestamp
,
130 'duration': duration
,