URI: 
       Fix yt-dlp output and adding to queue. - annna - Annna the nice friendly bot.
  HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
       ---
   DIR commit 41ec9fc9977fde61417488d0746553f50ec34288
   DIR parent f850abb402021106be62251faaab4b6592f7c614
  HTML Author: Annna Robert-Houdin <annna@bitreich.org>
       Date:   Sat, 10 Aug 2024 11:08:12 +0200
       
       Fix yt-dlp output and adding to queue.
       
       Diffstat:
         M ytdl-mpd                            |      37 ++++++++++++++++---------------
       
       1 file changed, 19 insertions(+), 18 deletions(-)
       ---
   DIR diff --git a/ytdl-mpd b/ytdl-mpd
       @@ -41,7 +41,7 @@ handle_url() {
                mkdir -p "$outputdir"
                cd "$outputdir"
        
       -        album="$(ytdl "$1" | tee /dev/tty | grep 'Finished downloading' | sed 's/.*: //')"
       +        album="$(ytdl "$1" | grep 'Finished downloading' | sed 's/.*: //')"
        
                if [ $? -ne 0 ]; then
                        die "youtube-dl error"
       @@ -82,11 +82,12 @@ handle_url() {
                                artist="$(printf '%s' "$f" | \
                                        awk -F'-' '{gsub(/^ +/, "", $2); gsub(/ +$/, "", $2); print $2}')"
        
       -                printf 'file: %s\n' "$f"
        
                        song=$(printf '%s' "$f" | sed 's/.* - //; s/^ //; s/\.mp3//')
        
                        if [ "$auto" = 0 ]; then
       +                        printf 'file: %s\n' "$f"
       +
                                printf 'song [%s]: ' "$song"
                                read
                                song="${REPLY:-$song}"
       @@ -106,28 +107,28 @@ handle_url() {
        
                        id3tag --artist="$artist" --album="$album" \
                                --song="$song" --track="$track" \
       -                        "$f"
       +                        "$f" 2>&1 >/dev/null
        
                        track=$(( track + 1 ))
       +
       +                if [ "$move_music" = 1 ]; then
       +                        outdir="$musicroot/$artist/$album"
       +                        mkdir -p "$outdir"
       +                        mv "${f}" "$outdir"
       +                        mpc update --wait >/dev/null
       +                        if [ "$queue" = 1 ]; then
       +                                mpc findadd \
       +                                        artist "$artist" \
       +                                        album "$album" \
       +                                        title "$song"
       +                        fi
       +                else
       +                        mv "${f}" "$oldpwd/"
       +                fi
                done
        
                IFS=$SAVEIFS
        
       -        if [ "$move_music" = 1 ]; then
       -                outdir="$musicroot/$artist/$album"
       -                mkdir -p "$outdir"
       -                mv ./*.mp3 "$outdir"
       -                mpc update --wait >/dev/null
       -                if [ "$queue" = 1 ]; then
       -                        mpc findadd \
       -                                artist "$artist" \
       -                                album "$album" \
       -                                title "$song"
       -                fi
       -        else
       -                mv ./*.mp3 "$oldpwd/"
       -        fi
       -
                rmdir "$outputdir"
                cd - >/dev/null
        }