]>
Commit | Line | Data |
---|---|---|
4237ba10 | 1 | import json |
1183b85f PH |
2 | |
3 | from .common import InfoExtractor | |
647a7bf5 | 4 | from ..utils import int_or_none |
1183b85f PH |
5 | |
6 | ||
7 | class PornotubeIE(InfoExtractor): | |
4237ba10 | 8 | _VALID_URL = r'https?://(?:\w+\.)?pornotube\.com/(?:[^?#]*?)/video/(?P<id>[0-9]+)' |
6f5ac90c | 9 | _TEST = { |
4237ba10 PH |
10 | 'url': 'http://www.pornotube.com/orientation/straight/video/4964/title/weird-hot-and-wet-science', |
11 | 'md5': '60fc5a4f0d93a97968fc7999d98260c9', | |
51ed9fce | 12 | 'info_dict': { |
4237ba10 PH |
13 | 'id': '4964', |
14 | 'ext': 'mp4', | |
15 | 'upload_date': '20141203', | |
16 | 'title': 'Weird Hot and Wet Science', | |
17 | 'description': 'md5:a8304bef7ef06cb4ab476ca6029b01b0', | |
18 | 'categories': ['Adult Humor', 'Blondes'], | |
19 | 'uploader': 'Alpha Blue Archives', | |
ec85ded8 | 20 | 'thumbnail': r're:^https?://.*\.jpg$', |
4237ba10 PH |
21 | 'timestamp': 1417582800, |
22 | 'age_limit': 18, | |
add96eb9 | 23 | }, |
6f5ac90c | 24 | } |
1183b85f PH |
25 | |
26 | def _real_extract(self, url): | |
4237ba10 | 27 | video_id = self._match_id(url) |
1183b85f | 28 | |
647a7bf5 S |
29 | token = self._download_json( |
30 | 'https://api.aebn.net/auth/v2/origins/authenticate', | |
31 | video_id, note='Downloading token', | |
add96eb9 | 32 | data=json.dumps({'credentials': 'Clip Application'}).encode(), |
647a7bf5 S |
33 | headers={ |
34 | 'Content-Type': 'application/json', | |
35 | 'Origin': 'http://www.pornotube.com', | |
36 | })['tokenKey'] | |
4237ba10 | 37 | |
647a7bf5 | 38 | video_url = self._download_json( |
add96eb9 | 39 | f'https://api.aebn.net/delivery/v1/clips/{video_id}/MP4', |
647a7bf5 S |
40 | video_id, note='Downloading delivery information', |
41 | headers={'Authorization': token})['mediaUrl'] | |
1183b85f | 42 | |
647a7bf5 S |
43 | FIELDS = ( |
44 | 'title', 'description', 'startSecond', 'endSecond', 'publishDate', | |
add96eb9 | 45 | 'studios{name}', 'categories{name}', 'movieId', 'primaryImageNumber', |
647a7bf5 | 46 | ) |
1183b85f | 47 | |
4237ba10 | 48 | info = self._download_json( |
add96eb9 | 49 | 'https://api.aebn.net/content/v2/clips/{}?fields={}'.format(video_id, ','.join(FIELDS)), video_id, |
647a7bf5 S |
50 | note='Downloading metadata', |
51 | headers={'Authorization': token}) | |
52 | ||
53 | if isinstance(info, list): | |
54 | info = info[0] | |
55 | ||
56 | title = info['title'] | |
1183b85f | 57 | |
4237ba10 PH |
58 | timestamp = int_or_none(info.get('publishDate'), scale=1000) |
59 | uploader = info.get('studios', [{}])[0].get('name') | |
647a7bf5 S |
60 | movie_id = info.get('movieId') |
61 | primary_image_number = info.get('primaryImageNumber') | |
62 | thumbnail = None | |
63 | if movie_id and primary_image_number: | |
64 | thumbnail = 'http://pic.aebn.net/dis/t/%s/%s_%08d.jpg' % ( | |
65 | movie_id, movie_id, primary_image_number) | |
66 | start = int_or_none(info.get('startSecond')) | |
67 | end = int_or_none(info.get('endSecond')) | |
68 | duration = end - start if start and end else None | |
69 | categories = [c['name'] for c in info.get('categories', []) if c.get('name')] | |
1183b85f | 70 | |
51ed9fce PH |
71 | return { |
72 | 'id': video_id, | |
73 | 'url': video_url, | |
647a7bf5 | 74 | 'title': title, |
4237ba10 | 75 | 'description': info.get('description'), |
647a7bf5 | 76 | 'duration': duration, |
4237ba10 PH |
77 | 'timestamp': timestamp, |
78 | 'uploader': uploader, | |
79 | 'thumbnail': thumbnail, | |
80 | 'categories': categories, | |
81 | 'age_limit': 18, | |
51ed9fce | 82 | } |