]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/veoh.py
[toutv] really skip test
[youtube-dl.git] / youtube_dl / extractor / veoh.py
1 import re
2 import json
3
4 from .common import InfoExtractor
5 from ..utils import (
6     determine_ext,
7 )
8
9 class VeohIE(InfoExtractor):
10     _VALID_URL = r'http://www\.veoh\.com/watch/v(?P<id>\d*)'
11
12     _TEST = {
13         u'url': u'http://www.veoh.com/watch/v56314296nk7Zdmz3',
14         u'file': u'56314296.mp4',
15         u'md5': u'620e68e6a3cff80086df3348426c9ca3',
16         u'info_dict': {
17             u'title': u'Straight Backs Are Stronger',
18             u'uploader': u'LUMOback',
19             u'description': u'At LUMOback, we believe straight backs are stronger.  The LUMOback Posture & Movement Sensor:  It gently vibrates when you slouch, inspiring improved posture and mobility.  Use the app to track your data and improve your posture over time. ',
20         }
21     }
22
23     def _real_extract(self, url):
24         mobj = re.match(self._VALID_URL, url)
25         video_id = mobj.group('id')
26         webpage = self._download_webpage(url, video_id)
27
28         m_youtube = re.search(r'http://www\.youtube\.com/v/(.*?)(\&|")', webpage)
29         if m_youtube is not None:
30             youtube_id = m_youtube.group(1)
31             self.to_screen(u'%s: detected Youtube video.' % video_id)
32             return self.url_result(youtube_id, 'Youtube')
33
34         self.report_extraction(video_id)
35         info = self._search_regex(r'videoDetailsJSON = \'({.*?})\';', webpage, 'info')
36         info = json.loads(info)
37         video_url =  info.get('fullPreviewHashHighPath') or info.get('fullPreviewHashLowPath')
38
39         return {'id': info['videoId'], 
40                 'title': info['title'],
41                 'ext': determine_ext(video_url),
42                 'url': video_url,
43                 'uploader': info['username'],
44                 'thumbnail': info.get('highResImage') or info.get('medResImage'),
45                 'description': info['description'],
46                 'view_count': info['views'],
47                 }