1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-12-30 18:07:54 +01:00
youtube-dl/youtube_dl/extractor/odatv.py

51 lines
1.5 KiB
Python
Raw Normal View History

2016-04-23 03:20:04 +02:00
# coding: utf-8
from __future__ import unicode_literals
2016-07-20 16:43:22 +02:00
2016-04-23 03:20:04 +02:00
from .common import InfoExtractor
from ..utils import (
ExtractorError,
2016-07-20 16:43:22 +02:00
NO_DEFAULT,
2016-04-23 03:20:04 +02:00
remove_start
)
class OdaTVIE(InfoExtractor):
2016-07-20 16:43:22 +02:00
_VALID_URL = r'https?://(?:www\.)?odatv\.com/(?:mob|vid)_video\.php\?.*\bid=(?P<id>[^&]+)'
2016-04-23 03:20:04 +02:00
_TESTS = [{
'url': 'http://odatv.com/vid_video.php?id=8E388',
'md5': 'dc61d052f205c9bf2da3545691485154',
'info_dict': {
'id': '8E388',
'ext': 'mp4',
2016-07-20 16:43:22 +02:00
'title': 'Artık Davutoğlu ile devam edemeyiz'
2016-04-23 03:20:04 +02:00
}
}, {
2016-07-20 16:43:22 +02:00
# mobile URL
2016-04-23 03:20:04 +02:00
'url': 'http://odatv.com/mob_video.php?id=8E388',
2016-07-20 16:43:22 +02:00
'only_matching': True,
2016-04-23 03:20:04 +02:00
}, {
2016-07-20 16:43:22 +02:00
# no video
2016-04-23 03:20:04 +02:00
'url': 'http://odatv.com/mob_video.php?id=8E900',
2016-07-20 16:43:22 +02:00
'only_matching': True,
2016-04-23 03:20:04 +02:00
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
2016-07-20 16:43:22 +02:00
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:
2016-04-23 03:20:04 +02:00
raise ExtractorError('Video %s does not exist' % video_id, expected=True)
return {
'id': video_id,
2016-07-20 16:43:22 +02:00
'url': video_url,
2016-04-23 03:20:04 +02:00
'title': remove_start(self._og_search_title(webpage), 'Video: '),
'thumbnail': self._og_search_thumbnail(webpage),
}