]>
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',
21 'title': 'Talkshowet - Leonard Cohen',
22 'description': 'md5:8f34194fb30cd8c8a30ad8b27b70c0ca',
23 'thumbnail': r
're:^https?://.*\.(?:gif|jpg)$',
24 'timestamp': 1295537932,
25 'upload_date': '20110120',
29 'skip_download': True, # requires rtmp
32 'url': 'http://www.dr.dk/bonanza/radio/serie/sport/fodbold.htm?assetId=59410',
33 'md5': '6dfe039417e76795fb783c52da3de11d',
37 'title': 'EM fodbold 1992 Danmark - Tyskland finale Transmission',
38 'description': 'md5:501e5a195749480552e214fbbed16c4e',
39 'thumbnail': r
're:^https?://.*\.(?:gif|jpg)$',
40 'timestamp': 1223274900,
41 'upload_date': '20081006',
46 def _real_extract(self
, url
):
47 url_id
= self
._match
_id
(url
)
48 webpage
= self
._download
_webpage
(url
, url_id
)
51 info
= json
.loads(self
._html
_search
_regex
(r
'({.*?%s.*})' % url_id
, webpage
, 'json'))
53 # Just fetch the first video on that page
54 info
= json
.loads(self
._html
_search
_regex
(r
'bonanzaFunctions.newPlaylist\(({.*})\)', webpage
, 'json'))
56 asset_id
= str(info
['AssetId'])
57 title
= info
['Title'].rstrip(' \'\"-,.:;!?')
58 duration
= int_or_none(info
.get('Duration'), scale
=1000)
59 # First published online. "FirstPublished" contains the date for original airing.
60 timestamp
= parse_iso8601(
61 re
.sub(r
'\.\d+$', '', info
['Created']))
63 def parse_filename_info(url
):
64 match
= re
.search(r
'/\d+_(?P<width>\d+)x(?P<height>\d+)x(?P<bitrate>\d+)K\.(?P<ext>\w+)$', url
)
67 'width': int(match
.group('width')),
68 'height': int(match
.group('height')),
69 'vbr': int(match
.group('bitrate')),
70 'ext': match
.group('ext')
72 match
= re
.search(r
'/\d+_(?P<bitrate>\d+)K\.(?P<ext>\w+)$', url
)
75 'vbr': int(match
.group('bitrate')),
80 video_types
= ['VideoHigh', 'VideoMid', 'VideoLow']
89 for file in info
['Files']:
90 if info
['Type'] == 'Video':
91 if file['Type'] in video_types
:
92 format
= parse_filename_info(file['Location'])
94 'url': file['Location'],
95 'format_id': file['Type'].replace('Video', ''),
96 'preference': preferencemap
.get(file['Type'], -10),
98 if format
['url'].startswith('rtmp'):
99 rtmp_url
= format
['url']
100 format
['rtmp_live'] = True # --resume does not work
101 if '/bonanza/' in rtmp_url
:
102 format
['play_path'] = rtmp_url
.split('/bonanza/')[1]
103 formats
.append(format
)
104 elif file['Type'] == 'Thumb':
105 thumbnail
= file['Location']
106 elif info
['Type'] == 'Audio':
107 if file['Type'] == 'Audio':
108 format
= parse_filename_info(file['Location'])
110 'url': file['Location'],
111 'format_id': file['Type'],
114 formats
.append(format
)
115 elif file['Type'] == 'Thumb':
116 thumbnail
= file['Location']
118 description
= '%s\n%s\n%s\n' % (
119 info
['Description'], info
['Actors'], info
['Colophon'])
121 self
._sort
_formats
(formats
)
123 display_id
= re
.sub(r
'[^\w\d-]', '', re
.sub(r
' ', '-', title
.lower())) + '-' + asset_id
124 display_id
= re
.sub(r
'-+', '-', display_id
)
128 'display_id': display_id
,
131 'description': description
,
132 'thumbnail': thumbnail
,
133 'timestamp': timestamp
,
134 'duration': duration
,