1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-07 19:52:40 +01:00

[odatv] Improve (Closes #9285)

This commit is contained in:
Sergey M․ 2016-07-20 21:43:22 +07:00
parent 740d7c49c2
commit 790b06b7d4
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -1,51 +1,50 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
ExtractorError, ExtractorError,
NO_DEFAULT,
remove_start remove_start
) )
import re
class OdaTVIE(InfoExtractor): class OdaTVIE(InfoExtractor):
_VALID_URL = r'^https?://(?:www\.)?odatv\.com/(?:mob|vid)_video\.php\?id=(?P<id>[^&]*)' _VALID_URL = r'https?://(?:www\.)?odatv\.com/(?:mob|vid)_video\.php\?.*\bid=(?P<id>[^&]+)'
_TESTS = [{ _TESTS = [{
'url': 'http://odatv.com/vid_video.php?id=8E388', 'url': 'http://odatv.com/vid_video.php?id=8E388',
'md5': 'dc61d052f205c9bf2da3545691485154', 'md5': 'dc61d052f205c9bf2da3545691485154',
'info_dict': { 'info_dict': {
'id': '8E388', 'id': '8E388',
'ext': 'mp4', 'ext': 'mp4',
'title': 'md5:69654805a16a16cf9ec9d055e079831c' 'title': 'Artık Davutoğlu ile devam edemeyiz'
} }
}, { }, {
# mobile URL
'url': 'http://odatv.com/mob_video.php?id=8E388', 'url': 'http://odatv.com/mob_video.php?id=8E388',
'md5': 'dc61d052f205c9bf2da3545691485154', 'only_matching': True,
'info_dict': {
'id': '8E388',
'ext': 'mp4',
'title': 'md5:69654805a16a16cf9ec9d055e079831c'
}
}, { }, {
# no video
'url': 'http://odatv.com/mob_video.php?id=8E900', 'url': 'http://odatv.com/mob_video.php?id=8E900',
'md5': '', 'only_matching': True,
'info_dict': {
'id': '8E900',
'ext': 'mp4',
'title': 'not found check'
}
}] }]
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
if 'NO VIDEO!' in webpage:
no_video = 'NO VIDEO!' in webpage
video_url = self._search_regex(
r'mp4\s*:\s*(["\'])(?P<url>http.+?)\1', webpage, 'video url',
default=None if no_video else NO_DEFAULT, group='url')
if no_video:
raise ExtractorError('Video %s does not exist' % video_id, expected=True) raise ExtractorError('Video %s does not exist' % video_id, expected=True)
return { return {
'id': video_id, 'id': video_id,
'url': video_url,
'title': remove_start(self._og_search_title(webpage), 'Video: '), 'title': remove_start(self._og_search_title(webpage), 'Video: '),
'thumbnail': self._og_search_thumbnail(webpage), 'thumbnail': self._og_search_thumbnail(webpage),
'url': self._html_search_regex(r"(http.+?video_%s\.mp4)" % re.escape(video_id), webpage, 'url', flags=re.IGNORECASE)
} }