From 358bafaf956a0c07ad000bdc656deeddead31a33 Mon Sep 17 00:00:00 2001 From: magicquark <198001825+magicquark@users.noreply.github.com> Date: Thu, 26 Feb 2026 04:37:49 +0000 Subject: [PATCH] pyradio: add per-station buffering option --- modules/programs/pyradio.nix | 22 ++++++++++++++++++- .../programs/pyradio/custom-stations.nix | 1 + .../programs/pyradio/expected-stations.csv | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/modules/programs/pyradio.nix b/modules/programs/pyradio.nix index 8bdd0b89..6e403734 100644 --- a/modules/programs/pyradio.nix +++ b/modules/programs/pyradio.nix @@ -61,6 +61,24 @@ in description = "Stream URL of the radio station."; }; + buffering = mkOption { + type = nullOr (submodule { + options = { + seconds = mkOption { + type = ints.positive; + description = "Number of seconds to buffer the stream."; + }; + bitrate = mkOption { + type = ints.positive; + default = 128; + description = "Bitrate of the stream in kbps (modify only if using MPlayer)."; + }; + }; + }); + description = "Buffering configuration to apply to the station."; + default = null; + }; + encoding = mkOption { type = str; default = ""; @@ -142,7 +160,9 @@ in station.encoding (escapeCSV station.iconUrl) "" - "" + (lib.optionalString ( + station.buffering != null + ) "${toString station.buffering.seconds}@${toString station.buffering.bitrate}") (if station.forceHttp then "1" else "0") (toString station.volume) ] diff --git a/tests/modules/programs/pyradio/custom-stations.nix b/tests/modules/programs/pyradio/custom-stations.nix index 9f4f0278..347ae5f2 100644 --- a/tests/modules/programs/pyradio/custom-stations.nix +++ b/tests/modules/programs/pyradio/custom-stations.nix @@ -23,6 +23,7 @@ { name = "DEF CON Radio (SomaFM)"; url = "https://somafm.com/defcon256.pls"; + buffering.seconds = 10; volume = 85; encoding = "utf-8"; iconUrl = "https://somafm.com/img3/defcon400.png"; diff --git a/tests/modules/programs/pyradio/expected-stations.csv b/tests/modules/programs/pyradio/expected-stations.csv index 1ebbcce4..492ec6c3 100644 --- a/tests/modules/programs/pyradio/expected-stations.csv +++ b/tests/modules/programs/pyradio/expected-stations.csv @@ -2,4 +2,4 @@ DEF CON Radio (SomaFM),https://somafm.com/defcon256.pls,,,,,0,50 "DEF CON Radio, SomaFM",https://somafm.com/defcon256.pls,,,,,0,50 "DEF CON Radio on ""SomaFM""",https://somafm.com/defcon256.pls,,,,,0,50 "DEF CON Radio on ""SomaFM""",https://somafm.com/defcon256.pls,,,,,0,50 -DEF CON Radio (SomaFM),https://somafm.com/defcon256.pls,utf-8,https://somafm.com/img3/defcon400.png,,,1,85 +DEF CON Radio (SomaFM),https://somafm.com/defcon256.pls,utf-8,https://somafm.com/img3/defcon400.png,,10@128,1,85