]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/audimedia.py
3b2effa15fe15a5527644349d785b452540c7568
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
12 class AudiMediaIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://(?:www\.)?audimedia\.tv/(?:en|de)/vid/(?P<id>[^/?#]+)'
15 'url': 'https://audimedia.tv/en/vid/60-seconds-of-audi-sport-104-2015-wec-bahrain-rookie-test',
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
(r
'<script[^>]+class="amtv-embed"[^>]+id="([^"]+)"', webpage
, 'raw payload')
36 _
, stage_mode
, video_id
, lang
= raw_payload
.split('-')
38 # TODO: handle s and e stage_mode (live streams and ended live streams)
39 if stage_mode
not in ('s', 'e'):
40 request
= sanitized_Request(
41 'https://audimedia.tv/api/video/v1/videos/%s?embed[]=video_versions&embed[]=thumbnail_image&where[content_language_iso]=%s' % (video_id
, lang
),
42 headers
={'X-Auth-Token': self
._AUTH
_TOKEN
})
43 json_data
= self
._download
_json
(request
, video_id
)['results']
46 stream_url_hls
= json_data
.get('stream_url_hls')
48 formats
.extend(self
._extract
_m
3u8_formats
(
49 stream_url_hls
, video_id
, 'mp4',
50 entry_protocol
='m3u8_native', m3u8_id
='hls', fatal
=False))
52 stream_url_hds
= json_data
.get('stream_url_hds')
54 formats
.extend(self
._extract
_f
4m
_formats
(
55 stream_url_hds
+ '?hdcore=3.4.0',
56 video_id
, f4m_id
='hds', fatal
=False))
58 for video_version
in json_data
.get('video_versions'):
59 video_version_url
= video_version
.get('download_url') or video_version
.get('stream_url')
60 if not video_version_url
:
63 'url': video_version_url
,
64 'width': int_or_none(video_version
.get('width')),
65 'height': int_or_none(video_version
.get('height')),
66 'abr': int_or_none(video_version
.get('audio_bitrate')),
67 'vbr': int_or_none(video_version
.get('video_bitrate')),
69 self
._sort
_formats
(formats
)
73 'title': json_data
['title'],
74 'description': json_data
.get('subtitle'),
75 'thumbnail': json_data
.get('thumbnail_image', {}).get('file'),
76 'timestamp': parse_iso8601(json_data
.get('publication_date')),
77 'duration': int_or_none(json_data
.get('duration')),
78 'view_count': int_or_none(json_data
.get('view_count')),