mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-11-27 13:06:49 +01:00
[spiegel] Use generalized formats pre-testing
This commit is contained in:
parent
a57e8ce658
commit
d862a4f94f
@ -4,14 +4,7 @@ from __future__ import unicode_literals
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
from ..compat import compat_urlparse
|
||||||
compat_urlparse,
|
|
||||||
compat_HTTPError,
|
|
||||||
)
|
|
||||||
from ..utils import (
|
|
||||||
HEADRequest,
|
|
||||||
ExtractorError,
|
|
||||||
)
|
|
||||||
from .spiegeltv import SpiegeltvIE
|
from .spiegeltv import SpiegeltvIE
|
||||||
|
|
||||||
|
|
||||||
@ -72,16 +65,6 @@ class SpiegelIE(InfoExtractor):
|
|||||||
if n.tag.startswith('type') and n.tag != 'type6':
|
if n.tag.startswith('type') and n.tag != 'type6':
|
||||||
format_id = n.tag.rpartition('type')[2]
|
format_id = n.tag.rpartition('type')[2]
|
||||||
video_url = base_url + n.find('./filename').text
|
video_url = base_url + n.find('./filename').text
|
||||||
# Test video URLs beforehand as some of them are invalid
|
|
||||||
try:
|
|
||||||
self._request_webpage(
|
|
||||||
HEADRequest(video_url), video_id,
|
|
||||||
'Checking %s video URL' % format_id)
|
|
||||||
except ExtractorError as e:
|
|
||||||
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 404:
|
|
||||||
self.report_warning(
|
|
||||||
'%s video URL is invalid, skipping' % format_id, video_id)
|
|
||||||
continue
|
|
||||||
formats.append({
|
formats.append({
|
||||||
'format_id': format_id,
|
'format_id': format_id,
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
@ -94,6 +77,7 @@ class SpiegelIE(InfoExtractor):
|
|||||||
})
|
})
|
||||||
duration = float(idoc[0].findall('./duration')[0].text)
|
duration = float(idoc[0].findall('./duration')[0].text)
|
||||||
|
|
||||||
|
self._check_formats(formats, video_id)
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user