mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-04 12:12:32 -05:00
tests + hatch fmt --check
passing
This commit is contained in:
parent
ac857fd120
commit
07cc6d2828
1 changed files with 55 additions and 40 deletions
|
@ -4,19 +4,35 @@
|
||||||
|
|
||||||
|
|
||||||
class VRPornIE(InfoExtractor):
|
class VRPornIE(InfoExtractor):
|
||||||
_VALID_URL = r"https?://(?:www\.)?vrporn\.com/(?P<display_id>.+)/"
|
_VALID_URL = r'https?://(?:www\.)?vrporn\.com/(?P<display_id>.+)/'
|
||||||
_LOGIN_URL = "https://vrporn.com/api/playa/v2/auth/sign-in-password"
|
_LOGIN_URL = 'https://vrporn.com/api/playa/v2/auth/sign-in-password'
|
||||||
_SINGLE_VIDEO_URL = "https://vrporn.com/api/playa/v2/video/"
|
_SINGLE_VIDEO_URL = 'https://vrporn.com/api/playa/v2/video/'
|
||||||
_NETRC_MACHINE = "vrporn"
|
_NETRC_MACHINE = 'vrporn'
|
||||||
_USERTOKEN = None
|
_USERTOKEN = None
|
||||||
_TESTS = [
|
_TESTS = [
|
||||||
{
|
{
|
||||||
"url": "https://vrporn.com/milkmans-diaries/",
|
'url': 'https://vrporn.com/milkmans-diaries/',
|
||||||
"only_matching": True,
|
'md5': 'd50ab6c2b4adbe4fcd3f46e40984c7c8',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '865690',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'duration': 60,
|
||||||
|
'age_limit': 18,
|
||||||
|
'title': "Milkman's Diaries",
|
||||||
|
'display_id': 'milkmans-diaries',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "https://vrporn.com/what-a-fellin/",
|
'url': 'https://vrporn.com/what-a-fellin/',
|
||||||
"only_matching": True,
|
'md5': 'eebd569dfea62c398947dbdc422ae0f0',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '852931',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'duration': 60,
|
||||||
|
'age_limit': 18,
|
||||||
|
'title': 'What A Feelin',
|
||||||
|
'display_id': 'what-a-fellin',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -24,77 +40,76 @@ class VRPornIE(InfoExtractor):
|
||||||
user_data = self._download_json(
|
user_data = self._download_json(
|
||||||
self._LOGIN_URL,
|
self._LOGIN_URL,
|
||||||
None,
|
None,
|
||||||
note="Logging in",
|
note='Logging in',
|
||||||
data=json.dumps(
|
data=json.dumps(
|
||||||
{
|
{
|
||||||
"login": username,
|
'login': username,
|
||||||
"password": password,
|
'password': password,
|
||||||
}
|
},
|
||||||
).encode(),
|
).encode(),
|
||||||
headers={
|
headers={
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self._USERTOKEN = user_data["data"]["access_token"]
|
self._USERTOKEN = user_data['data']['access_token']
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = self._match_valid_url(url)
|
mobj = self._match_valid_url(url)
|
||||||
display_id = mobj.group("display_id")
|
display_id = mobj.group('display_id')
|
||||||
|
|
||||||
webpage, _ = self._download_webpage_handle(url, display_id)
|
webpage, _ = self._download_webpage_handle(url, display_id)
|
||||||
|
|
||||||
video_id = self._search_regex(
|
video_id = self._search_regex(
|
||||||
r"shortlink.+href=[\'\"]https://vrporn\.com/\?p=([0-9]+)[\'\"]",
|
r"shortlink.+href=[\'\"]https://vrporn\.com/\?p=([0-9]+)[\'\"]",
|
||||||
webpage,
|
webpage,
|
||||||
"id",
|
'id',
|
||||||
)
|
)
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
}
|
}
|
||||||
if self._USERTOKEN:
|
if self._USERTOKEN:
|
||||||
headers.update(
|
headers.update(
|
||||||
{
|
{
|
||||||
"Authorization": f"Bearer {self._USERTOKEN}",
|
'Authorization': f'Bearer {self._USERTOKEN}',
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
video_data = self._download_json(
|
video_data = self._download_json(
|
||||||
self._SINGLE_VIDEO_URL + video_id,
|
self._SINGLE_VIDEO_URL + video_id,
|
||||||
None,
|
None,
|
||||||
query={"asd": "asd"},
|
query={'asd': 'asd'},
|
||||||
note="fetching formats",
|
note='fetching formats',
|
||||||
headers=headers,
|
headers=headers,
|
||||||
)
|
)
|
||||||
|
|
||||||
title = video_data["data"]["title"]
|
title = video_data['data']['title']
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
|
|
||||||
duration = ""
|
duration = ''
|
||||||
|
|
||||||
for detail in video_data["data"]["details"]:
|
for detail in video_data['data']['details']:
|
||||||
type = detail["type"]
|
video_type = detail['type']
|
||||||
duration = detail["duration_seconds"]
|
duration = detail['duration_seconds']
|
||||||
|
|
||||||
for link in detail["links"]:
|
for link in detail['links']:
|
||||||
if link["is_download"]:
|
if link['is_download']:
|
||||||
formats.append(
|
formats.append(
|
||||||
{
|
{
|
||||||
"url": link["url"],
|
'url': link['url'],
|
||||||
"format_id": f'{type}-{link["quality_name"]}-{link["stereo"]}-{link["projection"]}',
|
'format_id': f'{video_type}-{link["quality_name"]}-{link["stereo"]}-{link["projection"]}',
|
||||||
"quality": link["quality_name"],
|
'quality': link['quality_name'],
|
||||||
"resolution": link["quality_name"],
|
'resolution': link['quality_name'],
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"id": video_id,
|
'id': video_id,
|
||||||
"display_id": display_id,
|
'display_id': display_id,
|
||||||
"title": title,
|
'title': title,
|
||||||
"duration": duration,
|
'duration': duration,
|
||||||
"formats": formats,
|
'formats': formats,
|
||||||
"age_limit": 18,
|
'age_limit': 18,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue