Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 2 of 2
  1. #1
    Jeremy Kerr
    Guest

    [RFC/PATCH] squeezecenter: fall back to glob forartwork

    I have my album artwork in a file named after the album. For example:

    Underworld/dubnobasswithmyheadman/dubnobasswithmyheadman.jpg

    The %ALBUM.jpg pattern nearly works for my needs, but breaks in a couple
    of situations:

    * where the image isn't a specific extension - if I have a .png or
    ..jpeg cover art file, there's doesn't seem a way to handle this. If I
    don't specify an extension, the scanner assumes '.jpg':

    Underworld/AHundredDaysOff/AHundredDaysOff.jpg
    Underworld/Beaucoup Fish/Beaucoup Fish.png

    - won't work, as the extension varies

    * where the filename needs to differ from the album name. For example,
    the album has a '/' in the name:

    Underworld/Dirty Epic-Cowgirl/Dirty Epic-Cowgirl.jpg

    - won't work, as the album name is actually "Dirty Epic/Cowgirl", but
    the slash has been replaced.

    This change falls back to a glob to find a cover art file for the album,
    if we haven't discovered one yet. The glob pattern is *.ext, where ext
    is any of the items in the existing list of acceptable extensions. If
    there are multiple matches, we just use the first.

    Tested on Linux. File::Glob is in the Perl core, so should work on Mac
    and Windows too, but testing would be great.

    Signed-off-by: Jeremy Kerr <jk (AT) ozlabs (DOT) org>

    ---

    server/Slim/Music/Artwork.pm | 28 ++++++++++++++++++++++++++++
    1 file changed, 28 insertions(+)

    Index: squeezecenter/server/Slim/Music/Artwork.pm
    ================================================== =================
    --- squeezecenter.orig/server/Slim/Music/Artwork.pm 2008-09-01 21:31:12.000000000 +1000
    +++ squeezecenter/server/Slim/Music/Artwork.pm 2008-09-01 21:59:45.000000000 +1000
    @@ -22,6 +22,7 @@ use strict;
    use File::Basename qw(dirname);
    use File::Slurp;
    use File::Spec::Functions qw(:ALL);
    +use File::Glob ':glob';
    use Path::Class;
    use Scalar::Util qw(blessed);
    use Tie::Cache::LRU;
    @@ -366,6 +367,33 @@ sub _readCoverArtFiles {
    }
    }

    + # try to glob for a suitable image
    + my @patterns = map { $parentDir->file('*.' . $_) } @ext;
    +
    + for my $pattern (@patterns) {
    +
    + $log->info("trying glob $pattern");
    +
    + my @match = bsd_glob($pattern);
    +
    + next unless @match;
    +
    + $file = $match[0];
    +
    + my ($body, $contentType) = $class->getImageContentAndType($file);
    +
    + if ($body && $contentType) {
    +
    + $log->info("Found image file from glob: $file");
    +
    + $lastFile{$trackId} = $file;
    +
    + return ($body, $contentType, $file);
    +
    + }
    + }
    +
    +
    return undef;
    }


  2. #2
    Administrator andyg's Avatar
    Join Date
    Jan 2006
    Location
    Pittsburgh, PA
    Posts
    7,396

    [RFC/PATCH] squeezecenter: fall back to glob forartwork

    Thanks for the patch, can you file a bug? There's an existing
    enhancement filed about finding the first image file in a directory
    regardless of file name, but I can't find it right now.

    On Sep 1, 2008, at 8:42 AM, Jeremy Kerr wrote:

    > I have my album artwork in a file named after the album. For example:
    >
    > Underworld/dubnobasswithmyheadman/dubnobasswithmyheadman.jpg
    >
    > The %ALBUM.jpg pattern nearly works for my needs, but breaks in a
    > couple
    > of situations:
    >
    > * where the image isn't a specific extension - if I have a .png or
    > .jpeg cover art file, there's doesn't seem a way to handle this. If I
    > don't specify an extension, the scanner assumes '.jpg':
    >
    > Underworld/AHundredDaysOff/AHundredDaysOff.jpg
    > Underworld/Beaucoup Fish/Beaucoup Fish.png
    >
    > - won't work, as the extension varies
    >
    > * where the filename needs to differ from the album name. For example,
    > the album has a '/' in the name:
    >
    > Underworld/Dirty Epic-Cowgirl/Dirty Epic-Cowgirl.jpg
    >
    > - won't work, as the album name is actually "Dirty Epic/Cowgirl", but
    > the slash has been replaced.
    >
    > This change falls back to a glob to find a cover art file for the
    > album,
    > if we haven't discovered one yet. The glob pattern is *.ext, where ext
    > is any of the items in the existing list of acceptable extensions. If
    > there are multiple matches, we just use the first.
    >
    > Tested on Linux. File::Glob is in the Perl core, so should work on Mac
    > and Windows too, but testing would be great.
    >
    > Signed-off-by: Jeremy Kerr <jk (AT) ozlabs (DOT) org>
    >
    > ---
    >
    > server/Slim/Music/Artwork.pm | 28 ++++++++++++++++++++++++++++
    > 1 file changed, 28 insertions(+)
    >
    > Index: squeezecenter/server/Slim/Music/Artwork.pm
    > ================================================== =================
    > --- squeezecenter.orig/server/Slim/Music/Artwork.pm 2008-09-01
    > 21:31:12.000000000 +1000
    > +++ squeezecenter/server/Slim/Music/Artwork.pm 2008-09-01
    > 21:59:45.000000000 +1000
    > @@ -22,6 +22,7 @@ use strict;
    > use File::Basename qw(dirname);
    > use File::Slurp;
    > use File::Spec::Functions qw(:ALL);
    > +use File::Glob ':glob';
    > use Path::Class;
    > use Scalar::Util qw(blessed);
    > use Tie::Cache::LRU;
    > @@ -366,6 +367,33 @@ sub _readCoverArtFiles {
    > }
    > }
    >
    > + # try to glob for a suitable image
    > + my @patterns = map { $parentDir->file('*.' . $_) } @ext;
    > +
    > + for my $pattern (@patterns) {
    > +
    > + $log->info("trying glob $pattern");
    > +
    > + my @match = bsd_glob($pattern);
    > +
    > + next unless @match;
    > +
    > + $file = $match[0];
    > +
    > + my ($body, $contentType) = $class->getImageContentAndType($file);
    > +
    > + if ($body && $contentType) {
    > +
    > + $log->info("Found image file from glob: $file");
    > +
    > + $lastFile{$trackId} = $file;
    > +
    > + return ($body, $contentType, $file);
    > +
    > + }
    > + }
    > +
    > +
    > return undef;
    > }
    >
    >

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •