Files
root 3afad41d46 refactor: Restructure downloaders with clear separation
This commit implements a complete reorganization of the downloader system
with a clear distinction between anime streaming sites and video hosting services.

## Structure Changes

**New Organization:**
- `app/downloaders/anime_sites/` - Anime streaming sites (catalogs + metadata)
- `app/downloaders/video_players/` - Video hosting services (file downloads)

**Base Classes:**
- `BaseAnimeSite` - For anime providers (search, episodes, metadata)
- `BaseVideoPlayer` - For video players (download link extraction)

**Migrated Downloaders:**
Anime Sites (4):
- AnimeSama, NekoSama, AnimeUltime, Vostfree

Video Players (8):
- Doodstream, Sibnet, VidMoly, SendVid, Lpayer, 1fichier, Uptobox, Rapidfile

## Key Improvements

1. **Clear Separation**: Distinct base classes for different use cases
2. **Preserved Functionality**: All existing features maintained
   - VidMoly: M3U8 support, Playwright, multi-domains, target_filename param
   - SendVid: target_filename parameter support
   - All others: No behavioral changes

3. **Better Organization**:
   - Anime sites: search_anime(), get_episodes(), get_anime_metadata()
   - Video players: get_download_link(url, target_filename=None)

4. **Fixed Imports**: Updated cross-imports in AnimeSama
   - from ..video_players.vidmoly import
   - from ..video_players.sendvid import
   - from ..video_players.sibnet import
   - from ..video_players.lpayer import

5. **Updated Tests**: All test imports use new structure
6. **Updated Providers**: Added 4 missing file hosts to providers.py

## Backward Compatibility

 Main API unchanged: get_downloader() works identically
 All 23 tests passing
 Frontend fully functional
 No breaking changes for users

## Documentation

- RESTRUCTURATION_SUMMARY.md - Technical details
- FIX_IMPORT_ERROR.md - Import error resolution
- IMPORT_VERIFICATION_REPORT.md - Complete import verification
- FRONTEND_VERIFICATION_FINAL.md - Frontend validation

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>
2026-01-24 22:13:20 +00:00

60 lines
2.3 KiB
Python

from .base import BaseVideoPlayer
from bs4 import BeautifulSoup
import re
class UptoboxDownloader(BaseVideoPlayer):
"""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