mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
3.5 KiB
Python
117 lines
3.5 KiB
Python
10 years ago
|
from __future__ import unicode_literals
|
||
|
|
||
|
from .common import InfoExtractor
|
||
6 years ago
|
from ..compat import (
|
||
|
compat_str,
|
||
|
compat_urlparse,
|
||
|
)
|
||
9 years ago
|
from ..utils import (
|
||
|
int_or_none,
|
||
6 years ago
|
unified_timestamp,
|
||
9 years ago
|
)
|
||
10 years ago
|
|
||
|
|
||
|
class BeegIE(InfoExtractor):
|
||
6 years ago
|
_VALID_URL = r'https?://(?:www\.)?beeg\.(?:com|porn(?:/video)?)/(?P<id>\d+)'
|
||
|
_TESTS = [{
|
||
6 years ago
|
# api/v6 v1
|
||
10 years ago
|
'url': 'http://beeg.com/5416503',
|
||
8 years ago
|
'md5': 'a1a1b1a8bc70a89e49ccfd113aed0820',
|
||
10 years ago
|
'info_dict': {
|
||
|
'id': '5416503',
|
||
|
'ext': 'mp4',
|
||
|
'title': 'Sultry Striptease',
|
||
9 years ago
|
'description': 'md5:d22219c09da287c14bed3d6c37ce4bc2',
|
||
|
'timestamp': 1391813355,
|
||
|
'upload_date': '20140207',
|
||
|
'duration': 383,
|
||
|
'tags': list,
|
||
10 years ago
|
'age_limit': 18,
|
||
10 years ago
|
}
|
||
6 years ago
|
}, {
|
||
|
# api/v6 v2
|
||
|
'url': 'https://beeg.com/1941093077?t=911-1391',
|
||
|
'only_matching': True,
|
||
6 years ago
|
}, {
|
||
|
# api/v6 v2 w/o t
|
||
|
'url': 'https://beeg.com/1277207756',
|
||
|
'only_matching': True,
|
||
6 years ago
|
}, {
|
||
|
'url': 'https://beeg.porn/video/5416503',
|
||
|
'only_matching': True,
|
||
|
}, {
|
||
|
'url': 'https://beeg.porn/5416503',
|
||
|
'only_matching': True,
|
||
|
}]
|
||
10 years ago
|
|
||
|
def _real_extract(self, url):
|
||
9 years ago
|
video_id = self._match_id(url)
|
||
10 years ago
|
|
||
9 years ago
|
webpage = self._download_webpage(url, video_id)
|
||
|
|
||
6 years ago
|
beeg_version = self._search_regex(
|
||
|
r'beeg_version\s*=\s*([\da-zA-Z_-]+)', webpage, 'beeg version',
|
||
|
default='1546225636701')
|
||
9 years ago
|
|
||
6 years ago
|
if len(video_id) >= 10:
|
||
6 years ago
|
query = {
|
||
|
'v': 2,
|
||
|
}
|
||
6 years ago
|
qs = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query)
|
||
|
t = qs.get('t', [''])[0].split('-')
|
||
|
if len(t) > 1:
|
||
|
query.update({
|
||
|
's': t[0],
|
||
|
'e': t[1],
|
||
|
})
|
||
6 years ago
|
else:
|
||
|
query = {'v': 1}
|
||
|
|
||
7 years ago
|
for api_path in ('', 'api.'):
|
||
|
video = self._download_json(
|
||
|
'https://%sbeeg.com/api/v6/%s/video/%s'
|
||
|
% (api_path, beeg_version, video_id), video_id,
|
||
6 years ago
|
fatal=api_path == 'api.', query=query)
|
||
7 years ago
|
if video:
|
||
|
break
|
||
9 years ago
|
|
||
9 years ago
|
formats = []
|
||
|
for format_id, video_url in video.items():
|
||
9 years ago
|
if not video_url:
|
||
|
continue
|
||
9 years ago
|
height = self._search_regex(
|
||
|
r'^(\d+)[pP]$', format_id, 'height', default=None)
|
||
|
if not height:
|
||
|
continue
|
||
|
formats.append({
|
||
6 years ago
|
'url': self._proto_relative_url(
|
||
|
video_url.replace('{DATA_MARKERS}', 'data=pc_XX__%s_0' % beeg_version), 'https:'),
|
||
9 years ago
|
'format_id': format_id,
|
||
|
'height': int(height),
|
||
|
})
|
||
10 years ago
|
self._sort_formats(formats)
|
||
10 years ago
|
|
||
9 years ago
|
title = video['title']
|
||
6 years ago
|
video_id = compat_str(video.get('id') or video_id)
|
||
9 years ago
|
display_id = video.get('code')
|
||
|
description = video.get('desc')
|
||
6 years ago
|
series = video.get('ps_name')
|
||
10 years ago
|
|
||
6 years ago
|
timestamp = unified_timestamp(video.get('date'))
|
||
9 years ago
|
duration = int_or_none(video.get('duration'))
|
||
10 years ago
|
|
||
9 years ago
|
tags = [tag.strip() for tag in video['tags'].split(',')] if video.get('tags') else None
|
||
10 years ago
|
|
||
|
return {
|
||
|
'id': video_id,
|
||
9 years ago
|
'display_id': display_id,
|
||
10 years ago
|
'title': title,
|
||
|
'description': description,
|
||
6 years ago
|
'series': series,
|
||
9 years ago
|
'timestamp': timestamp,
|
||
|
'duration': duration,
|
||
|
'tags': tags,
|
||
10 years ago
|
'formats': formats,
|
||
9 years ago
|
'age_limit': self._rta_search(webpage),
|
||
10 years ago
|
}
|