You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-27 14:13:55 +01:00
compression?
This commit is contained in:
@@ -40,6 +40,8 @@ class PlayerModule(BaseIMCModule):
|
||||
def progress(self, index: int, track: Track, elapsed: float, total: float, real_total: float) -> None:
|
||||
"""
|
||||
Real total and total differ in that, total is how much the track lasts, but real_total will be for how long we will play it for
|
||||
Runs at a frequency around 1 Hz
|
||||
Please don't put any blocking or code that takes time
|
||||
"""
|
||||
pass
|
||||
class PlaylistModifierModule:
|
||||
@@ -92,6 +94,8 @@ class InterModuleCommunication:
|
||||
self.active_modifier = active_modifier
|
||||
self.simple_modules = simple_modules
|
||||
self.names_modules: dict[str, BaseIMCModule] = {}
|
||||
for module in simple_modules + [active_modifier, advisor]:
|
||||
if module: module.imc(self)
|
||||
def broadcast(self, source: BaseIMCModule, data: object) -> None:
|
||||
"""
|
||||
Send data to all modules, other than ourself
|
||||
|
||||
@@ -15,11 +15,11 @@ playlist_dir = "/home/user/playlists"
|
||||
|
||||
class Time:
|
||||
@staticmethod
|
||||
def get_playlist_modification_time(playlist_path):
|
||||
def get_playlist_modification_time(playlist_path) -> float:
|
||||
try: return os.path.getmtime(playlist_path)
|
||||
except OSError: return 0
|
||||
|
||||
def check_if_playlist_modifed(playlist_path: str):
|
||||
def check_if_playlist_modifed(playlist_path: str) -> bool:
|
||||
current_day, current_hour = datetime.datetime.now().strftime('%A').lower(), datetime.datetime.now().hour
|
||||
morning_playlist_path = os.path.join(playlist_dir, current_day, 'morning')
|
||||
day_playlist_path = os.path.join(playlist_dir, current_day, 'day')
|
||||
@@ -107,7 +107,7 @@ class Module(PlaylistAdvisor):
|
||||
logger.info("Playlist changed on disc, reloading...")
|
||||
return True
|
||||
return False
|
||||
def imc(self, imc: InterModuleCommunication):
|
||||
def imc(self, imc: InterModuleCommunication) -> None:
|
||||
self.class_imc = imc
|
||||
imc.register(self, "advisor")
|
||||
def imc_data(self, source: PlayerModule | ActiveModifier | PlaylistAdvisor, source_name: str | None, data: object, broadcast: bool):
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
from . import PlayerModule, Track
|
||||
import os
|
||||
|
||||
def format_time(seconds):
|
||||
def format_time(seconds) -> str:
|
||||
hours = int(seconds // 3600)
|
||||
minutes = int((seconds % 3600) // 60)
|
||||
secs = int(seconds % 60)
|
||||
return f"{hours:02d}:{minutes:02d}:{secs:02d}"
|
||||
|
||||
class Module(PlayerModule):
|
||||
def progress(self, index: int, track: Track, elapsed: float, total: float, real_total: float):
|
||||
def progress(self, index: int, track: Track, elapsed: float, total: float, real_total: float) -> None:
|
||||
if track.official:
|
||||
print(f"{os.path.basename(track.path)}: {format_time(elapsed)} / {format_time(total)}", end="\r", flush=True)
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ from . import PlaylistModifierModule, Track
|
||||
class Module(PlaylistModifierModule):
|
||||
def __init__(self, file: str) -> None:
|
||||
self.file = file
|
||||
def modify(self, global_args: dict, playlist: list[Track]):
|
||||
if int(global_args.get("no_jingle", 0)): return playlist
|
||||
def modify(self, global_args: dict, playlist: list[Track]) -> list[Track] | None:
|
||||
if int(global_args.get("no_jingle", 0)): return None
|
||||
out: list[Track] = []
|
||||
last_jingiel = True
|
||||
for track in playlist:
|
||||
@@ -22,9 +22,9 @@ class Module(PlaylistModifierModule):
|
||||
out.append(Track(track.path, True, False, True, track.args))
|
||||
out.append(Track(self.file, False, False, False, {}))
|
||||
last_jingiel = True
|
||||
else:
|
||||
out.append(Track(track.path, True, True, True, track.args))
|
||||
last_jingiel = False
|
||||
continue
|
||||
out.append(Track(track.path, True, True, True, track.args))
|
||||
last_jingiel = False
|
||||
del last_jingiel
|
||||
return out
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ name_table_path = "/home/user/mixes/name_table.txt"
|
||||
|
||||
rds_base = "Gramy: {} - {}"
|
||||
rds_default_artist = "radio95"
|
||||
rds_default_name = "Program Godzinny"
|
||||
|
||||
udp_host = ("127.0.0.1", 5000)
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@ from . import PlaylistModifierModule, Track
|
||||
|
||||
class Module(PlaylistModifierModule):
|
||||
def modify(self, global_args: dict, playlist: list[Track]):
|
||||
if int(global_args.get("no_shuffle", 0)) == 0:
|
||||
random.shuffle(playlist)
|
||||
return playlist
|
||||
if int(global_args.get("no_shuffle", 0)) == 0: random.shuffle(playlist)
|
||||
return None
|
||||
|
||||
playlistmod = (Module(), 0)
|
||||
@@ -12,7 +12,7 @@ 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.path})"] + [self.playlist[index]] + self.playlist[index+1:]
|
||||
logger.info("Next up:", self.playlist[index])
|
||||
logger.info("Next up:", self.playlist[index]) # core no longer does this
|
||||
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])
|
||||
|
||||
Reference in New Issue
Block a user