Bug 36

Summary: Album art stored in wrong directory
Product: abcde Reporter: Peter Hülstede <phuel22>
Component: Album artAssignee: Andrew Strong <andrew.david.strong>
Status: CONFIRMED ---    
Severity: normal CC: metakirby5, steve
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: All   

Description Peter Hülstede 2016-07-19 07:39:37 BST
When the OUTPUTFORMAT is "${ARTISTFILE}/${ALBUMFILE}/${TRACKNUM} ${TRACKFILE}" the album art is stored in the artist directory instead of the album directory.

The reason is that in this case the ALBUMARTDIR in do_getalbumart() is "Artist/Album/".
do_getalbumart() then calls $(dirname "$OUPUTDIR/$ALBUMARTDIR") and ends up with "Artist/", which is not how it was intended.

A possible fix is to check for the trailing slash before calling dirname:

    FINALALBUMARTDIR="$OUTPUTDIR/$ALBUMARTDIR"
    if [ "${FINALALBUMARTDIR: -1}" != "/" ] ; then
        FINALALBUMARTDIR="$(dirname "$OUTPUTDIR/$ALBUMARTDIR")"
 
instead of

    FINALALBUMARTDIR="$(dirname "$OUTPUTDIR/$ALBUMARTDIR")"

in abcde do_getalbumart() line 3238.
Comment 1 Ethan 2017-08-13 07:12:39 BST
(In reply to Peter Hülstede from comment #0)
> When the OUTPUTFORMAT is "${ARTISTFILE}/${ALBUMFILE}/${TRACKNUM}
> ${TRACKFILE}" the album art is stored in the artist directory instead of the
> album directory.
> 
> The reason is that in this case the ALBUMARTDIR in do_getalbumart() is
> "Artist/Album/".
> do_getalbumart() then calls $(dirname "$OUPUTDIR/$ALBUMARTDIR") and ends up
> with "Artist/", which is not how it was intended.
> 
> A possible fix is to check for the trailing slash before calling dirname:
> 
>     FINALALBUMARTDIR="$OUTPUTDIR/$ALBUMARTDIR"
>     if [ "${FINALALBUMARTDIR: -1}" != "/" ] ; then
>         FINALALBUMARTDIR="$(dirname "$OUTPUTDIR/$ALBUMARTDIR")"
>  
> instead of
> 
>     FINALALBUMARTDIR="$(dirname "$OUTPUTDIR/$ALBUMARTDIR")"
> 
> in abcde do_getalbumart() line 3238.

I think this should work:
     FINALALBUMARTDIR="$OUTPUTDIR/${ALBUMARTDIR%/*}"