generated from unai/python_boilerplate
Liniting
This commit is contained in:
parent
d9dfe7b7c4
commit
5342644b1d
@ -1,5 +1,4 @@
|
||||
"""
|
||||
Módulo principal para iniciar el servicio de construcción de listas M3U."""
|
||||
"""Módulo principal para iniciar el servicio de construcción de listas M3U."""
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
@ -14,6 +14,7 @@ class PlaylistManager:
|
||||
"""Clase para gestionar la generación y actualización de listas M3U."""
|
||||
|
||||
def __init__(self):
|
||||
"""Inicialize the PlaylistManager."""
|
||||
self.running = False
|
||||
|
||||
def fetch_and_generate(self):
|
||||
@ -44,7 +45,6 @@ class PlaylistManager:
|
||||
|
||||
def _write_m3u(self, channels: list):
|
||||
"""Escribe el archivo M3U en disco de forma atómica."""
|
||||
# Escribimos en un temporal y renombramos para evitar lecturas de archivo corrupto
|
||||
temp_file = Path(f"{settings.output_file}.tmp")
|
||||
final_file = Path(settings.output_file)
|
||||
|
||||
@ -57,11 +57,16 @@ class PlaylistManager:
|
||||
cat_id = channel.get("category_id", "")
|
||||
|
||||
# Construir URL directa
|
||||
stream_url = f"{settings.host}/live/{settings.username}/{settings.password}/{stream_id}.ts"
|
||||
|
||||
f.write(
|
||||
f'#EXTINF:-1 tvg-id="{name}" tvg-logo="{icon}" group-title="Cat_{cat_id}",{name}\n'
|
||||
stream_url = (
|
||||
f"{settings.host}/live/{settings.username}/"
|
||||
f"{settings.password}/{stream_id}.ts"
|
||||
)
|
||||
|
||||
extinf_line = (
|
||||
f'#EXTINF:-1 tvg-id="{name}" tvg-logo="{icon}" '
|
||||
f'group-title="Cat_{cat_id}",{name}\n'
|
||||
)
|
||||
f.write(extinf_line)
|
||||
f.write(f"{stream_url}\n")
|
||||
|
||||
# Reemplazo atómico
|
||||
|
||||
@ -9,7 +9,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
def run_server():
|
||||
"""Inicia el servidor HTTP bloqueante."""
|
||||
handler = partial(SimpleHTTPRequestHandler, directory=".")
|
||||
_ = partial(SimpleHTTPRequestHandler, directory=".")
|
||||
|
||||
# Truco: SimpleHTTPRequestHandler sirve el directorio actual,
|
||||
# asegurarse de que el CWD es correcto o mover el archivo a una carpeta 'public'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user