You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-27 06:03:52 +01:00
more jingles
This commit is contained in:
@@ -11,21 +11,24 @@ import random
|
|||||||
from . import PlaylistModifierModule, Track, Path
|
from . import PlaylistModifierModule, Track, Path
|
||||||
|
|
||||||
class Module(PlaylistModifierModule):
|
class Module(PlaylistModifierModule):
|
||||||
def __init__(self, file: Path) -> None:
|
def __init__(self, primary: Path, secondary: list[Path] = []) -> None:
|
||||||
self.file = file.absolute()
|
self.primary = primary.absolute()
|
||||||
assert file.exists()
|
assert primary.exists()
|
||||||
|
self.secondary = [f.absolute() for f in secondary if f.exists()]
|
||||||
def modify(self, global_args: dict, playlist: list[Track]) -> list[Track] | None:
|
def modify(self, global_args: dict, playlist: list[Track]) -> list[Track] | None:
|
||||||
if int(global_args.get("no_jingle", 0)) != 0: return None
|
if int(global_args.get("no_jingle", 0)) != 0 or not self.primary: return None
|
||||||
out: list[Track] = []
|
out: list[Track] = []
|
||||||
last_jingiel = True
|
last_jingiel = True
|
||||||
for track in playlist:
|
for track in playlist:
|
||||||
if not last_jingiel and (random.randint(1,3) == 1) and self.file and (track.args is None or int(track.args.get("no_jingle", 0)) == 0):
|
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, True, False, True, track.args))
|
out.append(Track(track.path, True, False, True, track.args))
|
||||||
out.append(Track(self.file, False, False, False, {}))
|
jingle = self.primary
|
||||||
|
if self.secondary and (random.randint(1,3) == 1): jingle = random.choice(self.secondary) or self.primary
|
||||||
|
out.append(Track(jingle, False, False, False, {}))
|
||||||
last_jingiel = True
|
last_jingiel = True
|
||||||
continue
|
continue
|
||||||
out.append(Track(track.path, True, True, True, track.args))
|
out.append(Track(track.path, True, True, True, track.args))
|
||||||
last_jingiel = False
|
last_jingiel = False
|
||||||
return out
|
return out
|
||||||
|
|
||||||
playlistmod = (Module(Path("/home/user/Jingiel.mp3")), 1)
|
playlistmod = (Module(Path("/home/user/Jingiel.mp3"), [Path("/home/user/jing2.opus"), Path("Jing3.opus")]), 1)
|
||||||
Reference in New Issue
Block a user