]>
Commit | Line | Data |
---|---|---|
c11a0611 PH |
1 | from __future__ import unicode_literals |
2 | ||
8e4e89f1 JMF |
3 | import re |
4 | import json | |
5 | ||
6 | from .common import InfoExtractor | |
1cc79574 | 7 | from ..compat import ( |
8e4e89f1 | 8 | compat_urlparse, |
1cc79574 PH |
9 | ) |
10 | from ..utils import ( | |
8e4e89f1 | 11 | clean_html, |
1cc79574 | 12 | get_element_by_id, |
8e4e89f1 JMF |
13 | ) |
14 | ||
c11a0611 | 15 | |
8e4e89f1 | 16 | class VeeHDIE(InfoExtractor): |
c0ade33e | 17 | _VALID_URL = r'https?://veehd\.com/video/(?P<id>\d+)' |
8e4e89f1 JMF |
18 | |
19 | _TEST = { | |
c11a0611 | 20 | 'url': 'http://veehd.com/video/4686958', |
c11a0611 | 21 | 'info_dict': { |
df53b635 PH |
22 | 'id': '4686958', |
23 | 'ext': 'mp4', | |
c11a0611 PH |
24 | 'title': 'Time Lapse View from Space ( ISS)', |
25 | 'uploader_id': 'spotted', | |
26 | 'description': 'md5:f0094c4cf3a72e22bc4e4239ef767ad7', | |
8e4e89f1 JMF |
27 | }, |
28 | } | |
29 | ||
30 | def _real_extract(self, url): | |
1cc79574 | 31 | video_id = self._match_id(url) |
8e4e89f1 | 32 | |
c11a0611 PH |
33 | # VeeHD seems to send garbage on the first request. |
34 | # See https://github.com/rg3/youtube-dl/issues/2102 | |
35 | self._download_webpage(url, video_id, 'Requesting webpage') | |
8e4e89f1 | 36 | webpage = self._download_webpage(url, video_id) |
c11a0611 PH |
37 | player_path = self._search_regex( |
38 | r'\$\("#playeriframe"\).attr\({src : "(.+?)"', | |
39 | webpage, 'player path') | |
8e4e89f1 | 40 | player_url = compat_urlparse.urljoin(url, player_path) |
c11a0611 PH |
41 | |
42 | self._download_webpage(player_url, video_id, 'Requesting player page') | |
43 | player_page = self._download_webpage( | |
44 | player_url, video_id, 'Downloading player page') | |
45 | config_json = self._search_regex( | |
46 | r'value=\'config=({.+?})\'', player_page, 'config json') | |
8e4e89f1 JMF |
47 | config = json.loads(config_json) |
48 | ||
49 | video_url = compat_urlparse.unquote(config['clip']['url']) | |
50 | title = clean_html(get_element_by_id('videoName', webpage).rpartition('|')[0]) | |
51 | uploader_id = self._html_search_regex(r'<a href="/profile/\d+">(.+?)</a>', | |
9e1a5b84 | 52 | webpage, 'uploader') |
8e4e89f1 | 53 | thumbnail = self._search_regex(r'<img id="veehdpreview" src="(.+?)"', |
9e1a5b84 | 54 | webpage, 'thumbnail') |
8e4e89f1 | 55 | description = self._html_search_regex(r'<td class="infodropdown".*?<div>(.*?)<ul', |
9e1a5b84 | 56 | webpage, 'description', flags=re.DOTALL) |
8e4e89f1 JMF |
57 | |
58 | return { | |
59 | '_type': 'video', | |
60 | 'id': video_id, | |
61 | 'title': title, | |
62 | 'url': video_url, | |
63 | 'ext': 'mp4', | |
64 | 'uploader_id': uploader_id, | |
65 | 'thumbnail': thumbnail, | |
66 | 'description': description, | |
67 | } |