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>
86 lines
3.2 KiB
Python
86 lines
3.2 KiB
Python
from .base import BaseVideoPlayer
|
|
from bs4 import BeautifulSoup
|
|
import re
|
|
from urllib.parse import urljoin
|
|
|
|
|
|
class SibnetDownloader(BaseVideoPlayer):
|
|
"""Downloader for sibnet.ru video player"""
|
|
|
|
def can_handle(self, url: str) -> bool:
|
|
return 'sibnet.ru' in url.lower()
|
|
|
|
async def get_download_link(self, url: str, target_filename: str = None) -> tuple[str, str]:
|
|
"""
|
|
Extract download link from Sibnet video page
|
|
Sibnet uses a JavaScript player with direct MP4 links
|
|
"""
|
|
try:
|
|
print(f"[SIBNET] Extracting link from: {url}")
|
|
|
|
# If it's already a direct MP4 URL, return it as-is
|
|
if url.endswith('.mp4'):
|
|
print(f"[SIBNET] Direct MP4 URL detected")
|
|
filename = url.split('/')[-1] or "sibnet_video.mp4"
|
|
return url, filename
|
|
|
|
# Fetch the video page
|
|
response = await self.client.get(
|
|
url,
|
|
headers={
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36'
|
|
}
|
|
)
|
|
|
|
# Parse HTML to find the video source
|
|
soup = BeautifulSoup(response.text, 'lxml')
|
|
|
|
# Look for player.src in JavaScript
|
|
# Pattern: player.src([{src: "/v/HASH/ID.mp4", type: "video/mp4"},]);
|
|
script_tags = soup.find_all('script')
|
|
video_url = None
|
|
|
|
for script in script_tags:
|
|
if script.string:
|
|
# Look for player.src pattern
|
|
match = re.search(r'player\.src\(\[\{src:\s*"([^"]+\.mp4)"', script.string)
|
|
if match:
|
|
video_url = match.group(1)
|
|
break
|
|
|
|
# Alternative pattern
|
|
match = re.search(r'"([^"]+\.mp4)"[^}]*type:\s*"video/mp4"', script.string)
|
|
if match:
|
|
video_url = match.group(1)
|
|
# Make sure it's from /v/ directory
|
|
if video_url.startswith('/v/'):
|
|
break
|
|
video_url = None
|
|
|
|
if not video_url:
|
|
# Try to find any .mp4 URL in the page
|
|
mp4_match = re.search(r'"/v/[^"]+\.mp4"', response.text)
|
|
if mp4_match:
|
|
video_url = mp4_match.group(0).strip('"')
|
|
|
|
if not video_url:
|
|
raise Exception("Could not find video URL in Sibnet page")
|
|
|
|
# Convert relative URL to absolute
|
|
if video_url.startswith('/'):
|
|
video_url = urljoin('https://video.sibnet.ru/', video_url)
|
|
|
|
print(f"[SIBNET] Found video URL: {video_url[:80]}...")
|
|
|
|
# Generate filename from URL or use default
|
|
filename_match = re.search(r'/([^/]+)\.mp4', video_url)
|
|
if filename_match:
|
|
filename = f"{filename_match.group(1)}.mp4"
|
|
else:
|
|
filename = "sibnet_video.mp4"
|
|
|
|
return video_url, filename
|
|
|
|
except Exception as e:
|
|
raise Exception(f"Error extracting Sibnet link: {str(e)}")
|