mirror of
https://github.com/g0ldyy/comet.git
synced 2026-01-12 01:16:12 +01:00
feat: enable dynamic proxy configuration by allowing extra Pydantic settings fields and setting the default proxy ethos to 'always'
This commit is contained in:
+1
-1
@@ -93,7 +93,7 @@ ANIME_MAPPING_REFRESH_INTERVAL=86400 # Seconds between background anime mapping
|
||||
# Networking & Proxy Configuration #
|
||||
# ============================== #
|
||||
GLOBAL_PROXY_URL= # Global proxy for all outbound requests (e.g. http://user:pass@host:port)
|
||||
PROXY_ETHOS=never # always: use proxy for everything; on_failure: retry with proxy if direct fails; never: never use proxy (unless specific scraper override)
|
||||
PROXY_ETHOS=always # always: use proxy for everything; on_failure: retry with proxy if direct fails; never: never use proxy (unless specific scraper override)
|
||||
# Scraper specific proxies can be set using [SCRAPERNAME]_PROXY_URL
|
||||
# Example: TORRENTIO_PROXY_URL=http://...
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from comet.core.logger import logger
|
||||
|
||||
class AppSettings(BaseSettings):
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env", env_file_encoding="utf-8", extra="ignore"
|
||||
env_file=".env", env_file_encoding="utf-8", extra="allow"
|
||||
)
|
||||
|
||||
ADDON_ID: Optional[str] = "stremio.comet.fast"
|
||||
@@ -127,7 +127,7 @@ class AppSettings(BaseSettings):
|
||||
DIGITAL_RELEASE_FILTER: Optional[bool] = False
|
||||
TMDB_READ_ACCESS_TOKEN: Optional[str] = None
|
||||
GLOBAL_PROXY_URL: Optional[str] = None
|
||||
PROXY_ETHOS: Optional[str] = "never"
|
||||
PROXY_ETHOS: Optional[str] = "always"
|
||||
|
||||
@field_validator("INDEXER_MANAGER_TYPE")
|
||||
def set_indexer_manager_type(cls, v, values):
|
||||
|
||||
@@ -134,7 +134,8 @@ class AsyncClientWrapper:
|
||||
scraper_proxy_key = (
|
||||
f"{scraper_name.upper().replace('SCRAPER', '')}_PROXY_URL"
|
||||
)
|
||||
self.proxy_url = getattr(settings, scraper_proxy_key, None)
|
||||
if settings.model_extra:
|
||||
self.proxy_url = settings.model_extra.get(scraper_proxy_key.lower())
|
||||
|
||||
if not self.proxy_url:
|
||||
# Fallback to global proxy
|
||||
|
||||
Reference in New Issue
Block a user