[thepltform] detect other types of errors

This commit is contained in:
remitamine 2016-03-02 21:41:29 +01:00
parent e07237f640
commit 4459bef203

View file

@ -22,6 +22,7 @@ from ..utils import (
unsmuggle_url, unsmuggle_url,
xpath_with_ns, xpath_with_ns,
mimetype2ext, mimetype2ext,
find_xpath_attr,
) )
default_ns = 'http://www.w3.org/2005/SMIL21/Language' default_ns = 'http://www.w3.org/2005/SMIL21/Language'
@ -31,15 +32,11 @@ _x = lambda p: xpath_with_ns(p, {'smil': default_ns})
class ThePlatformBaseIE(InfoExtractor): class ThePlatformBaseIE(InfoExtractor):
def _extract_theplatform_smil(self, smil_url, video_id, note='Downloading SMIL data'): def _extract_theplatform_smil(self, smil_url, video_id, note='Downloading SMIL data'):
meta = self._download_xml(smil_url, video_id, note=note) meta = self._download_xml(smil_url, video_id, note=note)
try: error_element = find_xpath_attr(
error_msg = next( meta, _x('.//smil:ref'), 'src',
n.attrib['abstract'] 'http://link.theplatform.com/s/errorFiles/Unavailable.mp4')
for n in meta.findall(_x('.//smil:ref')) if error_element is not None:
if n.attrib.get('title') == 'Geographic Restriction' or n.attrib.get('title') == 'Expired') raise ExtractorError(error_element.attrib['abstract'], expected=True)
except StopIteration:
pass
else:
raise ExtractorError(error_msg, expected=True)
formats = self._parse_smil_formats( formats = self._parse_smil_formats(
meta, smil_url, video_id, namespace=default_ns, meta, smil_url, video_id, namespace=default_ns,