]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/veehd.py
3a99a29c6520ba6824a9060264d678a5cf31e6e6
[youtubedl] / youtube_dl / extractor / veehd.py
1 import re
2 import json
3
4 from .common import InfoExtractor
5 from ..utils import (
6 compat_urlparse,
7 get_element_by_id,
8 clean_html,
9 )
10
11 class VeeHDIE(InfoExtractor):
12 _VALID_URL = r'https?://veehd.com/video/(?P<id>\d+)'
13
14 _TEST = {
15 u'url': u'http://veehd.com/video/4686958',
16 u'file': u'4686958.mp4',
17 u'info_dict': {
18 u'title': u'Time Lapse View from Space ( ISS)',
19 u'uploader_id': u'spotted',
20 u'description': u'md5:f0094c4cf3a72e22bc4e4239ef767ad7',
21 },
22 }
23
24 def _real_extract(self, url):
25 mobj = re.match(self._VALID_URL, url)
26 video_id = mobj.group('id')
27
28 webpage = self._download_webpage(url, video_id)
29 player_path = self._search_regex(r'\$\("#playeriframe"\).attr\({src : "(.+?)"',
30 webpage, u'player path')
31 player_url = compat_urlparse.urljoin(url, player_path)
32 player_page = self._download_webpage(player_url, video_id,
33 u'Downloading player page')
34 config_json = self._search_regex(r'value=\'config=({.+?})\'',
35 player_page, u'config json')
36 config = json.loads(config_json)
37
38 video_url = compat_urlparse.unquote(config['clip']['url'])
39 title = clean_html(get_element_by_id('videoName', webpage).rpartition('|')[0])
40 uploader_id = self._html_search_regex(r'<a href="/profile/\d+">(.+?)</a>',
41 webpage, u'uploader')
42 thumbnail = self._search_regex(r'<img id="veehdpreview" src="(.+?)"',
43 webpage, u'thumbnail')
44 description = self._html_search_regex(r'<td class="infodropdown".*?<div>(.*?)<ul',
45 webpage, u'description', flags=re.DOTALL)
46
47 return {
48 '_type': 'video',
49 'id': video_id,
50 'title': title,
51 'url': video_url,
52 'ext': 'mp4',
53 'uploader_id': uploader_id,
54 'thumbnail': thumbnail,
55 'description': description,
56 }