Files
ohm_streaming/app/downloaders/unfichier.py
T
root cb3ea8d926 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>
2026-01-23 08:17:10 +00:00

52 lines
2.2 KiB
Python

from .base import BaseDownloader
from bs4 import BeautifulSoup
import re
import httpx
class UnFichierDownloader(BaseDownloader):
"""Downloader for 1fichier.com"""
def can_handle(self, url: str) -> bool:
return any(domain in url.lower() for domain in ["1fichier.com", "1fichier.fr"])
async def get_download_link(self, url: str) -> tuple[str, str]:
try:
# Initial page
response = await self.client.get(url)
response.raise_for_status()
# Check if we need to wait (download button)
soup = BeautifulSoup(response.text, 'lxml')
# Check for direct download link
download_link = soup.find('a', class_='btn btn-download')
if download_link and download_link.get('href'):
download_url = download_link['href']
# Follow to get headers for filename
head_resp = await self.client.head(download_url)
filename = self._extract_filename_from_headers(head_resp.headers)
if not filename:
filename = download_url.split('/')[-1] or "downloaded_file"
return download_url, filename
# Alternative: look for any download link in the page
for link in soup.find_all('a', href=True):
href = link['href']
if href.startswith('http') and '1fichier' not in href:
# Try to head the URL to see if it's a file
try:
head_resp = await self.client.head(href, timeout=5.0)
if 'content-length' in head_resp.headers or 'attachment' in head_resp.headers.get('content-disposition', ''):
filename = self._extract_filename_from_headers(head_resp.headers)
if not filename:
filename = href.split('/')[-1] or "downloaded_file"
return href, filename
except:
continue
raise Exception("Could not find download link on page")
except Exception as e:
raise Exception(f"Error extracting 1fichier link: {str(e)}")