Files
ohm_streaming/app/downloaders/video_players/doodstream.py
T
Kimi Agent 520be53901
CI / Test (Python 3.11) (push) Has been cancelled
CI / Test (Python 3.12) (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Type Check (push) Has been cancelled
CI / Summary (push) Has been cancelled
fix: migrations, auth, providers health check, E2E tests, remove neko-sama
- Add proper Alembic initial migration (0001_initial_schema.py)
- Migrate refresh tokens from JSON file to SQLite (RefreshTokenTable)
- Remove Neko-Sama provider entirely (redirects to Gupy, not a host)
- Fix provider health check always showing UNKNOWN
  - Run check_all_health() on startup
  - Fix POST /providers/health/check background task bug
  - Add HTMX refresh after manual health check trigger
- Fix anime search relevance scoring with MIN_RELEVANCE_THRESHOLD=0.5
- Replace bare 'except:' with 'except Exception:' across codebase
- Add Playwright E2E test suite (12 tests, auth setup, helpers)
- Fix toast container blocking clicks via pointer-events: none
- Remove obsolete Jest/Vite test files and config
- Clean up obsolete test_watchlist scripts
- Update sonarr model comment for active providers
2026-05-12 11:45:56 +00:00

80 lines
3.2 KiB
Python

from .base import BaseVideoPlayer
from bs4 import BeautifulSoup
import re
import httpx
class DoodStreamDownloader(BaseVideoPlayer):
"""Downloader for doodstream.com"""
def can_handle(self, url: str) -> bool:
return any(domain in url.lower() for domain in ["doodstream.com", "dood.stream", "dood.to", "dood.lol", "dood.cx", "dood.so", "dood.watch", "dood.sh"])
async def get_download_link(self, url: str, target_filename: str = None) -> tuple[str, str]:
try:
# Get the page
response = await self.client.get(url)
response.raise_for_status()
soup = BeautifulSoup(response.text, 'lxml')
# Doodstream usually has the video URL in a script with '$(function)'
# or in a token-based system
download_url = None
filename = "doodstream_video.mp4"
# Method 1: Look for /pass_md5 or similar patterns
scripts = soup.find_all('script')
for script in scripts:
if script.string:
# Look for token patterns
match = re.search(r'https?://[^\"\']+\.(?:mp4|mkv|avi)', script.string)
if match:
download_url = match.group(0)
break
# Look for doodstream CDN patterns
match = re.search(r'(https?://[^\s\"\'<>]+/download/[^\s\"\'<>]+)', script.string)
if match:
download_url = match.group(0)
break
# Method 2: Try to construct download URL from page
if not download_url:
# Extract video ID from URL
# Format: https://doodstream.com/e/VIDEO_ID or /d/VIDEO_ID
video_id_match = re.search(r'/[ed]/([a-zA-Z0-9]+)', url)
if video_id_match:
video_id = video_id_match.group(1)
# Try direct download pattern
download_url = f"https://dood.stream/e/{video_id}"
# Method 3: Look for any MP4 source in iframes or video tags
if not download_url:
video = soup.find('video')
if video and video.get('src'):
download_url = video['src']
else:
sources = soup.find_all('source')
for source in sources:
if source.get('src'):
download_url = source['src']
filename = source.get('src', '').split('/')[-1]
break
if download_url:
# Try to get real filename from HEAD request
try:
head_resp = await self.client.head(download_url, timeout=5.0)
fname = self._extract_filename_from_headers(head_resp.headers)
if fname:
filename = fname
except Exception:
pass
return download_url, filename
raise Exception("Could not extract download link from Doodstream page")
except Exception as e:
raise Exception(f"Error extracting Doodstream link: {str(e)}")