]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/vbox7.py
[tapely] Remove extractor. It's shut down
[yt-dlp.git] / youtube_dl / extractor / vbox7.py
CommitLineData
50451f2a
JMF
1# encoding: utf-8
2from __future__ import unicode_literals
3
01c10ca2 4from .common import InfoExtractor
6e6bc8da 5from ..compat import compat_urlparse
1cc79574 6from ..utils import (
01c10ca2 7 ExtractorError,
5c2266df 8 sanitized_Request,
6e6bc8da 9 urlencode_postdata,
01c10ca2
PH
10)
11
12
13class Vbox7IE(InfoExtractor):
5886b38d 14 _VALID_URL = r'https?://(?:www\.)?vbox7\.com/play:(?P<id>[^/]+)'
6f5ac90c 15 _TEST = {
50451f2a
JMF
16 'url': 'http://vbox7.com/play:249bb972c2',
17 'md5': '99f65c0c9ef9b682b97313e052734c3f',
18 'info_dict': {
19 'id': '249bb972c2',
8e6f8051 20 'ext': 'mp4',
50451f2a
JMF
21 'title': 'Смях! Чудо - чист за секунди - Скрита камера',
22 },
6f5ac90c 23 }
01c10ca2 24
50451f2a 25 def _real_extract(self, url):
1cc79574 26 video_id = self._match_id(url)
01c10ca2 27
4af98ecd
YCH
28 # need to get the page 3 times for the correct jsSecretToken cookie
29 # which is necessary for the correct title
30 def get_session_id():
31 redirect_page = self._download_webpage(url, video_id)
32 session_id_url = self._search_regex(
33 r'var\s*url\s*=\s*\'([^\']+)\';', redirect_page,
34 'session id url')
35 self._download_webpage(
36 compat_urlparse.urljoin(url, session_id_url), video_id,
37 'Getting session id')
38
39 get_session_id()
40 get_session_id()
41
42 webpage = self._download_webpage(url, video_id,
9e1a5b84 43 'Downloading redirect page')
01c10ca2
PH
44
45 title = self._html_search_regex(r'<title>(.*)</title>',
9e1a5b84 46 webpage, 'title').split('/')[0].strip()
01c10ca2 47
611c1dd9 48 info_url = 'http://vbox7.com/play/magare.do'
6e6bc8da 49 data = urlencode_postdata({'as3': '1', 'vid': video_id})
5c2266df 50 info_request = sanitized_Request(info_url, data)
01c10ca2 51 info_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
50451f2a 52 info_response = self._download_webpage(info_request, video_id, 'Downloading info webpage')
01c10ca2 53 if info_response is None:
50451f2a 54 raise ExtractorError('Unable to extract the media url')
01c10ca2
PH
55 (final_url, thumbnail_url) = map(lambda x: x.split('=')[1], info_response.split('&'))
56
50451f2a
JMF
57 return {
58 'id': video_id,
59 'url': final_url,
50451f2a 60 'title': title,
01c10ca2 61 'thumbnail': thumbnail_url,
50451f2a 62 }