You are not logged in.

#1 2020-03-19 02:19:30

cirrus
Member
From: Glasgow Scotland
Registered: 2012-08-24
Posts: 340
Website

wrapper script for sacad album art downloader

#!/usr/bin/env bash

# This is just a simplistic wrapper script for sacad album art downloader


red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
blue=`tput setaf 4`
magenta=`tput setaf 5`
cyan=`tput setaf 6`
tput setaf 5
echo -n "enter name of artist : "
read "artist"
url="$artist"
tput setaf 1
echo -n "enter name of album requiring art : "
read "album"
url="$album"
tput setaf 6
~/venv/bin/sacad -v normal "${artist}" "${album}" 150  ~/"${album}.jpg"
tput setaf 2
echo -n " yay ! "${album}.jpg" album art will be in your home directory."
exit

  sacad
  fancy_audio
  sacad-git
#TODO integrate fancy_audio to auto embed downloaded art.

Last edited by cirrus (2020-03-19 03:12:19)

Offline

#2 2020-03-19 03:09:27

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: wrapper script for sacad album art downloader

There are more lines in that script that are useless than useful.  You run all those tput commands to define colors that you never use.  Then you use echo and read instead of read -p, then you create then overwrite a variable url that you never even use, there is a`tput setaf 6` for absolutely no reason as the color is changed again before anything is printed (or does sacad print output), and there is an exit at the end which is pointless ...  This would be identical:

#!/usr/bin/env bash

tput setaf 5
read -p "enter name of artist album art:" artist
tput setaf 1
read -p "enter name of the album requiring art:" album
tput setaf 6
~/venv/bin/sacad -v normal "${artist}" "${album}" 150  ~/"${album}.jpg"
tput setaf 2
echo -n " yay ! "${album}.jpg" album art will be in your home directory."

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2020-03-19 03:16:19

cirrus
Member
From: Glasgow Scotland
Registered: 2012-08-24
Posts: 340
Website

Re: wrapper script for sacad album art downloader

Trilby thanks for cleaning up my newbie code once again.
LOL im a scaffolder / steel erector by trade so as you have noticed, writing code is not my forte, thanks again for your help sir.
Regards
P.S sacad -v normal does print output RE/; searching and results, then downloading from the art sources, however -v quiet does not.

[edit]  Added fancy_audio intergration for a more streamlined approach to downloading and embedding album art.
added option to view downloaded image with feh before proceeding with embedding.

#!/usr/bin/env bash
# deps: sacad feh fancy_audio [rubygem]
# opt deps: optipng jpegoptim
tput setaf 5
read -p "enter name of artist album art: " artist
tput setaf 1
read -p "enter name of the album requiring art: " album
tput setaf 6
~/venv/bin/sacad -v normal "${artist}" "${album}" 150  ~/"${album}.jpg"
read -p "View Downloaded Album Art $fehview? [yn]" answer
if [[ $answer = y ]] ; then
fehview=$(feh ~/"${album}.jpg" )
fi
tput setaf 2
read -p "enter path of .mp3 file to embed art: " embed
fancy_audio  "${embed}"  ~/"${album}.jpg"
tput setaf 3
echo -n " yay ! "${album}.jpg" now embedded into "${embed}" " 
echo ''
tput setaf 1
read -p "Delete Downloaded Album Art $artdel? [yn] " answer
if [[ $answer = y ]] ; then
artdel=$(rm ~/"${album}.jpg" )
fi

video

Last edited by cirrus (2020-03-21 00:57:54)

Offline

Board footer

Powered by FluxBB