2015-11-26 20:24:10 +00:00
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
|
|
|
int_or_none,
|
|
|
|
parse_iso8601,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class AudiMediaIE(InfoExtractor):
|
2018-05-31 11:39:45 +00:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?audi-mediacenter\.com/(?:en|de)/audimediatv/(?:video/)?(?P<id>[^/?#]+)'
|
|
|
|
_TESTS = [{
|
2016-03-04 16:55:50 +00:00
|
|
|
'url': 'https://www.audi-mediacenter.com/en/audimediatv/60-seconds-of-audi-sport-104-2015-wec-bahrain-rookie-test-1467',
|
2015-11-26 20:24:10 +00:00
|
|
|
'md5': '79a8b71c46d49042609795ab59779b66',
|
|
|
|
'info_dict': {
|
2015-12-21 22:02:55 +00:00
|
|
|
'id': '1565',
|
2015-11-26 20:24:10 +00:00
|
|
|
'ext': 'mp4',
|
|
|
|
'title': '60 Seconds of Audi Sport 104/2015 - WEC Bahrain, Rookie Test',
|
|
|
|
'description': 'md5:60e5d30a78ced725f7b8d34370762941',
|
|
|
|
'upload_date': '20151124',
|
|
|
|
'timestamp': 1448354940,
|
|
|
|
'duration': 74022,
|
|
|
|
'view_count': int,
|
|
|
|
}
|
2018-05-31 11:39:45 +00:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.audi-mediacenter.com/en/audimediatv/video/60-seconds-of-audi-sport-104-2015-wec-bahrain-rookie-test-2991',
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
2015-11-26 20:24:10 +00:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
display_id = self._match_id(url)
|
|
|
|
webpage = self._download_webpage(url, display_id)
|
2015-12-03 21:25:08 +00:00
|
|
|
|
2016-03-04 16:55:50 +00:00
|
|
|
raw_payload = self._search_regex([
|
2018-05-31 11:39:45 +00:00
|
|
|
r'class="amtv-embed"[^>]+id="([0-9a-z-]+)"',
|
|
|
|
r'id="([0-9a-z-]+)"[^>]+class="amtv-embed"',
|
|
|
|
r'class=\\"amtv-embed\\"[^>]+id=\\"([0-9a-z-]+)\\"',
|
|
|
|
r'id=\\"([0-9a-z-]+)\\"[^>]+class=\\"amtv-embed\\"',
|
|
|
|
r'id=(?:\\)?"(amtve-[a-z]-\d+-[a-z]{2})',
|
2016-03-04 16:55:50 +00:00
|
|
|
], webpage, 'raw payload')
|
2018-05-31 11:39:45 +00:00
|
|
|
_, stage_mode, video_id, _ = raw_payload.split('-')
|
2015-11-26 20:24:10 +00:00
|
|
|
|
|
|
|
# TODO: handle s and e stage_mode (live streams and ended live streams)
|
|
|
|
if stage_mode not in ('s', 'e'):
|
2018-05-31 11:39:45 +00:00
|
|
|
video_data = self._download_json(
|
|
|
|
'https://www.audimedia.tv/api/video/v1/videos/' + video_id,
|
|
|
|
video_id, query={
|
|
|
|
'embed[]': ['video_versions', 'thumbnail_image'],
|
|
|
|
})['results']
|
2015-11-26 20:24:10 +00:00
|
|
|
formats = []
|
|
|
|
|
2018-05-31 11:39:45 +00:00
|
|
|
stream_url_hls = video_data.get('stream_url_hls')
|
2015-11-26 20:24:10 +00:00
|
|
|
if stream_url_hls:
|
2015-12-29 13:53:06 +00:00
|
|
|
formats.extend(self._extract_m3u8_formats(
|
|
|
|
stream_url_hls, video_id, 'mp4',
|
|
|
|
entry_protocol='m3u8_native', m3u8_id='hls', fatal=False))
|
2015-11-26 20:24:10 +00:00
|
|
|
|
2018-05-31 11:39:45 +00:00
|
|
|
stream_url_hds = video_data.get('stream_url_hds')
|
2015-11-26 20:24:10 +00:00
|
|
|
if stream_url_hds:
|
2015-12-29 13:53:06 +00:00
|
|
|
formats.extend(self._extract_f4m_formats(
|
|
|
|
stream_url_hds + '?hdcore=3.4.0',
|
|
|
|
video_id, f4m_id='hds', fatal=False))
|
2015-11-26 20:24:10 +00:00
|
|
|
|
2018-05-31 11:39:45 +00:00
|
|
|
for video_version in video_data.get('video_versions', []):
|
2015-11-26 20:24:10 +00:00
|
|
|
video_version_url = video_version.get('download_url') or video_version.get('stream_url')
|
|
|
|
if not video_version_url:
|
|
|
|
continue
|
2016-03-04 16:55:50 +00:00
|
|
|
f = {
|
2015-11-26 20:24:10 +00:00
|
|
|
'url': video_version_url,
|
|
|
|
'width': int_or_none(video_version.get('width')),
|
|
|
|
'height': int_or_none(video_version.get('height')),
|
|
|
|
'abr': int_or_none(video_version.get('audio_bitrate')),
|
|
|
|
'vbr': int_or_none(video_version.get('video_bitrate')),
|
2016-03-04 16:55:50 +00:00
|
|
|
}
|
|
|
|
bitrate = self._search_regex(r'(\d+)k', video_version_url, 'bitrate', default=None)
|
|
|
|
if bitrate:
|
|
|
|
f.update({
|
|
|
|
'format_id': 'http-%s' % bitrate,
|
|
|
|
})
|
|
|
|
formats.append(f)
|
2015-11-26 20:24:10 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
2018-05-31 11:39:45 +00:00
|
|
|
'title': video_data['title'],
|
|
|
|
'description': video_data.get('subtitle'),
|
|
|
|
'thumbnail': video_data.get('thumbnail_image', {}).get('file'),
|
|
|
|
'timestamp': parse_iso8601(video_data.get('publication_date')),
|
|
|
|
'duration': int_or_none(video_data.get('duration')),
|
|
|
|
'view_count': int_or_none(video_data.get('view_count')),
|
2015-11-26 20:24:10 +00:00
|
|
|
'formats': formats,
|
|
|
|
}
|