mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-07 20:30:41 -05:00
[UDNEmbed] Enhance error checking and extend _VALID_URL
This commit is contained in:
parent
9fc03aa87c
commit
d0eb724e22
1 changed files with 14 additions and 4 deletions
|
@ -3,12 +3,15 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import js_to_json
|
from ..utils import (
|
||||||
|
js_to_json,
|
||||||
|
ExtractorError,
|
||||||
|
)
|
||||||
from ..compat import compat_urlparse
|
from ..compat import compat_urlparse
|
||||||
|
|
||||||
|
|
||||||
class UDNEmbedIE(InfoExtractor):
|
class UDNEmbedIE(InfoExtractor):
|
||||||
_VALID_URL = r'(?:https?:)?//video\.udn\.com/embed/news/(?P<id>\d+)'
|
_VALID_URL = r'https?://video\.udn\.com/(?:embed|play)/news/(?P<id>\d+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://video.udn.com/embed/news/300040',
|
'url': 'http://video.udn.com/embed/news/300040',
|
||||||
'md5': 'de06b4c90b042c128395a88f0384817e',
|
'md5': 'de06b4c90b042c128395a88f0384817e',
|
||||||
|
@ -19,7 +22,11 @@ class UDNEmbedIE(InfoExtractor):
|
||||||
'thumbnail': 're:^https?://.*\.jpg$',
|
'thumbnail': 're:^https?://.*\.jpg$',
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'url': '//video.udn.com/embed/news/300040',
|
'url': 'https://video.udn.com/embed/news/300040',
|
||||||
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
# From https://video.udn.com/news/303776
|
||||||
|
'url': 'https://video.udn.com/play/news/303776',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
@ -47,7 +54,10 @@ def _real_extract(self, url):
|
||||||
'retrieve url for %s video' % video_type),
|
'retrieve url for %s video' % video_type),
|
||||||
'format_id': video_type,
|
'format_id': video_type,
|
||||||
'preference': 0 if video_type == 'mp4' else -1,
|
'preference': 0 if video_type == 'mp4' else -1,
|
||||||
} for video_type, api_url in video_urls.items()]
|
} for video_type, api_url in video_urls.items() if api_url]
|
||||||
|
|
||||||
|
if not formats:
|
||||||
|
raise ExtractorError('No videos found', expected=True)
|
||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue