generated from unai/python_boilerplate
feat: add inclusion and exclusion filters for channel names in playlist generation
This commit is contained in:
parent
ab9ccd16aa
commit
1cf174e896
@ -24,6 +24,20 @@ class Settings(BaseSettings):
|
||||
env_file=".env", env_file_encoding="utf-8", extra="ignore"
|
||||
)
|
||||
|
||||
# Filtros por prefijo de nombre de canal
|
||||
include_text: list[str] = Field(
|
||||
default_factory=list,
|
||||
description="Lista de textos obligatorios. Si se define, el canal DEBE contener al menos uno.",
|
||||
)
|
||||
exclude_text: list[str] = Field(
|
||||
default_factory=list,
|
||||
description="Lista de textos prohibidos. Si el canal contiene uno, se descarta.",
|
||||
)
|
||||
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env", env_file_encoding="utf-8", extra="ignore"
|
||||
)
|
||||
|
||||
|
||||
# Instancia única de configuración
|
||||
settings = Settings()
|
||||
|
||||
@ -61,7 +61,19 @@ class PlaylistManager:
|
||||
stream_id = channel.get("stream_id")
|
||||
icon = channel.get("stream_icon", "")
|
||||
cat_id = channel.get("category_id", "")
|
||||
|
||||
# Filtros de inclusión/exclusión por prefijo de nombre
|
||||
if settings.include_text:
|
||||
if not any(
|
||||
name.lower().startswith(inc_text.lower())
|
||||
for inc_text in settings.include_text
|
||||
):
|
||||
continue
|
||||
if settings.exclude_text:
|
||||
if any(
|
||||
exc_text.lower() in name.lower()
|
||||
for exc_text in settings.exclude_text
|
||||
):
|
||||
continue
|
||||
# Construir URL directa
|
||||
stream_url = (
|
||||
f"{settings.host}/live/{settings.username}/"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user