Skip to content

was the rename function doing things when the compgen line was broken that it isn't now #8

@iconoclasthero

Description

@iconoclasthero
## this should still work, but the array version is probably cleaner...
#if ! compgen -G '* -- Part @(??|???): *.opus' &> /dev/null; then
#  rename
#fi

## depends on nullglob
matches=( * -- Part @(??|???): *.opus )
! (( ${#matches[@]} )) && rename

the line if ! compgen -G *\ --\ Part\ @(??|???)\:\ *opus &> /dev/null; then was not working because it never matched and thus everything went to rename() function.
this is now corrected but has been supplanted by the array match method anyway...however this means that things that didn't need to be renamed are now not going to the rename function... which is a problem if rename() was doing more than it was supposed to as a result.

e.g., it was removing brackets from titles which fixed one problem but caused another. one thing got fixed here:

#[[ "$opuspartdur" ]] && duration="$opuspartdur" ||
##also changing what its using for part digits here to just straight fuckin' parts:
##           duration=$(find . -type f \( -iname "$title -- Part ??:*.opus" -o -iname "$title -- Part ???:*.opus" \) -print0 |
#           duration=$(find . -type f \( -iname "$title -- Part *: *.opus" -o -iname "$title -- Part ???:*.opus" \) -print0 |
#           xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null |
#           perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' |
#           tail -n 1)


if [[ "$opuspartdur" ]]; then
  duration="$opuspartdur"
else
  if [[ "$title" = *\[* ]] || [[ "$title" = *\]* ]]; then
    findtitle="${title//\[/\\[}"; findtitle="${findtitle//\]/\\]}"
    pause "findtitle=$findtitle"
#also changing what its using for part digits here to just straight fuckin' parts:
#           duration=$(find . -type f \( -iname "$title -- Part ??:*.opus" -o -iname "$title -- Part ???:*.opus" \) -print0 |
           duration=$(find . -type f \( -iname "$findtitle -- Part *: *.opus" -o -iname "$findtitle -- Part ???:*.opus" \) -print0
|
           xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null |
           perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' |
           tail -n 1)
  fi
fi

where the duration wasn't working because find treats brackets as a character class instead of literal brackets.
this had been breaking in m4b2opus the move from temp of the $title -- Audiobook.opus back to the $SWD but is fixed now since the brackets aren't being removed from the "$title" in indexopus (and not passed back to m4b2opus) but find is still able to get the duration b/c the brackets are escaped in the find term.

HOWEVER it's possible that rename() was doing other things that are now going to cause problems...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions