You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-26 13:52:00 +01:00
wtf
This commit is contained in:
@@ -2,6 +2,7 @@ from modules import BaseIMCModule, InterModuleCommunication
|
||||
from . import ActiveModifier, log95, Track, Path
|
||||
import os, glob, datetime
|
||||
from threading import Lock
|
||||
from crossfade_init import DEFAULT_CROSSFADE
|
||||
|
||||
from typing import TextIO
|
||||
_log_out: TextIO
|
||||
@@ -20,11 +21,11 @@ class Module(ActiveModifier):
|
||||
self.can_limit_tracks = False
|
||||
self.morning_start = self.day_end = 0
|
||||
self.file_lock = Lock()
|
||||
self.crossfade = 5
|
||||
self.crossfade = DEFAULT_CROSSFADE
|
||||
self.skip_next = False
|
||||
def on_new_playlist(self, playlist: list[Track], global_args: dict[str, str]):
|
||||
self.playlist = playlist
|
||||
self.crossfade = float(global_args.get("crossfade", 5.0))
|
||||
self.crossfade = float(global_args.get("crossfade", DEFAULT_CROSSFADE))
|
||||
|
||||
if not self._imc: return
|
||||
self.limit_tracks, self.morning_start, self.day_end = self._imc.send(self, "advisor", None) # pyright: ignore[reportGeneralTypeIssues]
|
||||
|
||||
12
modules/crossfade_init.py
Normal file
12
modules/crossfade_init.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from . import PlaylistModifierModule, Track
|
||||
DEFAULT_CROSSFADE = 5.0
|
||||
class Module(PlaylistModifierModule):
|
||||
def modify(self, global_args: dict, playlist: list[Track]) -> list[Track] | None:
|
||||
out = []
|
||||
for track in playlist:
|
||||
do_cross_fade = track.official
|
||||
track_crossfade = float(track.args.get("crossfade", DEFAULT_CROSSFADE) if track.args else DEFAULT_CROSSFADE) or DEFAULT_CROSSFADE
|
||||
if do_cross_fade and track_crossfade:
|
||||
out.append(Track(track.path, track_crossfade, track_crossfade, do_cross_fade, track.args, focus_time_offset=-track_crossfade))
|
||||
else: out.append(track)
|
||||
return out
|
||||
@@ -22,16 +22,15 @@ class Module(PlaylistModifierModule):
|
||||
if int(global_args.get("no_jingle", 0)) != 0 or not self.primary: return None
|
||||
out: list[Track] = []
|
||||
last_jingiel = True
|
||||
crossfade = float(global_args.get("crossfade", 5.0))
|
||||
for track in playlist:
|
||||
if not last_jingiel and (random.randint(1,3) == 1) and (track.args is None or int(track.args.get("no_jingle", 0)) == 0):
|
||||
out.append(Track(track.path, crossfade, 0, True, track.args, focus_time_offset=-crossfade))
|
||||
out.append(Track(track.path, 0, track.fade_in, True, track.args))
|
||||
jingle = self.primary
|
||||
if self.secondary and (random.randint(1,3) == 1): jingle = random.choice(self.secondary)
|
||||
out.append(Track(jingle, 0, 0, False, {}))
|
||||
last_jingiel = True
|
||||
continue
|
||||
out.append(Track(track.path, crossfade, crossfade, True, track.args,focus_time_offset=-crossfade))
|
||||
out.append(Track(track.path, track.fade_out, track.fade_in, True, track.args,focus_time_offset=-track.fade_out))
|
||||
last_jingiel = False
|
||||
return out
|
||||
|
||||
@@ -52,4 +51,4 @@ class Module2(PlayerModule):
|
||||
|
||||
options = Path("/home/user/Jingiel.mp3"), [Path("/home/user/jing2.opus"), Path("Jing3.opus")]
|
||||
module = Module2(*options)
|
||||
playlistmod = (Module(*options), 2)
|
||||
playlistmod = Module(*options)
|
||||
@@ -76,4 +76,4 @@ class PopularitySorterModule(PlaylistModifierModule):
|
||||
return playlist
|
||||
|
||||
# The radioPlayer will look for a 'playlistmod' variable to load the module.
|
||||
playlistmod = (PopularitySorterModule(), 1)
|
||||
playlistmod = (PopularitySorterModule(), 2)
|
||||
Reference in New Issue
Block a user