]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/odatv.py
[odatv] Add extractor
[yt-dlp.git] / youtube_dl / extractor / odatv.py
1 # coding: utf-8
2
3 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..utils import (
6 ExtractorError,
7 remove_start
8 )
9 import re
10
11
12 class OdaTVIE(InfoExtractor):
13 _VALID_URL = r'^https?://(?:www\.)?odatv\.com/(?:mob|vid)_video\.php\?id=(?P<id>[^&]*)'
14 _TESTS = [{
15 'url': 'http://odatv.com/vid_video.php?id=8E388',
16 'md5': 'dc61d052f205c9bf2da3545691485154',
17 'info_dict': {
18 'id': '8E388',
19 'ext': 'mp4',
20 'title': 'md5:69654805a16a16cf9ec9d055e079831c'
21 }
22 }, {
23 'url': 'http://odatv.com/mob_video.php?id=8E388',
24 'md5': 'dc61d052f205c9bf2da3545691485154',
25 'info_dict': {
26 'id': '8E388',
27 'ext': 'mp4',
28 'title': 'md5:69654805a16a16cf9ec9d055e079831c'
29 }
30 }, {
31 'url': 'http://odatv.com/mob_video.php?id=8E900',
32 'md5': '',
33 'info_dict': {
34 'id': '8E900',
35 'ext': 'mp4',
36 'title': 'not found check'
37 }
38 }]
39
40 def _real_extract(self, url):
41 video_id = self._match_id(url)
42 webpage = self._download_webpage(url, video_id)
43 if 'NO VIDEO!' in webpage:
44 raise ExtractorError('Video %s does not exist' % video_id, expected=True)
45
46 return {
47 'id': video_id,
48 'title': remove_start(self._og_search_title(webpage), 'Video: '),
49 'thumbnail': self._og_search_thumbnail(webpage),
50 'url': self._html_search_regex(r"(http.+?video_%s\.mp4)" % re.escape(video_id), webpage, 'url', flags=re.IGNORECASE)
51 }