3afad41d46
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>
5.5 KiB
5.5 KiB
Restructuration des Downloaders - Résumé
🎯 Objectif Accompli
Restructuration complète du système de downloaders avec une distinction claire entre:
- Sites d'anime (catalogues avec métadonnées)
- Players vidéo (hébergement de fichiers)
📊 Nouvelle Structure
app/downloaders/
├── __init__.py # Factory principal (get_downloader)
├── base.py # BaseDownloader (classe racine)
│
├── anime_sites/ # 🎌 Sites d'anime (4 downloaders)
│ ├── __init__.py # Factory: get_anime_site()
│ ├── base.py # BaseAnimeSite
│ ├── animesama.py # Anime-Sama
│ ├── nekosama.py # Neko-Sama
│ ├── animeultime.py # Anime-Ultime
│ └── vostfree.py # Vostfree
│
└── video_players/ # 🎬 Players vidéo (8 downloaders)
├── __init__.py # Factory: get_video_player()
├── base.py # BaseVideoPlayer
├── doodstream.py # Doodstream
├── sibnet.py # Sibnet
├── vidmoly.py # VidMoly (avec support M3U8 + target_filename)
├── sendvid.py # SendVid (avec target_filename)
├── lpayer.py # Lpayer
├── unfichier.py # 1fichier
├── uptobox.py # Uptobox
└── rapidfile.py # Rapidfile
✨ Changements Clés
1. Classes de Base Spécialisées
BaseVideoPlayer (video_players/base.py):
- Pour les hébergeurs de fichiers vidéo
- Méthode clé:
get_download_link(url, target_filename=None) - Supporte le paramètre optionnel
target_filename(VidMoly, SendVid) - Gère l'extraction d'URL de téléchargement direct
BaseAnimeSite (anime_sites/base.py):
- Pour les sites de streaming anime
- Méthodes clés:
search_anime(query, lang)- Recherche dans le catalogueget_episodes(anime_url, lang)- Liste des épisodesget_anime_metadata(anime_url)- Métadonnées richesget_download_link(url)- URL du player vidéo
2. Preservation des Spécificités
✅ VidMoly: Toutes ses spécificités préservées
- Support M3U8 → MP4 conversion
- Playwright network interception
- Multi-domaines (.biz, .to, .org)
- Paramètre
target_filename
✅ SendVid: Paramètre target_filename préservé
✅ Tous les autres: Aucune modification de fonctionnalité
3. Factory Pattern
Nouveau get_downloader() dans __init__.py:
def get_downloader(url: str):
# Essaye les sites anime d'abord
anime_site = get_anime_site(url)
if anime_site:
return anime_site
# Puis les players vidéo
video_player = get_video_player(url)
if video_player:
return video_player
# Fallback générique
return GenericDownloader()
🧪 Tests
✅ 23/23 tests passants dans tests/test_downloaders.py
✅ Imports mis à jour pour utiliser la nouvelle structure
✅ URL routing correct pour tous les types
📈 Avantages
- Organisation claire: Distinction évidente entre catalogues et hébergeurs
- Maintenabilité: Ajouter un nouveau player ou site est plus intuitif
- Type safety: Héritage spécifique avec méthodes appropriées
- Flexibilité: Support des cas particuliers (VidMoly, SendVid)
- Backward compatibility: L'API principale
get_downloader()fonctionne toujours
🚀 Comment Ajouter un Nouveau Downloader
Nouveau Player Vidéo:
# app/downloaders/video_players/myplayer.py
from .base import BaseVideoPlayer
class MyPlayerDownloader(BaseVideoPlayer):
def can_handle(self, url: str) -> bool:
return "myplayer.com" in url.lower()
async def get_download_link(self, url: str, target_filename: str = None):
# ... extraction logic ...
return download_url, filename
Nouveau Site Anime:
# app/downloaders/anime_sites/mysite.py
from .base import BaseAnimeSite
class MyAnimeSiteDownloader(BaseAnimeSite):
def can_handle(self, url: str) -> bool:
return "myanime.site" in url.lower()
async def search_anime(self, query: str, lang: str = "vostfr"):
# ... search logic ...
return anime_list
async def get_episodes(self, anime_url: str, lang: str = "vostfr"):
# ... episode listing logic ...
return episode_list
async def get_anime_metadata(self, anime_url: str):
# ... metadata extraction ...
return metadata
async def get_download_link(self, url: str):
# ... extract video player URL ...
return player_url, title
✅ Validation
# Tests
pytest tests/test_downloaders.py -v # 23/23 passed ✅
# Imports
from app.downloaders import get_downloader # ✅
from app.downloaders.video_players import BaseVideoPlayer # ✅
from app.downloaders.anime_sites import BaseAnimeSite # ✅
# Routing
get_downloader('https://doodstream.com/e/abc') # → DoodStreamDownloader ✅
get_downloader('https://anime-sama.si/naruto') # → AnimeSamaDownloader ✅
📝 Fichiers Modifiés
Nouveaux: 18 fichiers
- 2 classes de base (base.py)
- 2 __init__.py avec factories
- 12 downloaders migrés
- 2 dossiers (anime_sites/, video_players/)
Supprimés: 12 anciens fichiers dans app/downloaders/
Mis à jour:
app/downloaders/__init__.py(factory principal)tests/test_downloaders.py(imports)
Date: 2026-01-24
Statut: ✅ Terminé et testé
Impact: Aucune rupture de fonctionnalité