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