a perfectly good start (re: baby's little linux project)

oldmansmix is selling himself short again:

But I'm a Linux Baby (TM) and so it has taken me WEEKS to get going. All it is is a simple script, that somebody else wrote, that queries Bandcamp and automatically downloads any new music that I have recently bought to my NAS.

He might think of himself as a Linux Baby™, but a shell script that queries a web service and uses its API to download files to a NAS is a fairly ambitious project. After all, the last shell script I did was a half-assed music player¹.

Getting the Bandcamp Downloader working has made me read up on file permissions, mount points, (very basic) BASH scripting, cron and anacron, etc etc while also really familiarizing myself with basic BASH commands - just using ls or cat without having to really think about it. I'm finding it really neat and fun, and now that I have maybe a little bit of more of an idea how to do stuff with cron, etc.

Learning about file permissions, mount points, shell scripting, job scheduling with cron is hardly baby stuff. This is stuff that will have you well on your way to being a sysadmin.

I hope he keeps at it. It's always good when people challenge themselves and push to learn something new.

---

¹ This is the script I'm talking about. I call it "rockout". You're welcome to use it under GPLv3.

#!/bin/sh -e

# rockout: a front-end & launcher for mpv written in POSIX shell
# Copyright 2021 Matthew Graybosch <contact@starbreaker.org>

OPERATOR=$(whoami)
MUSIC_DIR=${MUSIC_DIR:=${HOME}/Music}
PLAYLIST=${PLAYLIST:=/tmp/rockout-${OPERATOR}.m3u}
LIBRARY_DIR=${HOME}/.local/rockout/
LIBRARY=${LIBRARY_DIR}library.m3u

args=`getopt drshlpq $*`
repeat=""
shuffle=""
display="--audio-display=no"

set -- $args
for search in $@; do :; done

while [ $# -ne 0 ]
do
	case "$1"
	in
		-d)
			echo "\m/ showing album art when available...";
			display="--audio-display=attachment --force-window";
			shift;;
		-r)
			echo "\m/ playlist repeat enabled...";
			repeat="--loop-playlist";
			shift;;
		-s)
			echo "\m/ playlist shuffle enabled...";
			shuffle="--shuffle";
			shift;;
		-p)
			count=$(cat $PLAYLIST | wc -l | sed 's/ //g');

			if [ $count > 0 ]; then
				echo "\m/ playing ${count} track(s) from previous playlist...";
				mpv ${repeat} ${shuffle} ${display} --quiet --playlist=${PLAYLIST};
			else
				echo "\m/ previous playlist not available..."
				exit 1;
			fi

			shift;;
		-h)
			echo "\m/ usage:\n\t-d: show album art when available\n\t-h: show brief usage instructions\n\t-l: generate library\n\t-q: query library\n\t-r: repeat playlist\n\t-s: shuffle playlist\n\tman rockout for further details\n\tRequires 'mpv' application for playback.";
			exit 0;
			shift;;
		-l)
			echo "\m/ (re)generating music library...";
			mkdir -p $LIBRARY_DIR;
			find $MUSIC_DIR -type f \
				 -not -name '*.jpg' \
				 -a -not -name '*.png' \
				 -a -not -name '*.gif' \
				 > $LIBRARY;
			exit 0;
			shift;;
		-q)
			echo "\m/ querying music library...";
			egrep $search $LIBRARY | sort;
			exit 0;
			shift;;
		--)
			shift; break;;
	esac
done

egrep $search $LIBRARY | sort > $PLAYLIST;
chmod 600 $PLAYLIST;
count=$(cat $PLAYLIST | wc -l | sed 's/ //g');

if [ $count > 0 ]; then
	echo "\m/ playing ${count} track(s)...";
	mpv ${repeat} ${shuffle} ${display} --quiet --playlist=${PLAYLIST};
else
	echo "\m/ no tracks found..."
	exit 1;
fi