You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-26 13:52:00 +01:00
less verbose
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from modules import InterModuleCommunication
|
||||
from . import ActiveModifier
|
||||
import os, log95
|
||||
from . import ActiveModifier, log95
|
||||
import os
|
||||
import subprocess
|
||||
import datetime
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -223,10 +223,6 @@ def play_playlist(playlist_path):
|
||||
for module in simple_modules: module.on_new_track(song_i, track_path, to_fade_in, to_fade_out, official)
|
||||
|
||||
logger.info(f"Now playing: {track_name}")
|
||||
if extend:
|
||||
logger.info(f"Next up: {os.path.basename(playlist[song_i][0])}")
|
||||
else:
|
||||
if (song_i + 1) < len(playlist): logger.info(f"Next up: {os.path.basename(playlist[song_i+1][0])}")
|
||||
|
||||
pr = procman.play(track_path, to_fade_in, to_fade_out, cross_fade)
|
||||
|
||||
@@ -296,7 +292,9 @@ def main():
|
||||
arg = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else None
|
||||
if active_modifier: active_modifier.arguments(arg)
|
||||
while True:
|
||||
play_playlist(playlist_advisor.advise(arg))
|
||||
playlist = playlist_advisor.advise(arg)
|
||||
logger.info(f"Advisor picked '{playlist}' to play")
|
||||
play_playlist(playlist)
|
||||
if exit_pending: exit()
|
||||
except Exception as e:
|
||||
logger.error(f"Unexpected error: {e}")
|
||||
|
||||
Reference in New Issue
Block a user