# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( urlencode_postdata, sanitized_Request, determine_ext, ExtractorError, int_or_none ) import re class RapidVideoIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?rapidvideo\.(cool|org)/(?P[a-zA-Z0-9-_]+)' _TEST = { 'url': 'http://www.rapidvideo.cool/b667kprndr8w/skyrim_no-audio_1080.mp4.html', 'md5': '99fd03701e3ee9f826ac2fcc11d21c02', 'info_dict': { 'id': 'b667kprndr8w', 'ext': 'mp4', 'title': 'skyrim_no-audio_1080.mp4', } } # Function ref: http://code.activestate.com/recipes/65212/ @staticmethod def _baseN(num, b, numerals="0123456789abcdefghijklmnopqrstuvwxyz"): return ((num == 0) and "0") or (RapidVideoIE._baseN(num // b, b).lstrip("0") + numerals[num % b]) def _decrypt(self, text): match = re.search(r"eval.*?}\('(?P

.*?)(?\d+),(?P\d+),'(?P.*?)(?]+name=["\']hash[^>]+value=["\'](?P[^<]+)["\']', webpage, 'hash', group='hash') req = sanitized_Request('http://www.rapidvideo.cool/%s' % video_id, data=urlencode_postdata({'op': 'download1', 'usr_login': '', 'id': video_id, 'fname': '', 'referer': '', 'hash': hash_, 'imhuman': 'Watch' }) ) req.add_header('Content-type', 'application/x-www-form-urlencoded') req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0') req.add_header('Referer', 'http://www.rapidvideo.cool/%s' % video_id) webpage = self._download_webpage(req, video_id) match = re.search(r'tv_file_name=[\'|"](?P[^\'|"]+).*?file:[\'|"](?P<video>[^\'|"]+)', self._decrypt(webpage)) if match is None: raise ExtractorError('Error while extracting video %s' % video_id, expected=True) title = match.group('title') video_url = match.group('video') return { 'id': video_id, 'title': title, 'url': video_url, 'ext': determine_ext(video_url, 'mp4') }