Files
unshackle/unshackle/core/proxies/proxy.py
T
imSp4rky 7898ff6dd6 refactor(types): bring mypy to zero errors across unshackle
Fix the bugs the type errors exposed (RnetSession.send body, HLS proxy session, title cache fallback, mux progress) and gate mypy in pre-commit, warn-only in CI.
2026-10-30 20:51:21 -06:00

32 lines
1.1 KiB
Python

from abc import abstractmethod
from typing import Any, Optional
class Proxy:
@abstractmethod
def __init__(self, **kwargs: Any) -> None:
"""
The constructor initializes the Service using passed configuration data.
Any authorization or pre-fetching of data should be done here.
"""
@abstractmethod
def __repr__(self) -> str:
"""Return a string denoting a list of Countries and Servers (if possible)."""
countries = ...
servers = ...
return f"{countries} Countr{['ies', 'y'][countries == 1]} ({servers} Server{['s', ''][servers == 1]})"
@abstractmethod
def get_proxy(self, query: str) -> Optional[str]:
"""
Get a proxy URI from the proxy provider.
Return None when this proxy provider has no proxy for the query, so that a bare query
moves on to the next proxy provider. Use exceptions for errors with the call.
The returned Proxy URI must be a string supported by Python-Requests:
'{scheme}://[{user}:{pass}@]{host}:{port}'
"""