summaryrefslogtreecommitdiffstats
path: root/src/db-artwork-parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/db-artwork-parser.c')
-rw-r--r--src/db-artwork-parser.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/db-artwork-parser.c b/src/db-artwork-parser.c
index 4a1997c..8be8be7 100644
--- a/src/db-artwork-parser.c
+++ b/src/db-artwork-parser.c
@@ -22,6 +22,12 @@
*
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+
#include "itdb.h"
#include "db-artwork-debug.h"
#include "db-artwork-parser.h"
@@ -98,8 +104,32 @@ get_utf16_string (void* buffer, gint length)
}
+static char *
+mhod3_get_ithmb_filename (MhodHeaderArtworkType3 *mhod3,
+ Itdb_iTunesDB *db)
+{
+ char *paths[] = {"iPod_Control", "Artwork", NULL, NULL};
+ char *filename;
+ char *result;
+
+ g_assert (mhod3 != NULL);
+ g_assert (db != NULL);
+
+ filename = get_utf16_string (mhod3->string, mhod3->string_len);
+ if ((filename == NULL) || (strlen (filename) < 2)) {
+ return NULL;
+ }
+
+ paths[2] = filename+1;
+ result = itdb_resolve_path (db->mountpoint, (const char **)paths);
+ g_free (filename);
+ return result;
+}
+
+
static int
-parse_mhod_3 (DBParseContext *ctx, Itdb_Image *image, GError *error)
+parse_mhod_3 (DBParseContext *ctx, Itdb_iTunesDB *db,
+ Itdb_Image *image, GError *error)
{
MhodHeader *mhod;
MhodHeaderArtworkType3 *mhod3;
@@ -117,7 +147,7 @@ parse_mhod_3 (DBParseContext *ctx, Itdb_Image *image, GError *error)
if ((GINT_FROM_LE (mhod3->type) & 0x00FFFFFF) != MHOD_ARTWORK_TYPE_FILE_NAME) {
return -1;
}
- image->filename = get_utf16_string (mhod3->string, mhod3->string_len);
+ image->filename = mhod3_get_ithmb_filename (mhod3, db);
dump_mhod_type_3 (mhod3);
return 0;
}
@@ -145,7 +175,7 @@ parse_mhni (DBParseContext *ctx, iPodSong *song, GError *error)
if (mhod_ctx == NULL) {
return -1;
}
- parse_mhod_3 (mhod_ctx, thumb, error);
+ parse_mhod_3 (mhod_ctx, song->itdb, thumb, error);
g_free (mhod_ctx);
return 0;