0
1
mirror of https://github.com/radio95-rnt/RadioPlayer.git synced 2026-02-26 21:53:54 +01:00

less verbose

This commit is contained in:
Kuba
2025-10-31 17:33:44 +01:00
parent b2cda9cb05
commit 2247e7996c
6 changed files with 30 additions and 19 deletions

View File

@@ -1,3 +1,5 @@
import log95
class PlayerModule:
"""
Simple passive observer, this allows you to send the current track the your RDS encoder, or to your website

View File

@@ -1,6 +1,6 @@
from modules import InterModuleCommunication
from . import ActiveModifier
import os, log95
from . import ActiveModifier, log95
import os
import subprocess
import datetime

View File

@@ -1,13 +1,13 @@
from modules import ActiveModifier, InterModuleCommunication, PlayerModule
from . import PlaylistAdvisor
import os, datetime, log95
from . import PlaylistAdvisor, log95
import os, datetime
logger = log95.log95("ADVISOR")
MORNING_START = 5
MORNING_END = 11
DAY_START = 11
DAY_END = 19
MORNING_END = 10
DAY_START = 10
DAY_END = 18
LATE_NIGHT_START = 0
LATE_NIGHT_END = 5

View File

@@ -1,5 +1,7 @@
from . import PlayerModule
import socket, re, log95, os
from . import PlayerModule, log95
import socket, re, os
DEBUG = False
name_table_path = "/home/user/mixes/name_table.txt"
@@ -9,7 +11,8 @@ rds_default_name = "Program Godzinny"
udp_host = ("127.0.0.1", 5000)
logger = log95.log95("RDS-MODULE")
logger_level = log95.log95Levels.DEBUG if DEBUG else log95.log95Levels.CRITICAL_ERROR
logger = log95.log95("RDS-MODULE", logger_level)
def load_dict_from_custom_format(file_path: str) -> dict[str, str]:
try:
@@ -60,7 +63,9 @@ def update_rds(track_name: str):
try:
f = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
f.settimeout(1.0)
f.sendto(f"TEXT={prt}\r\nRTP={rtp}\r\n".encode(), udp_host)
data = f"TEXT={prt}\r\nRTP={rtp}\r\n".encode()
f.sendto(data, udp_host)
logger.debug("Sending", str(data))
f.close()
except Exception as e: logger.error(f"Error updating RDS: {e}")
@@ -70,6 +75,7 @@ class Module(PlayerModule):
def on_new_track(self, index: int, track: str, to_fade_in: bool, to_fade_out: bool, official: bool):
if official:
rds_rt, rds_rtp = update_rds(os.path.basename(track))
logger.info(f"RT set to '{rds_rt}' (RTP: {rds_rtp})")
logger.info(f"RT set to '{rds_rt}'")
logger.debug(f"{rds_rtp=}")
module = Module()

View File

@@ -1,4 +1,6 @@
from . import PlayerModule
from . import PlayerModule, log95
logger = log95.log95("PlayView")
class Module(PlayerModule):
def __init__(self) -> None:
@@ -10,7 +12,10 @@ class Module(PlayerModule):
# discrepancy, which means that the playing file was modified by the active modifier
# we are playing a file that was not determined in the playlist, that means it was chosen by the active modifier and made up on the fly
lines = self.playlist[:index] + [f"> ({track})"] + [self.playlist[index]] + self.playlist[index+1:]
else: lines = self.playlist[:index] + [f"> {self.playlist[index]}"] + self.playlist[index+1:]
logger.info("Next up:", self.playlist[index])
else:
lines = self.playlist[:index] + [f"> {self.playlist[index]}"] + self.playlist[index+1:]
if index + 1 < len(self.playlist): logger.info("Next up:", self.playlist[index+1])
with open("/tmp/radioPlayer_playlist", "w") as f:
for line in lines:
try: f.write(line + "\n")