[mtv] Skip missing video parts (closes #13690)

This commit is contained in:
Sergey M․ 2017-07-23 00:25:23 +07:00
parent 0017d9ad6d
commit e0f1fb0a27
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D
2 changed files with 30 additions and 10 deletions

View File

@ -83,7 +83,7 @@ def _extract_video_formats(self, mdoc, mtvn_id, video_id):
hls_url = rendition.find('./src').text hls_url = rendition.find('./src').text
formats.extend(self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
hls_url, video_id, ext='mp4', entry_protocol='m3u8_native', hls_url, video_id, ext='mp4', entry_protocol='m3u8_native',
m3u8_id='hls')) m3u8_id='hls', fatal=False))
else: else:
# fms # fms
try: try:
@ -106,6 +106,7 @@ def _extract_video_formats(self, mdoc, mtvn_id, video_id):
}]) }])
except (KeyError, TypeError): except (KeyError, TypeError):
raise ExtractorError('Invalid rendition field.') raise ExtractorError('Invalid rendition field.')
if formats:
self._sort_formats(formats) self._sort_formats(formats)
return formats return formats
@ -133,8 +134,11 @@ def _get_video_info(self, itemdoc, use_hls=True):
mediagen_url += 'acceptMethods=' mediagen_url += 'acceptMethods='
mediagen_url += 'hls' if use_hls else 'fms' mediagen_url += 'hls' if use_hls else 'fms'
mediagen_doc = self._download_xml(mediagen_url, video_id, mediagen_doc = self._download_xml(
'Downloading video urls') mediagen_url, video_id, 'Downloading video urls', fatal=False)
if mediagen_doc is False:
return None
item = mediagen_doc.find('./video/item') item = mediagen_doc.find('./video/item')
if item is not None and item.get('type') == 'text': if item is not None and item.get('type') == 'text':
@ -174,6 +178,13 @@ def _get_video_info(self, itemdoc, use_hls=True):
formats = self._extract_video_formats(mediagen_doc, mtvn_id, video_id) formats = self._extract_video_formats(mediagen_doc, mtvn_id, video_id)
# Some parts of complete video may be missing (e.g. missing Act 3 in
# http://www.southpark.de/alle-episoden/s14e01-sexual-healing)
if not formats:
return None
self._sort_formats(formats)
return { return {
'title': title, 'title': title,
'formats': formats, 'formats': formats,
@ -205,9 +216,14 @@ def _get_videos_info_from_url(self, url, video_id, use_hls=True):
title = xpath_text(idoc, './channel/title') title = xpath_text(idoc, './channel/title')
description = xpath_text(idoc, './channel/description') description = xpath_text(idoc, './channel/description')
entries = []
for item in idoc.findall('.//item'):
info = self._get_video_info(item, use_hls)
if info:
entries.append(info)
return self.playlist_result( return self.playlist_result(
[self._get_video_info(item, use_hls) for item in idoc.findall('.//item')], entries, playlist_title=title, playlist_description=description)
playlist_title=title, playlist_description=description)
def _extract_triforce_mgid(self, webpage, data_zone=None, video_id=None): def _extract_triforce_mgid(self, webpage, data_zone=None, video_id=None):
triforce_feed = self._parse_json(self._search_regex( triforce_feed = self._parse_json(self._search_regex(

View File

@ -121,7 +121,11 @@ def _real_extract(self, url):
idoc = self._download_xml( idoc = self._download_xml(
doc_url, video_id, doc_url, video_id,
'Downloading info', transform_source=fix_xml_ampersands) 'Downloading info', transform_source=fix_xml_ampersands)
return self.playlist_result(
[self._get_video_info(item) for item in idoc.findall('.//item')], entries = []
playlist_id=video_id, for item in idoc.findall('.//item'):
) info = self._get_video_info(item)
if info:
entries.append(info)
return self.playlist_result(entries, playlist_id=video_id)