summaryrefslogtreecommitdiff
path: root/plugins/artwork
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-04-09 16:29:23 +0200
committerGravatar waker <wakeroid@gmail.com>2012-04-09 16:29:23 +0200
commit516f25073a726709abb83c3b73bd1e53404514c9 (patch)
tree68113731910c0df756717191a9cfaf55be514130 /plugins/artwork
parent6502057510696ea575a1cf0143dec02acb7cf01c (diff)
parent1ed51a80ec0979bc0be453f75548c59965fbd6f5 (diff)
Merge branch 'master' into devel
Conflicts: plugins/gtkui/callbacks.c plugins/gtkui/callbacks.h plugins/gtkui/gtkui.h
Diffstat (limited to 'plugins/artwork')
-rw-r--r--plugins/artwork/albumartorg.c2
-rw-r--r--plugins/artwork/albumartorg.h2
-rw-r--r--plugins/artwork/artwork.c145
-rw-r--r--plugins/artwork/escape.h2
-rw-r--r--plugins/artwork/lastfm.h2
5 files changed, 79 insertions, 74 deletions
diff --git a/plugins/artwork/albumartorg.c b/plugins/artwork/albumartorg.c
index 51ca54cb..c07bb82c 100644
--- a/plugins/artwork/albumartorg.c
+++ b/plugins/artwork/albumartorg.c
@@ -1,6 +1,6 @@
/*
DeaDBeeF - ultimate music player for GNU/Linux systems with X11
- Copyright (C) 2009-2011 Alexey Yakovenko <waker@users.sourceforge.net>
+ Copyright (C) 2009-2012 Alexey Yakovenko <waker@users.sourceforge.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
diff --git a/plugins/artwork/albumartorg.h b/plugins/artwork/albumartorg.h
index 49231b04..c561b4f7 100644
--- a/plugins/artwork/albumartorg.h
+++ b/plugins/artwork/albumartorg.h
@@ -1,6 +1,6 @@
/*
DeaDBeeF - ultimate music player for GNU/Linux systems with X11
- Copyright (C) 2009-2011 Alexey Yakovenko <waker@users.sourceforge.net>
+ Copyright (C) 2009-2012 Alexey Yakovenko <waker@users.sourceforge.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
diff --git a/plugins/artwork/artwork.c b/plugins/artwork/artwork.c
index 7fad8166..5dffd714 100644
--- a/plugins/artwork/artwork.c
+++ b/plugins/artwork/artwork.c
@@ -824,83 +824,88 @@ fetcher_thread (void *none)
make_cache_path (cache_path, sizeof (cache_path), param->album, param->artist, -1);
int got_pic = 0;
- // try to load embedded from id3v2
if (deadbeef->is_local_file (param->fname)) {
if (artwork_enable_embedded) {
- trace ("trying to load artwork from id3v2 tag for %s\n", param->fname);
- DB_id3v2_tag_t tag;
- memset (&tag, 0, sizeof (tag));
- DB_FILE *fp = deadbeef->fopen (param->fname);
- current_file = fp;
- if (fp) {
- int res = deadbeef->junk_id3v2_read_full (NULL, &tag, fp);
- if (!res) {
- for (DB_id3v2_frame_t *f = tag.frames; f; f = f->next) {
- if (!strcmp (f->id, "APIC")) {
-
- if (f->size < 20) {
- trace ("artwork: id3v2 APIC frame is too small\n");
- continue;
- }
- uint8_t *data = f->data;
- uint8_t *end = f->data + f->size;
- int enc = *data;
- data++; // enc
- // mime-type must always be ASCII - hence enc is 0 here
- uint8_t *mime_end = id3v2_skip_str (0, data, end);
- if (!mime_end) {
- trace ("artwork: corrupted id3v2 APIC frame\n");
- continue;
- }
- if (strcasecmp (data, "image/jpeg") && strcasecmp (data, "image/png")) {
- trace ("artwork: unsupported mime type: %s\n", data);
- continue;
- }
- if (*mime_end != 3) {
- trace ("artwork: picture type=%d, skipped: %s\n", *mime_end);
- continue;
- }
- trace ("artwork: mime-type=%s, picture type: %d\n", data, *mime_end);
- data = mime_end;
- data++; // picture type
- data = id3v2_skip_str (enc, data, end); // description
- if (!data) {
- trace ("artwork: corrupted id3v2 APIC frame\n");
- continue;
- }
- int sz = f->size - (data - f->data);
-
- char tmp_path[1024];
- trace ("will write id3v2 APIC into %s\n", cache_path);
- snprintf (tmp_path, sizeof (tmp_path), "%s.part", cache_path);
- FILE *out = fopen (tmp_path, "w+b");
- if (!out) {
- trace ("artwork: failed to open %s for writing\n", tmp_path);
- break;
- }
- if (fwrite (data, 1, sz, out) != sz) {
- trace ("artwork: failed to write id3v2 picture into %s\n", tmp_path);
+ // try to load embedded from id3v2
+ {
+ trace ("trying to load artwork from id3v2 tag for %s\n", param->fname);
+ DB_id3v2_tag_t tag;
+ memset (&tag, 0, sizeof (tag));
+ DB_FILE *fp = deadbeef->fopen (param->fname);
+ current_file = fp;
+ if (fp) {
+ int res = deadbeef->junk_id3v2_read_full (NULL, &tag, fp);
+ if (!res) {
+ for (DB_id3v2_frame_t *f = tag.frames; f; f = f->next) {
+ if (!strcmp (f->id, "APIC")) {
+ if (f->size < 20) {
+ trace ("artwork: id3v2 APIC frame is too small\n");
+ continue;
+ }
+ uint8_t *data = f->data;
+ if (tag.version[0] == 4) {
+ // skip size
+ data += 4;
+ }
+ uint8_t *end = f->data + f->size;
+ int enc = *data;
+ data++; // enc
+ // mime-type must always be ASCII - hence enc is 0 here
+ uint8_t *mime_end = id3v2_skip_str (enc, data, end);
+ if (!mime_end) {
+ trace ("artwork: corrupted id3v2 APIC frame\n");
+ continue;
+ }
+ if (strcasecmp (data, "image/jpeg") && strcasecmp (data, "image/png")) {
+ trace ("artwork: unsupported mime type: %s\n", data);
+ continue;
+ }
+ if (*mime_end != 3) {
+ trace ("artwork: picture type=%d, skipped: %s\n", *mime_end);
+ continue;
+ }
+ trace ("artwork: mime-type=%s, picture type: %d\n", data, *mime_end);
+ data = mime_end;
+ data++; // picture type
+ data = id3v2_skip_str (enc, data, end); // description
+ if (!data) {
+ trace ("artwork: corrupted id3v2 APIC frame\n");
+ continue;
+ }
+ int sz = f->size - (data - f->data);
+
+ char tmp_path[1024];
+ trace ("will write id3v2 APIC into %s\n", cache_path);
+ snprintf (tmp_path, sizeof (tmp_path), "%s.part", cache_path);
+ FILE *out = fopen (tmp_path, "w+b");
+ if (!out) {
+ trace ("artwork: failed to open %s for writing\n", tmp_path);
+ break;
+ }
+ if (fwrite (data, 1, sz, out) != sz) {
+ trace ("artwork: failed to write id3v2 picture into %s\n", tmp_path);
+ fclose (out);
+ unlink (tmp_path);
+ break;
+ }
fclose (out);
+ int err = rename (tmp_path, cache_path);
+ if (err != 0) {
+ trace ("Failed not move %s to %s: %s\n", tmp_path, cache_path, strerror (err));
+ unlink (tmp_path);
+ break;
+ }
unlink (tmp_path);
+ got_pic = 1;
break;
}
- fclose (out);
- int err = rename (tmp_path, cache_path);
- if (err != 0) {
- trace ("Failed not move %s to %s: %s\n", tmp_path, cache_path, strerror (err));
- unlink (tmp_path);
- break;
- }
- unlink (tmp_path);
- got_pic = 1;
- break;
}
}
- }
- deadbeef->junk_id3v2_free (&tag);
- current_file = NULL;
- deadbeef->fclose (fp);
+ deadbeef->junk_id3v2_free (&tag);
+ current_file = NULL;
+ deadbeef->fclose (fp);
+ }
}
// try to load embedded from apev2
@@ -975,8 +980,8 @@ fetcher_thread (void *none)
}
#ifdef USE_METAFLAC
+ // try to load embedded from flac metadata
{
- // try to load embedded from flac metadata
FLAC__StreamMetadata *meta = NULL;
do {
trace ("trying to load artwork flac metadata for %s\n", param->fname);
@@ -1431,7 +1436,7 @@ static DB_artwork_plugin_t plugin = {
.plugin.plugin.name = "Album Artwork",
.plugin.plugin.descr = "Loads album artwork either from local directories or from internet",
.plugin.plugin.copyright =
- "Copyright (C) 2009-2011 Alexey Yakovenko <waker@users.sourceforge.net>\n"
+ "Copyright (C) 2009-2012 Alexey Yakovenko <waker@users.sourceforge.net>\n"
"Copyright (C) 2009-2011 Viktor Semykin <thesame.ml@gmail.com>\n"
"\n"
"This program is free software; you can redistribute it and/or\n"
diff --git a/plugins/artwork/escape.h b/plugins/artwork/escape.h
index 75d24091..e23421a2 100644
--- a/plugins/artwork/escape.h
+++ b/plugins/artwork/escape.h
@@ -1,6 +1,6 @@
/*
DeaDBeeF - ultimate music player for GNU/Linux systems with X11
- Copyright (C) 2009-2011 Alexey Yakovenko <waker@users.sourceforge.net>
+ Copyright (C) 2009-2012 Alexey Yakovenko <waker@users.sourceforge.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
diff --git a/plugins/artwork/lastfm.h b/plugins/artwork/lastfm.h
index cef71919..b5c12b8b 100644
--- a/plugins/artwork/lastfm.h
+++ b/plugins/artwork/lastfm.h
@@ -1,6 +1,6 @@
/*
DeaDBeeF - ultimate music player for GNU/Linux systems with X11
- Copyright (C) 2009-2011 Alexey Yakovenko <waker@users.sourceforge.net>
+ Copyright (C) 2009-2012 Alexey Yakovenko <waker@users.sourceforge.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License