]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/audimedia.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
12 class AudiMediaIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://(?:www\.)?audi-mediacenter\.com/(?:en|de)/audimediatv/(?P<id>[^/?#]+)'
15 'url': 'https://www.audi-mediacenter.com/en/audimediatv/60-seconds-of-audi-sport-104-2015-wec-bahrain-rookie-test-1467',
16 'md5': '79a8b71c46d49042609795ab59779b66',
20 'title': '60 Seconds of Audi Sport 104/2015 - WEC Bahrain, Rookie Test',
21 'description': 'md5:60e5d30a78ced725f7b8d34370762941',
22 'upload_date': '20151124',
23 'timestamp': 1448354940,
28 # extracted from https://audimedia.tv/assets/embed/embedded-player.js (dataSourceAuthToken)
29 _AUTH_TOKEN
= 'e25b42847dba18c6c8816d5d8ce94c326e06823ebf0859ed164b3ba169be97f2'
31 def _real_extract(self
, url
):
32 display_id
= self
._match
_id
(url
)
33 webpage
= self
._download
_webpage
(url
, display_id
)
35 raw_payload
= self
._search
_regex
([
36 r
'class="amtv-embed"[^>]+id="([^"]+)"',
37 r
'class=\\"amtv-embed\\"[^>]+id=\\"([^"]+)\\"',
38 ], webpage
, 'raw payload')
39 _
, stage_mode
, video_id
, lang
= raw_payload
.split('-')
41 # TODO: handle s and e stage_mode (live streams and ended live streams)
42 if stage_mode
not in ('s', 'e'):
43 request
= sanitized_Request(
44 'https://audimedia.tv/api/video/v1/videos/%s?embed[]=video_versions&embed[]=thumbnail_image&where[content_language_iso]=%s' % (video_id
, lang
),
45 headers
={'X-Auth-Token': self
._AUTH
_TOKEN
})
46 json_data
= self
._download
_json
(request
, video_id
)['results']
49 stream_url_hls
= json_data
.get('stream_url_hls')
51 formats
.extend(self
._extract
_m
3u8_formats
(
52 stream_url_hls
, video_id
, 'mp4',
53 entry_protocol
='m3u8_native', m3u8_id
='hls', fatal
=False))
55 stream_url_hds
= json_data
.get('stream_url_hds')
57 formats
.extend(self
._extract
_f
4m
_formats
(
58 stream_url_hds
+ '?hdcore=3.4.0',
59 video_id
, f4m_id
='hds', fatal
=False))
61 for video_version
in json_data
.get('video_versions'):
62 video_version_url
= video_version
.get('download_url') or video_version
.get('stream_url')
63 if not video_version_url
:
66 'url': video_version_url
,
67 'width': int_or_none(video_version
.get('width')),
68 'height': int_or_none(video_version
.get('height')),
69 'abr': int_or_none(video_version
.get('audio_bitrate')),
70 'vbr': int_or_none(video_version
.get('video_bitrate')),
72 bitrate
= self
._search
_regex
(r
'(\d+)k', video_version_url
, 'bitrate', default
=None)
75 'format_id': 'http-%s' % bitrate
,
78 self
._sort
_formats
(formats
)
82 'title': json_data
['title'],
83 'description': json_data
.get('subtitle'),
84 'thumbnail': json_data
.get('thumbnail_image', {}).get('file'),
85 'timestamp': parse_iso8601(json_data
.get('publication_date')),
86 'duration': int_or_none(json_data
.get('duration')),
87 'view_count': int_or_none(json_data
.get('view_count')),