2014-08-23 23:16:24 -05:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2014-12-12 12:44:25 -06:00
|
|
|
import json
|
2013-06-23 15:13:32 -05:00
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
2014-12-12 12:44:25 -06:00
|
|
|
int_or_none,
|
2015-11-21 10:18:17 -06:00
|
|
|
sanitized_Request,
|
2013-06-23 15:13:32 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class PornotubeIE(InfoExtractor):
|
2014-12-12 12:44:25 -06:00
|
|
|
_VALID_URL = r'https?://(?:\w+\.)?pornotube\.com/(?:[^?#]*?)/video/(?P<id>[0-9]+)'
|
2013-06-27 13:46:46 -05:00
|
|
|
_TEST = {
|
2014-12-12 12:44:25 -06:00
|
|
|
'url': 'http://www.pornotube.com/orientation/straight/video/4964/title/weird-hot-and-wet-science',
|
|
|
|
'md5': '60fc5a4f0d93a97968fc7999d98260c9',
|
2014-08-23 23:16:24 -05:00
|
|
|
'info_dict': {
|
2014-12-12 12:44:25 -06:00
|
|
|
'id': '4964',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'upload_date': '20141203',
|
|
|
|
'title': 'Weird Hot and Wet Science',
|
|
|
|
'description': 'md5:a8304bef7ef06cb4ab476ca6029b01b0',
|
|
|
|
'categories': ['Adult Humor', 'Blondes'],
|
|
|
|
'uploader': 'Alpha Blue Archives',
|
|
|
|
'thumbnail': 're:^https?://.*\\.jpg$',
|
|
|
|
'timestamp': 1417582800,
|
|
|
|
'age_limit': 18,
|
2013-06-27 13:46:46 -05:00
|
|
|
}
|
|
|
|
}
|
2013-06-23 15:13:32 -05:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2014-12-12 12:44:25 -06:00
|
|
|
video_id = self._match_id(url)
|
2013-06-23 15:13:32 -05:00
|
|
|
|
2014-12-12 12:44:25 -06:00
|
|
|
# Fetch origin token
|
|
|
|
js_config = self._download_webpage(
|
|
|
|
'http://www.pornotube.com/assets/src/app/config.js', video_id,
|
|
|
|
note='Download JS config')
|
|
|
|
originAuthenticationSpaceKey = self._search_regex(
|
|
|
|
r"constant\('originAuthenticationSpaceKey',\s*'([^']+)'",
|
|
|
|
js_config, 'originAuthenticationSpaceKey')
|
|
|
|
|
|
|
|
# Fetch actual token
|
|
|
|
token_req_data = {
|
|
|
|
'authenticationSpaceKey': originAuthenticationSpaceKey,
|
|
|
|
'credentials': 'Clip Application',
|
|
|
|
}
|
2015-11-21 10:18:17 -06:00
|
|
|
token_req = sanitized_Request(
|
2014-12-12 12:44:25 -06:00
|
|
|
'https://api.aebn.net/auth/v1/token/primal',
|
|
|
|
data=json.dumps(token_req_data).encode('utf-8'))
|
|
|
|
token_req.add_header('Content-Type', 'application/json')
|
|
|
|
token_req.add_header('Origin', 'http://www.pornotube.com')
|
|
|
|
token_answer = self._download_json(
|
|
|
|
token_req, video_id, note='Requesting primal token')
|
|
|
|
token = token_answer['tokenKey']
|
2013-06-23 15:13:32 -05:00
|
|
|
|
2014-12-12 12:44:25 -06:00
|
|
|
# Get video URL
|
2015-11-21 10:18:17 -06:00
|
|
|
delivery_req = sanitized_Request(
|
2014-12-12 12:44:25 -06:00
|
|
|
'https://api.aebn.net/delivery/v1/clips/%s/MP4' % video_id)
|
|
|
|
delivery_req.add_header('Authorization', token)
|
|
|
|
delivery_info = self._download_json(
|
|
|
|
delivery_req, video_id, note='Downloading delivery information')
|
|
|
|
video_url = delivery_info['mediaUrl']
|
2013-06-23 15:13:32 -05:00
|
|
|
|
2014-12-12 12:44:25 -06:00
|
|
|
# Get additional info (title etc.)
|
2015-11-21 10:18:17 -06:00
|
|
|
info_req = sanitized_Request(
|
2014-12-12 12:44:25 -06:00
|
|
|
'https://api.aebn.net/content/v1/clips/%s?expand='
|
|
|
|
'title,description,primaryImageNumber,startSecond,endSecond,'
|
|
|
|
'movie.title,movie.MovieId,movie.boxCoverFront,movie.stars,'
|
|
|
|
'movie.studios,stars.name,studios.name,categories.name,'
|
|
|
|
'clipActive,movieActive,publishDate,orientations' % video_id)
|
|
|
|
info_req.add_header('Authorization', token)
|
|
|
|
info = self._download_json(
|
|
|
|
info_req, video_id, note='Downloading metadata')
|
2013-06-23 15:13:32 -05:00
|
|
|
|
2014-12-12 12:44:25 -06:00
|
|
|
timestamp = int_or_none(info.get('publishDate'), scale=1000)
|
|
|
|
uploader = info.get('studios', [{}])[0].get('name')
|
|
|
|
movie_id = info['movie']['movieId']
|
|
|
|
thumbnail = 'http://pic.aebn.net/dis/t/%s/%s_%08d.jpg' % (
|
|
|
|
movie_id, movie_id, info['primaryImageNumber'])
|
|
|
|
categories = [c['name'] for c in info.get('categories')]
|
2013-06-23 15:13:32 -05:00
|
|
|
|
2014-08-23 23:16:24 -05:00
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'url': video_url,
|
2014-12-12 12:44:25 -06:00
|
|
|
'title': info['title'],
|
|
|
|
'description': info.get('description'),
|
|
|
|
'timestamp': timestamp,
|
|
|
|
'uploader': uploader,
|
|
|
|
'thumbnail': thumbnail,
|
|
|
|
'categories': categories,
|
|
|
|
'age_limit': 18,
|
2014-08-23 23:16:24 -05:00
|
|
|
}
|