- BaseExtractor ABC with health_check method - ExtractorRegistry with concurrent fan-out extraction - ExtractionService with in-memory cache and background polling - DemoExtractor with 3 public HLS test streams - Adaptive polling: 5min during live sessions, 30min otherwise - GET /streams, GET /extractors, POST /extract endpoints
29 lines
1,007 B
Python
29 lines
1,007 B
Python
"""Data models for the stream extraction framework."""
|
|
|
|
from dataclasses import dataclass, field
|
|
from datetime import datetime, timezone
|
|
|
|
|
|
@dataclass
|
|
class ExtractedStream:
|
|
"""Represents a single stream URL discovered by an extractor."""
|
|
|
|
url: str # The HLS/m3u8 URL
|
|
site_key: str # Which extractor found it
|
|
site_name: str # Human-readable name
|
|
quality: str = "" # e.g., "720p", "1080p", or empty
|
|
title: str = "" # e.g., "F1 Race Live"
|
|
extracted_at: str = field(default_factory=lambda: datetime.now(timezone.utc).isoformat())
|
|
is_live: bool = False # Whether it passed health check
|
|
|
|
def to_dict(self) -> dict:
|
|
"""Serialize to a plain dictionary for JSON responses."""
|
|
return {
|
|
"url": self.url,
|
|
"site_key": self.site_key,
|
|
"site_name": self.site_name,
|
|
"quality": self.quality,
|
|
"title": self.title,
|
|
"extracted_at": self.extracted_at,
|
|
"is_live": self.is_live,
|
|
}
|