Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
for (it = m_itdb->tracks; it != NULL; it = it->next) {
    Itdb_Track *song = (Itdb_Track *)it->data;

    if (song->has_artwork == 0x02) {
	continue;
    }
    GdkPixbuf *pixbuf = (GdkPixbuf*) itdb_artwork_get_pixbuf( song->itdb->device,
						song->artwork, -1, -1);
    if(pixbuf == NULL ) {
	debug() << "unexpected null pixbuf";
	continue;
    }

    g_print ("Track %d (%016"G_GINT64_MODIFIER"x) %s-%s-%s (%08x)\n",
	    count, song->dbid,
	    song->artist, song->album,
	    song->title, song->mhii_link);

    gint width;
    gint height;
    gchar* filename;

    g_object_get (G_OBJECT (pixbuf),
		  "width", &width,
		  "height", &height,
		  NULL);

    filename = g_strdup_printf ("/home/seb/%d-%s-%s-%s-%dx%d.png", count, song->artist, song->album, song->title, width, height);

    g_print ("  --> %s\n", filename );

    gdk_pixbuf_save (pixbuf, filename, "png", NULL, NULL);
    gdk_pixbuf_unref (pixbuf);
    g_free (filename);

    count++;
}