KFUK radio scripts to manage MPD music server via MPC to
Automate a radio station and control it manually via SSH

=========
NOTE - this is super easy to use, I wrote a lot trying to help
Anyone that can install linux can figure this out no prob
=========

if you are unfamiliar with Linux, open a terminal and type: nano add.sh

Nano is a simple code editor that highlights the code in colors
if you don't see different colors of text, something is wrong.
I put a few tips on nano use in the very first post on notards.net (-:

You'll see that this script is just a few lines, easy to understand
most of these scripts are just that, a tool to queue songs quickly
and make mixes better than the GUI

Many of the scripts are just 'helper' scripts called by the others,
don't be overwhelmed.. it's like getting a new tool box full of tools
get the hang of a few and learn more as needed.

I'm not a programmer, so all of this scripts suck and could be better
many were my first scripts yeaaaars ago- ie i had no clue

============== Usage: ============== 
zg	search
zg peace	returns a list of songs with peace in the title

ipl	insert playlist	 queues all those peace songs next
ipl r			 ditto but random
ipl kfuk		 insert ~/playlists/kfuk.m3u -- intended for small pls
m3u kfuk [random]	 add playlist to end [for starting from scratch]

zga	search artist    same options as zg
zgb	search album

===================
So not to get too complicated, but i just added a new option
that's really cool.

Say I just got a new album but don't want to play it straight
or you found the 30 WRH Rivero Bankers Wars clips...

zgb Libertad	queues the album  [or zga rivero :-]
ipl s 3 5	"s" for getting songs from the search file .mg
		queue 1st song 3 places after current
		skip 5 songs then add song 2, skip 5... 
		
ipl rock2 3 5   does the same with the rock2 playlist
===================

zap		queue songs from the search results

zga eddie
	Alternative_Rock/misc/eddie_vedder-truth.ogg
	Alternative_Rock/misc/eddie_vedder-people_have_the_power.ogg
	misc/peace/eddie_vedder_powerCLEAN.ogg

zap		queue last song  [powerCLEAN]
zap 1		queue first song

		queue middle song (with the bad language)
zed	z edit    but this is not a script but a shortcut
	nano ~/.bash_aliases
		alias zed='nano ~/.mg'
====
oh yeah, you may have to make that file before any of this works
	touch ~/.mg
====

zz	skip to next song
zn	show playlist
add	add currently playing song to default playlist
add kfuk	"    "   to   kfuk     "
addall  add .mg search results to playlist
countdown	wanted a timer one day- needs work
zd	delete song from playlist
zd 314		deletes 314
zd 314 5	deletes 314 + the next 5  
zdfrompl	worst song ever- delete from every playlist
		makes backup files just in case
zm		move song in the playlist
zm 542		moves song 542 to next
zm 542 538	moves song 542 to 538
ztoggle		Toggle play/stop with fade in/out
zz		skip song- 
zback		go back to previous song
zup		"mpc" volume up- not the same as system volume
zdown		mpc vol down- probably won't need these often
rzclip		select a random ogg
			* ogg is like mp3 but open source
rzclip 6 &	random clip every 6 minutes (& = run in background)
nwzclip		renamed rzclip, for news/ diff source folder
nwzclip 30 &	better this way as each can be cancelled individually

		alias krz='killall -9 rzclip'
		sometimes you want the playlist to run without randoms

ipl news	q all clips fr last day- shuffle, queue, newsintro

lst	last	songs played [but last is already a command]
		shows file paths of recent songs - ie need to edit that one
mlist	make a playlist file from your recent queue
		you just put together 30 songs in a row, weaving a story...
		-- save it and run it back, or tweak it for next time

Note- it's good practice to look at any scripts before running them

These are all pretty simplistic, except for the file processing...


=========================================================================

used freq	mp3/4 processing	advanced	called by scripts
=========	================	========	=================
ipl							tm	timestamp for temp files
lst		svc					za	add song to end of pl
m3u		tags					zclip	used by rzclip
mlist		wavit			fnd		zget	returns song number, title, etc
addall		bump			newscript	randfile
add		cvc			nb		randogg
countdown	getvol			nospaces	this	current song file path 

========
zap	===
zg/a/b    ====  These are the primary commands
zm	  ====       a dj will use all the time
zn	===
========

zd
zdfrompl
zup
zdown
ztoggle
zz
zback


=============================
file processing - for WtP style radio
ffmpeg is the swiss army knife of audio/video processing
	see 1st post on notards.net for tips 

I've been ripping voices of We the People
and turning them into mp3s [ogg]  

you may have to set default to mp4, mp3 or ogg
** used oggs mostly because mp3gain doesn't work on some linux

nospaces	bc I hate file names with spaces and funny characters

tags	add id3 tags and mp3 gain
tags		apply to most recent file
tags a		apply to all
tags zyx.ogg	tag just the one file

**** Volume levels can vary so much, scripts to bring
the volumes to similar levels- normalize doesn't always work

cvc	analyze volume level
getvol  use cvc then return vol level for ffmpeg
	On Ubuntu 20 this works pretty good
	  although the numbers could be fine tuned
	but on Ubuntu 22, ffmpeg changed the vol variable
	from '-vol 300' to -af "volume=1.2"
	I never got this dialed in, but put getvol2.sh
bump	bump the volume of the current file
svc	quick trim video files- many options- try svc h
	good if you don't want to load up a video editor
	to trim/crop files
wavit	used to make wav files, oggs now but kept the name
wavit trump-thePeacemaker.mp4	makes trump-thePeacemaker.ogg
				in zzclips folder
wavit rubio-0missiles.mp4 n	makes the file in znewsclips 
	this has 'compressor' audio filter to boost the sound
	for radio playback... check the wavs in audacity
	with and without... seems ok but could be
	fine tuned by someone with a clue  d-:

===========================
oh yeah- naming convention
the tag script works by separating the
artist-title-source.mp4/mp3/ogg

toddSnider-stepRightUp because i like no caps for leading letters
you can do Todd_Snider and the tags will read "Todd Snider" if you prefer

tiktok video  maryMargaretB-rockefellerPact-tt.ogg
I could write a script to have the computer speak the
artist's account aloud, like a dj giving credit
but the only puter voices I have are old school.


Anyone have a decent computer voice
without using a data center?  lol
lemme know at notards.net
===========================

To get all this running, install mpd mpc ffmpeg vorbisgain mp3gain lltag id3v2
				 and  openssh-server  [for remote operation]

to make these scripts usable, you can use a script lol

Once you get the hang of it, you'll write scripts to do any busy work
I'm always writing new stuff to streamline workflow.

So newscript.sh is a made to add new scripts

newscript bump.sh changes the permissions and makes a symlink
so bump can be called without the sh

but to make this work the first time:
chown USERNAME /usr/local/bin  # (location on ubuntu)
      this gives you ownership of local bin, no sudo/password every time

chmod u+x newscript.sh  # make it executable
ln -s ~/scripts/newscript.sh /usr/local/bin/newscript

that's all this script does for each new file.. just streamlined

now process them all at once
for i in *.sh; do echo "$i"; newscript "$i"; done

=====================

You may need to look inside files to set default directories and such
rzclip checks folder zzclips - zz.. always shows up last, for easy zapping (-;
obviously this can be duped and set to pull randoms on any schedule

The point of all this, your public radio station does not need
6 employees each making $80k or it will shut down as I was told

Local volunteers need to take back the public airwaves
With this you can go home at night, no syndicated crap req'd

Get local voices talking about real issues
Starter pack of local voices 
