]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/veoh.py
debian/NEWS: Write news about new behavior of youtube-dl.
[youtubedl] / youtube_dl / extractor / veoh.py
1 from __future__ import unicode_literals
2
3 import re
4 import json
5
6 from .common import InfoExtractor
7
8
9 class VeohIE(InfoExtractor):
10 _VALID_URL = r'http://(?:www\.)?veoh\.com/(?:watch|iphone/#_Watch)/v(?P<id>\d*)'
11
12 _TEST = {
13 'url': 'http://www.veoh.com/watch/v56314296nk7Zdmz3',
14 'file': '56314296.mp4',
15 'md5': '620e68e6a3cff80086df3348426c9ca3',
16 'info_dict': {
17 'title': 'Straight Backs Are Stronger',
18 'uploader': 'LUMOback',
19 'description': '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('%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 {
40 'id': info['videoId'],
41 'title': info['title'],
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 }