radio

a command line radio player, using mpd/mpv as a backend
git clone git://git.alex.balgavy.eu/radio.git
Log | Files | Refs | README | LICENSE

commit a5510f40f3beb0fed3636e6e4658cd418f644c0b
parent f936b094b04db03ab86f782a78043cfc2a1b41a0
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Fri, 18 Dec 2020 21:33:43 +0100

Partial mpd support with mpc

Not yet implemented for subreddits.

Diffstat:
Mradio | 19+++++++++++++++++--
Murls | 2+-
2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/radio b/radio @@ -22,6 +22,7 @@ class Subreddit end def play + # TODO: support mpd with mpc mpv_options = '--no-video --volume=50' links = [] @posts.each do |post| @@ -51,8 +52,12 @@ class Radio CONFIG_FILE = "#{ENV['HOME']}/.config/radio/urls" SUBREDDIT_CHANNEL = 'Play from music subreddit' def initialize - unless system('command -v mpv 1>/dev/null 2>&1') - warn 'mpv not installed.' + if system('command -v mpc 1>/dev/null 2>&1') + @player = 'mpc' + elsif system('command -v mpv 1>/dev/null 2>&1') + @player = 'mpv' + else + warn 'neither mpc nor mpv installed.' exit 1 end if File.exist? CONFIG_FILE @@ -105,6 +110,16 @@ class Radio sub = Subreddit.new(gets.chomp) end sub.play + elsif @player == 'mpc' + puts "Loading #{selection} in mpd..." + system 'mpc', 'clear' + if selection.include? 'somafm.com' + system 'mpc', 'load', selection + system 'mpc', 'play' + else + system 'mpc', 'add', selection + system 'mpc', 'play' + end else puts "\e[H\e[2J" puts "Loading #{selection}..." diff --git a/urls b/urls @@ -16,4 +16,4 @@ "SOMA - Defcon" https://somafm.com/defcon256.pls "SOMA - Deep Space (deep ambient electro/experimental)" https://somafm.com/deepspaceone.pls "SOMA - Thistle Radio (Celtic)" https://somafm.com/thistle.pls -"SOMA - Fluid (instr. hip hop, liquid trap" https://somafm.com/fluid.pls +"SOMA - Fluid (instr. hip hop, liquid trap)" https://somafm.com/fluid.pls