mirror of
https://github.com/UrloMythus/UnHided.git
synced 2026-06-10 09:10:23 +00:00
new version
This commit is contained in:
@@ -1,22 +1,39 @@
|
||||
import re
|
||||
from typing import Dict
|
||||
from typing import Dict, Any
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from curl_cffi.requests import AsyncSession
|
||||
|
||||
from mediaflow_proxy.extractors.base import BaseExtractor, ExtractorError
|
||||
|
||||
|
||||
class UqloadExtractor(BaseExtractor):
|
||||
"""Uqload URL extractor."""
|
||||
"""Uqload URL extractor.
|
||||
|
||||
async def extract(self, url: str, **kwargs) -> Dict[str, str]:
|
||||
"""Extract Uqload URL."""
|
||||
response = await self._make_request(url)
|
||||
Uses curl_cffi + Chrome impersonation to handle Cloudflare protection.
|
||||
Follows redirects automatically (uqload.bz/co/io all redirect to uqload.is).
|
||||
"""
|
||||
|
||||
video_url_match = re.search(r'sources: \["(.*?)"]', response.text)
|
||||
async def extract(self, url: str, **kwargs) -> Dict[str, Any]:
|
||||
proxy = self._get_proxy(url)
|
||||
async with AsyncSession() as session:
|
||||
response = await session.get(
|
||||
url,
|
||||
impersonate="chrome",
|
||||
timeout=30,
|
||||
allow_redirects=True,
|
||||
**({"proxy": proxy} if proxy else {}),
|
||||
)
|
||||
|
||||
if response.status_code >= 400:
|
||||
raise ExtractorError(f"HTTP {response.status_code} while fetching {url}")
|
||||
|
||||
video_url_match = re.search(r'sources:\s*\["(https?://[^"]+)"', response.text)
|
||||
if not video_url_match:
|
||||
raise ExtractorError("Failed to extract video URL")
|
||||
raise ExtractorError("Uqload: video URL not found in page source")
|
||||
|
||||
self.base_headers["referer"] = urljoin(url, "/")
|
||||
final_url = str(response.url)
|
||||
self.base_headers["referer"] = urljoin(final_url, "/")
|
||||
return {
|
||||
"destination_url": video_url_match.group(1),
|
||||
"request_headers": self.base_headers,
|
||||
|
||||
Reference in New Issue
Block a user