1 from .common
import InfoExtractor
8 class AudiMediaIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.)?audi-mediacenter\.com/(?:en|de)/audimediatv/(?:video/)?(?P<id>[^/?#]+)'
11 'url': 'https://www.audi-mediacenter.com/en/audimediatv/60-seconds-of-audi-sport-104-2015-wec-bahrain-rookie-test-1467',
12 'md5': '79a8b71c46d49042609795ab59779b66',
16 'title': '60 Seconds of Audi Sport 104/2015 - WEC Bahrain, Rookie Test',
17 'description': 'md5:60e5d30a78ced725f7b8d34370762941',
18 'upload_date': '20151124',
19 'timestamp': 1448354940,
24 'url': 'https://www.audi-mediacenter.com/en/audimediatv/video/60-seconds-of-audi-sport-104-2015-wec-bahrain-rookie-test-2991',
25 'only_matching': True,
28 def _real_extract(self
, url
):
29 display_id
= self
._match
_id
(url
)
30 webpage
= self
._download
_webpage
(url
, display_id
)
32 raw_payload
= self
._search
_regex
([
33 r
'class="amtv-embed"[^>]+id="([0-9a-z-]+)"',
34 r
'id="([0-9a-z-]+)"[^>]+class="amtv-embed"',
35 r
'class=\\"amtv-embed\\"[^>]+id=\\"([0-9a-z-]+)\\"',
36 r
'id=\\"([0-9a-z-]+)\\"[^>]+class=\\"amtv-embed\\"',
37 r
'id=(?:\\)?"(amtve-[a-z]-\d+-[a-z]{2})',
38 ], webpage
, 'raw payload')
39 _
, stage_mode
, video_id
, _
= 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 video_data
= self
._download
_json
(
44 'https://www.audimedia.tv/api/video/v1/videos/' + video_id
,
46 'embed[]': ['video_versions', 'thumbnail_image'],
50 stream_url_hls
= video_data
.get('stream_url_hls')
52 formats
.extend(self
._extract
_m
3u8_formats
(
53 stream_url_hls
, video_id
, 'mp4',
54 entry_protocol
='m3u8_native', m3u8_id
='hls', fatal
=False))
56 stream_url_hds
= video_data
.get('stream_url_hds')
58 formats
.extend(self
._extract
_f
4m
_formats
(
59 stream_url_hds
+ '?hdcore=3.4.0',
60 video_id
, f4m_id
='hds', fatal
=False))
62 for video_version
in video_data
.get('video_versions', []):
63 video_version_url
= video_version
.get('download_url') or video_version
.get('stream_url')
64 if not video_version_url
:
67 'url': video_version_url
,
68 'width': int_or_none(video_version
.get('width')),
69 'height': int_or_none(video_version
.get('height')),
70 'abr': int_or_none(video_version
.get('audio_bitrate')),
71 'vbr': int_or_none(video_version
.get('video_bitrate')),
73 bitrate
= self
._search
_regex
(r
'(\d+)k', video_version_url
, 'bitrate', default
=None)
76 'format_id': f
'http-{bitrate}',
82 'title': video_data
['title'],
83 'description': video_data
.get('subtitle'),
84 'thumbnail': video_data
.get('thumbnail_image', {}).get('file'),
85 'timestamp': parse_iso8601(video_data
.get('publication_date')),
86 'duration': int_or_none(video_data
.get('duration')),
87 'view_count': int_or_none(video_data
.get('view_count')),