[pornotube] Adapt to new interface
This commit is contained in:
parent
c3f3b29b92
commit
4237ba10dc
1 changed files with 70 additions and 32 deletions
|
@ -1,56 +1,94 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
import json
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import (
|
||||||
|
compat_urllib_request,
|
||||||
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
compat_urllib_parse,
|
int_or_none,
|
||||||
|
|
||||||
unified_strdate,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class PornotubeIE(InfoExtractor):
|
class PornotubeIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:\w+\.)?pornotube\.com(/c/(?P<channel>[0-9]+))?(/m/(?P<videoid>[0-9]+))(/(?P<title>.+))$'
|
_VALID_URL = r'https?://(?:\w+\.)?pornotube\.com/(?:[^?#]*?)/video/(?P<id>[0-9]+)'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://pornotube.com/c/173/m/1689755/Marilyn-Monroe-Bathing',
|
'url': 'http://www.pornotube.com/orientation/straight/video/4964/title/weird-hot-and-wet-science',
|
||||||
'md5': '374dd6dcedd24234453b295209aa69b6',
|
'md5': '60fc5a4f0d93a97968fc7999d98260c9',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '1689755',
|
'id': '4964',
|
||||||
'ext': 'flv',
|
'ext': 'mp4',
|
||||||
'upload_date': '20090708',
|
'upload_date': '20141203',
|
||||||
'title': 'Marilyn-Monroe-Bathing',
|
'title': 'Weird Hot and Wet Science',
|
||||||
'age_limit': 18
|
'description': 'md5:a8304bef7ef06cb4ab476ca6029b01b0',
|
||||||
|
'categories': ['Adult Humor', 'Blondes'],
|
||||||
|
'uploader': 'Alpha Blue Archives',
|
||||||
|
'thumbnail': 're:^https?://.*\\.jpg$',
|
||||||
|
'timestamp': 1417582800,
|
||||||
|
'age_limit': 18,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
video_id = mobj.group('videoid')
|
# Fetch origin token
|
||||||
video_title = mobj.group('title')
|
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')
|
||||||
|
|
||||||
# Get webpage content
|
# Fetch actual token
|
||||||
webpage = self._download_webpage(url, video_id)
|
token_req_data = {
|
||||||
|
'authenticationSpaceKey': originAuthenticationSpaceKey,
|
||||||
|
'credentials': 'Clip Application',
|
||||||
|
}
|
||||||
|
token_req = compat_urllib_request.Request(
|
||||||
|
'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']
|
||||||
|
|
||||||
# Get the video URL
|
# Get video URL
|
||||||
VIDEO_URL_RE = r'url: "(?P<url>http://video[0-9].pornotube.com/.+\.flv)",'
|
delivery_req = compat_urllib_request.Request(
|
||||||
video_url = self._search_regex(VIDEO_URL_RE, webpage, 'video url')
|
'https://api.aebn.net/delivery/v1/clips/%s/MP4' % video_id)
|
||||||
video_url = compat_urllib_parse.unquote(video_url)
|
delivery_req.add_header('Authorization', token)
|
||||||
|
delivery_info = self._download_json(
|
||||||
|
delivery_req, video_id, note='Downloading delivery information')
|
||||||
|
video_url = delivery_info['mediaUrl']
|
||||||
|
|
||||||
# Get the uploaded date
|
# Get additional info (title etc.)
|
||||||
VIDEO_UPLOADED_RE = r'<div class="video_added_by">Added (?P<date>[0-9\/]+) by'
|
info_req = compat_urllib_request.Request(
|
||||||
upload_date = self._html_search_regex(VIDEO_UPLOADED_RE, webpage, 'upload date', fatal=False)
|
'https://api.aebn.net/content/v1/clips/%s?expand='
|
||||||
if upload_date:
|
'title,description,primaryImageNumber,startSecond,endSecond,'
|
||||||
upload_date = unified_strdate(upload_date)
|
'movie.title,movie.MovieId,movie.boxCoverFront,movie.stars,'
|
||||||
age_limit = self._rta_search(webpage)
|
'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')
|
||||||
|
|
||||||
|
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')]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
'upload_date': upload_date,
|
'title': info['title'],
|
||||||
'title': video_title,
|
'description': info.get('description'),
|
||||||
'ext': 'flv',
|
'timestamp': timestamp,
|
||||||
'format': 'flv',
|
'uploader': uploader,
|
||||||
'age_limit': age_limit,
|
'thumbnail': thumbnail,
|
||||||
|
'categories': categories,
|
||||||
|
'age_limit': 18,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue