feat: Add SendVid downloader support
Add complete support for SendVid video hosting service used by Anime-Sama for anime series like Hell's Paradise. Changes: - Create SendVidDownloader class with proper headers to avoid 403 errors - Add SendVid detection and handling in AnimeSamaDownloader - Update download_manager to include SendVid-specific headers - Support custom episode naming (e.g., "Hells Paradise - Episode 01.mp4") Technical details: - SendVid embed pages require User-Agent and Referer headers - Direct MP4 URLs extracted from <source> tags with IP/time-based parameters - Tested with Hell's Paradise Episode 01 (7MB, 24min, 1280x720) Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
from .base import BaseDownloader
|
||||
from bs4 import BeautifulSoup
|
||||
import re
|
||||
|
||||
|
||||
class UptoboxDownloader(BaseDownloader):
|
||||
"""Downloader for uptobox.com"""
|
||||
|
||||
BASE_DOMAINS = ["uptobox.com", "uptobox.fr"]
|
||||
|
||||
def can_handle(self, url: str) -> bool:
|
||||
return any(domain in url.lower() for domain in self.BASE_DOMAINS)
|
||||
|
||||
async def get_download_link(self, url: str) -> tuple[str, str]:
|
||||
"""Extract direct download link from uptobox"""
|
||||
try:
|
||||
response = await self.client.get(url, follow_redirects=True)
|
||||
soup = BeautifulSoup(response.text, 'lxml')
|
||||
|
||||
# Method 1: Look for direct download button/link
|
||||
download_btn = soup.find('a', {'id': 'directDownload'}) or soup.find('a', class_='download-btn')
|
||||
if download_btn and download_btn.get('href'):
|
||||
href = download_btn['href']
|
||||
filename = self._extract_filename_from_url(url) or "uptobox_file"
|
||||
return href, filename
|
||||
|
||||
# Method 2: Look for any download link in page
|
||||
links = soup.find_all('a', href=True)
|
||||
for link in links:
|
||||
href = link['href']
|
||||
text = link.get_text().lower()
|
||||
if any(keyword in text for keyword in ['download', 'télécharger', 'ddl']):
|
||||
if href.startswith('http'):
|
||||
filename = self._extract_filename_from_url(url) or "uptobox_file"
|
||||
return href, filename
|
||||
|
||||
# Method 3: Return the original URL (uptobox handles downloads directly)
|
||||
filename = self._extract_filename_from_url(url) or "uptobox_file"
|
||||
return url, filename
|
||||
|
||||
except Exception as e:
|
||||
raise Exception(f"Error extracting Uptobox link: {str(e)}")
|
||||
|
||||
def _extract_filename_from_url(self, url: str) -> str | None:
|
||||
"""Try to extract filename from URL"""
|
||||
# Look for filename parameter in URL
|
||||
match = re.search(r'[&?]filename=([^&]+)', url)
|
||||
if match:
|
||||
from urllib.parse import unquote
|
||||
return unquote(match.group(1))
|
||||
|
||||
# Extract from path
|
||||
parts = url.split('/')
|
||||
if len(parts) > 0:
|
||||
last_part = parts[-1]
|
||||
if '.' in last_part:
|
||||
return last_part
|
||||
|
||||
return None
|
||||
Reference in New Issue
Block a user