[ATV.at] Fix extractor for ATV.at

Fixes: https://github.com/ytdl-org/youtube-dl/issues/29079
This commit is contained in:
Reinhold Gschweicher 2021-05-19 23:15:07 +02:00
parent dfbbe2902f
commit 156c58b07f

View File

@ -12,15 +12,15 @@ from ..utils import (
class ATVAtIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?atv\.at/(?:[^/]+/){2}(?P<id>[dv]\d+)'
_TESTS = [{
'url': 'http://atv.at/aktuell/di-210317-2005-uhr/v1698449/',
'md5': 'c3b6b975fb3150fc628572939df205f2',
'url': 'https://www.atv.at/bauer-sucht-frau-die-zweite-chance/folge-1/d3390693/',
'md5': 'c471605591009dfb6e6c54f7e62e2807',
'info_dict': {
'id': '1698447',
'id': '3390684',
'ext': 'mp4',
'title': 'DI, 21.03.17 | 20:05 Uhr 1/1',
'title': 'Bauer sucht Frau - Die zweite Chance Folge 1',
}
}, {
'url': 'http://atv.at/aktuell/meinrad-knapp/d8416/',
'url': 'https://www.atv.at/bauer-sucht-frau-staffel-17/fuenfte-eventfolge/d3339537/',
'only_matching': True,
}]
@ -28,48 +28,52 @@ class ATVAtIE(InfoExtractor):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
video_data = self._parse_json(unescapeHTML(self._search_regex(
[r'flashPlayerOptions\s*=\s*(["\'])(?P<json>(?:(?!\1).)+)\1',
r'class="[^"]*jsb_video/FlashPlayer[^"]*"[^>]+data-jsb="(?P<json>[^"]+)"'],
r'var\splaylist\s*=\s*(?P<json>\[.*\]);',
webpage, 'player data', group='json')),
display_id)['config']['initial_video']
display_id)
video_id = video_data['id']
video_title = video_data['title']
first_video = video_data[0]
video_id = first_video['id']
video_title = first_video.get('tvShowTitle', first_video['title'])
parts = []
for part in video_data.get('parts', []):
part_id = part['id']
part_title = part['title']
formats = []
for source in part.get('sources', []):
source_url = source.get('src')
def process_source_entry(self, source, part_id):
source_url = source.get('url')
if not source_url:
continue
return None
ext = determine_ext(source_url)
if ext == 'm3u8':
formats.extend(self._extract_m3u8_formats(
return self._extract_m3u8_formats(
source_url, part_id, 'mp4', 'm3u8_native',
m3u8_id='hls', fatal=False))
m3u8_id='hls', fatal=False)
else:
formats.append({
'format_id': source.get('delivery'),
return {
'url': source_url,
})
self._sort_formats(formats)
}
parts.append({
'id': part_id,
'title': part_title,
'thumbnail': part.get('preview_image_url'),
'duration': int_or_none(part.get('duration')),
'is_live': part.get('is_livestream'),
'formats': formats,
})
def process_entry(self, entry):
part_id = entry['id']
formats = [process_source_entry(self, source, part_id) for source in entry["sources"]]
formats_flat = []
for f in formats:
if f is None:
continue
elif type(f) is list:
formats_flat.extend(f)
else:
formats_flat.append(f)
self._sort_formats(formats_flat)
return {
'id': entry['id'],
'title': entry['title'],
'duration': int_or_none(entry.get('duration')),
'formats': formats_flat
}
entries = [process_entry(self, entry) for entry in video_data]
return {
'_type': 'multi_video',
'id': video_id,
'title': video_title,
'entries': parts,
'entries': entries,
}