Files
ohm_streaming/app/downloaders/sendvid.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

84 lines
3.2 KiB
Python

from typing import Optional
from bs4 import BeautifulSoup
from .base import BaseDownloader
import re
class SendVidDownloader(BaseDownloader):
"""Downloader for SendVid videos"""
def can_handle(self, url: str) -> bool:
return "sendvid.com" in url.lower()
async def _fetch_page(self, url: str) -> str:
"""Fetch page with proper headers to avoid 403 errors"""
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
'Referer': 'https://sendvid.com/',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5',
}
response = await self.client.get(url, headers=headers)
response.raise_for_status()
return response.text
async def get_download_link(self, url: str, target_filename: str = None) -> tuple[str, str]:
"""
Extract direct download link from SendVid embed page
SendVid embed pages contain the direct MP4 URL in a <source> tag
"""
print(f"[SENDVID] Fetching page: {url}")
html = await self._fetch_page(url)
soup = BeautifulSoup(html, 'lxml')
# Try to find the video source in the <source> tag
source_tag = soup.find('source', {'id': 'video_source'})
if source_tag and source_tag.get('src'):
video_url = source_tag['src']
print(f"[SENDVID] Found video URL in <source> tag")
# Generate filename
if target_filename:
filename = target_filename
else:
# Extract filename from video URL or generate one
filename = self._extract_filename_from_url(url, video_url)
print(f"[SENDVID] Download URL: {video_url}")
print(f"[SENDVID] Filename: {filename}")
return video_url, filename
# Fallback: try to find in og:video meta property
og_video = soup.find('meta', {'property': 'og:video'})
if og_video and og_video.get('content'):
video_url = og_video['content']
print(f"[SENDVID] Found video URL in og:video meta")
if target_filename:
filename = target_filename
else:
filename = self._extract_filename_from_url(url, video_url)
print(f"[SENDVID] Download URL: {video_url}")
print(f"[SENDVID] Filename: {filename}")
return video_url, filename
raise Exception("Could not extract video URL from SendVid page")
def _extract_filename_from_url(self, page_url: str, video_url: str) -> str:
"""Generate filename from SendVod URLs"""
# Try to extract video ID from page URL
video_id_match = re.search(r'/embed/([a-z0-9]+)', page_url)
if video_id_match:
video_id = video_id_match.group(1)
# Try to get title from page (might need to fetch, but for now use ID)
return f"sendvid_{video_id}.mp4"
# Fallback: extract from video URL
filename_match = re.search(r'/([^/]+\.mp4)', video_url)
if filename_match:
return filename_match.group(1)
return "sendvid_video.mp4"