diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2021-05-30 21:41:57 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2021-05-30 21:41:57 -0300 |
commit | 1d056e11c165704b0bfde1e536efc09a6efbf5d8 (patch) | |
tree | f2877d6bca680be4d08c381dd7e8fa0cb8628e0b | |
parent | a0deea739032f5ba5980b45d2627cb12c2ac29a0 (diff) | |
download | playlister-1d056e11c165704b0bfde1e536efc09a6efbf5d8.tar.gz playlister-1d056e11c165704b0bfde1e536efc09a6efbf5d8.tar.bz2 |
Feat: playlist-check: can iterate over all playlists
-rwxr-xr-x | playlist-check | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/playlist-check b/playlist-check index 854ca5d..57cd8d2 100755 --- a/playlist-check +++ b/playlist-check @@ -9,8 +9,24 @@ PLAYLIST="$1" MEDIA="/var/cache/media/noise" PLAYLISTS="$MEDIA/playlists" +# Process +function playlist_check { + local cwd="`pwd`" + + cd $MEDIA + + cat $PLAYLISTS/$PLAYLIST.m3u | while read file; do + #if [ ! -e "$file" ]; then + if ! ls "$file" &> /dev/null; then + echo "$PLAYLIST: missing file: $file" + fi + done + + cd $cwd +} + # Basic syntax -if [ -z "$PLAYLIST" ]; then +if [ "$PLAYLIST" == "--help" ]; then echo "Usage: $BASENAME <playlist>" if [ -d "$PLAYLISTS" ]; then @@ -20,17 +36,15 @@ if [ -z "$PLAYLIST" ]; then fi exit 1 +elif [ -z "$PLAYLIST" ]; then + for playlist in $PLAYLISTS/*m3u; do + PLAYLIST="`basename $playlist .m3u`" + playlist_check + done + elif [ ! -f "$PLAYLISTS/$PLAYLIST.m3u" ]; then echo "No such playlist $PLAYLISTS/$PLAYLIST.m3u" exit 1 +else + playlist_check fi - -# Prepare -cd $MEDIA - -# Process -cat $PLAYLISTS/$PLAYLIST.m3u | while read file; do - if [ ! -e "$file" ]; then - echo "missing file: $file" - fi -done |