47 lines
1017 B
Python
47 lines
1017 B
Python
from collections.abc import Callable
|
|
from pathlib import Path
|
|
from typing import Protocol
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class ProviderError(RuntimeError):
|
|
pass
|
|
|
|
|
|
class MediaMetadata(BaseModel):
|
|
provider: str
|
|
title: str | None = None
|
|
description: str | None = None
|
|
thumbnail: str | None = None
|
|
duration_seconds: int | None = None
|
|
external_id: str | None = None
|
|
|
|
|
|
class DownloadOptions(BaseModel):
|
|
max_height: int = 1080
|
|
target_library: str = "movies"
|
|
audio_only: bool = False
|
|
max_bytes: int = 15_000_000_000
|
|
|
|
|
|
class DownloadResult(BaseModel):
|
|
output_files: list[Path]
|
|
metadata_files: list[Path] = []
|
|
|
|
|
|
class Provider(Protocol):
|
|
name: str
|
|
|
|
def can_handle(self, url: str) -> bool: ...
|
|
|
|
async def probe(self, url: str) -> MediaMetadata: ...
|
|
|
|
async def download(
|
|
self,
|
|
url: str,
|
|
target_dir: Path,
|
|
options: DownloadOptions,
|
|
progress_callback: Callable[[float], None] | None = None,
|
|
) -> DownloadResult: ...
|