]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/odatv.py
[compat, networking] Deprecate old functions (#2861)
[yt-dlp.git] / yt_dlp / extractor / odatv.py
1 from .common import InfoExtractor
2 from ..utils import (
3 ExtractorError,
4 NO_DEFAULT,
5 remove_start
6 )
7
8
9 class OdaTVIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?odatv\.com/(?:mob|vid)_video\.php\?.*\bid=(?P<id>[^&]+)'
11 _TESTS = [{
12 'url': 'http://odatv.com/vid_video.php?id=8E388',
13 'md5': 'dc61d052f205c9bf2da3545691485154',
14 'info_dict': {
15 'id': '8E388',
16 'ext': 'mp4',
17 'title': 'Artık Davutoğlu ile devam edemeyiz'
18 }
19 }, {
20 # mobile URL
21 'url': 'http://odatv.com/mob_video.php?id=8E388',
22 'only_matching': True,
23 }, {
24 # no video
25 'url': 'http://odatv.com/mob_video.php?id=8E900',
26 'only_matching': True,
27 }]
28
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
31 webpage = self._download_webpage(url, video_id)
32
33 no_video = 'NO VIDEO!' in webpage
34
35 video_url = self._search_regex(
36 r'mp4\s*:\s*(["\'])(?P<url>http.+?)\1', webpage, 'video url',
37 default=None if no_video else NO_DEFAULT, group='url')
38
39 if no_video:
40 raise ExtractorError('Video %s does not exist' % video_id, expected=True)
41
42 return {
43 'id': video_id,
44 'url': video_url,
45 'title': remove_start(self._og_search_title(webpage), 'Video: '),
46 'thumbnail': self._og_search_thumbnail(webpage),
47 }