1 from __future__ import unicode_literals
5 from .common import InfoExtractor
12 class PornotubeIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:\w+\.)?pornotube\.com/(?:[^?#]*?)/video/(?P<id>[0-9]+)'
15 'url': 'http://www.pornotube.com/orientation/straight/video/4964/title/weird-hot-and-wet-science',
16 'md5': '60fc5a4f0d93a97968fc7999d98260c9',
20 'upload_date': '20141203',
21 'title': 'Weird Hot and Wet Science',
22 'description': 'md5:a8304bef7ef06cb4ab476ca6029b01b0',
23 'categories': ['Adult Humor', 'Blondes'],
24 'uploader': 'Alpha Blue Archives',
25 'thumbnail': 're:^https?://.*\\.jpg$',
26 'timestamp': 1417582800,
31 def _real_extract(self, url):
32 video_id = self._match_id(url)
35 js_config = self._download_webpage(
36 'http://www.pornotube.com/assets/src/app/config.js', video_id,
37 note='Download JS config')
38 originAuthenticationSpaceKey = self._search_regex(
39 r"constant\('originAuthenticationSpaceKey',\s*'([^']+)'",
40 js_config, 'originAuthenticationSpaceKey')
44 'authenticationSpaceKey': originAuthenticationSpaceKey,
45 'credentials': 'Clip Application',
47 token_req = sanitized_Request(
48 'https://api.aebn.net/auth/v1/token/primal',
49 data=json.dumps(token_req_data).encode('utf-8'))
50 token_req.add_header('Content-Type', 'application/json')
51 token_req.add_header('Origin', 'http://www.pornotube.com')
52 token_answer = self._download_json(
53 token_req, video_id, note='Requesting primal token')
54 token = token_answer['tokenKey']
57 delivery_req = sanitized_Request(
58 'https://api.aebn.net/delivery/v1/clips/%s/MP4' % video_id)
59 delivery_req.add_header('Authorization', token)
60 delivery_info = self._download_json(
61 delivery_req, video_id, note='Downloading delivery information')
62 video_url = delivery_info['mediaUrl']
64 # Get additional info (title etc.)
65 info_req = sanitized_Request(
66 'https://api.aebn.net/content/v1/clips/%s?expand='
67 'title,description,primaryImageNumber,startSecond,endSecond,'
68 'movie.title,movie.MovieId,movie.boxCoverFront,movie.stars,'
69 'movie.studios,stars.name,studios.name,categories.name,'
70 'clipActive,movieActive,publishDate,orientations' % video_id)
71 info_req.add_header('Authorization', token)
72 info = self._download_json(
73 info_req, video_id, note='Downloading metadata')
75 timestamp = int_or_none(info.get('publishDate'), scale=1000)
76 uploader = info.get('studios', [{}])[0].get('name')
77 movie_id = info['movie']['movieId']
78 thumbnail = 'http://pic.aebn.net/dis/t/%s/%s_%08d.jpg' % (
79 movie_id, movie_id, info['primaryImageNumber'])
80 categories = [c['name'] for c in info.get('categories')]
85 'title': info['title'],
86 'description': info.get('description'),
87 'timestamp': timestamp,
89 'thumbnail': thumbnail,
90 'categories': categories,