Translate log messages from French to English

This commit is contained in:
√(noham)²
2025-11-27 21:32:56 +01:00
parent 0e0a811c91
commit 898edc0758

23
main.py
View File

@@ -95,22 +95,22 @@ def fetch_service_plan():
api_url = SERVICE_PLAN_API_URL api_url = SERVICE_PLAN_API_URL
try: try:
logger.info("Chargement de la liste des chaînes depuis l'API Oqee...") logger.info("Loading channel list from the Oqee API...")
response = requests.get(api_url, timeout=REQUEST_TIMEOUT) response = requests.get(api_url, timeout=REQUEST_TIMEOUT)
response.raise_for_status() response.raise_for_status()
data = response.json() data = response.json()
if not data.get("success") or "channels" not in data.get("result", {}): if not data.get("success") or "channels" not in data.get("result", {}):
logger.error("Erreur: Le format de la réponse de l'API est inattendu.") logger.error("Error: Unexpected API response format.")
return None return None
channels_data = data["result"]["channels"] channels_data = data["result"]["channels"]
return channels_data return channels_data
except requests.exceptions.RequestException as exc: except requests.exceptions.RequestException as exc:
logger.error("Une erreur réseau est survenue : %s", exc) logger.error("A network error occurred: %s", exc)
return None return None
except ValueError: except ValueError:
logger.error("Erreur lors de l'analyse de la réponse JSON.") logger.error("Error while parsing the JSON response.")
return None return None
def fetch_and_parse_ads(channel_id: str, conn: sqlite3.Connection) -> None: def fetch_and_parse_ads(channel_id: str, conn: sqlite3.Connection) -> None:
@@ -146,7 +146,6 @@ def fetch_and_parse_ads(channel_id: str, conn: sqlite3.Connection) -> None:
end_ts = item.get('end_time') end_ts = item.get('end_time')
if start_ts is None or end_ts is None: if start_ts is None or end_ts is None:
# Skip malformed periods instead of crashing the script
logger.warning("Skipping ad break with missing timestamps: %s", item) logger.warning("Skipping ad break with missing timestamps: %s", item)
continue continue
@@ -183,7 +182,7 @@ def run_collection_cycle(conn: sqlite3.Connection) -> None:
channels_data = fetch_service_plan() channels_data = fetch_service_plan()
if not channels_data: if not channels_data:
logger.warning("Aucune donnée de chaîne disponible pour ce cycle") logger.warning("No channel data available for this cycle")
return return
for channel_id, channel_info in channels_data.items(): for channel_id, channel_info in channels_data.items():
@@ -198,9 +197,9 @@ def run_collection_cycle(conn: sqlite3.Connection) -> None:
try: try:
fetch_and_parse_ads(channel_id, conn) fetch_and_parse_ads(channel_id, conn)
except requests.RequestException as exc: except requests.RequestException as exc:
logger.error("Erreur réseau pour la chaîne %s: %s", channel_id, exc) logger.error("Network error for channel %s: %s", channel_id, exc)
except Exception: # pylint: disable=broad-exception-caught except Exception: # pylint: disable=broad-exception-caught
logger.exception("Erreur inattendue pour la chaîne %s", channel_id) logger.exception("Unexpected error for channel %s", channel_id)
def main() -> None: def main() -> None:
"""Entrypoint for CLI execution.""" """Entrypoint for CLI execution."""
@@ -216,19 +215,19 @@ def main() -> None:
try: try:
while True: while True:
cycle_started = datetime.now().strftime('%Y-%m-%d %H:%M:%S') cycle_started = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
logger.info("=== Nouvelle collecte démarrée à %s ===", cycle_started) logger.info("=== New collection started at %s ===", cycle_started)
try: try:
run_collection_cycle(conn) run_collection_cycle(conn)
except Exception: # pylint: disable=broad-exception-caught except Exception: # pylint: disable=broad-exception-caught
logger.exception("Erreur critique pendant la collecte") logger.exception("Critical error during collection")
logger.info( logger.info(
"Pause de %s minutes avant la prochaine collecte...", "Pausing for %s minutes before the next collection...",
POLL_INTERVAL_SECONDS // 60, POLL_INTERVAL_SECONDS // 60,
) )
time.sleep(POLL_INTERVAL_SECONDS) time.sleep(POLL_INTERVAL_SECONDS)
except KeyboardInterrupt: except KeyboardInterrupt:
logger.info("Arrêt demandé par l'utilisateur. Fermeture...") logger.info("Shutdown requested by user. Closing...")
finally: finally:
conn.close() conn.close()