]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/odatv.py
Update changelog.
[youtubedl] / youtube_dl / extractor / odatv.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 ExtractorError,
7 NO_DEFAULT,
8 remove_start
9 )
10
11
12 class OdaTVIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?odatv\.com/(?:mob|vid)_video\.php\?.*\bid=(?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': 'Artık Davutoğlu ile devam edemeyiz'
21 }
22 }, {
23 # mobile URL
24 'url': 'http://odatv.com/mob_video.php?id=8E388',
25 'only_matching': True,
26 }, {
27 # no video
28 'url': 'http://odatv.com/mob_video.php?id=8E900',
29 'only_matching': True,
30 }]
31
32 def _real_extract(self, url):
33 video_id = self._match_id(url)
34 webpage = self._download_webpage(url, video_id)
35
36 no_video = 'NO VIDEO!' in webpage
37
38 video_url = self._search_regex(
39 r'mp4\s*:\s*(["\'])(?P<url>http.+?)\1', webpage, 'video url',
40 default=None if no_video else NO_DEFAULT, group='url')
41
42 if no_video:
43 raise ExtractorError('Video %s does not exist' % video_id, expected=True)
44
45 return {
46 'id': video_id,
47 'url': video_url,
48 'title': remove_start(self._og_search_title(webpage), 'Video: '),
49 'thumbnail': self._og_search_thumbnail(webpage),
50 }