int main (int argc, char **argv) { Itdb_iTunesDB *db; GList *it; GList *covers; int nb_covers; if (argc < 3) { g_print ("Usage: %s mountpoint image-dir\n", argv[0]); return 1; } setlocale (LC_ALL, ""); #if !GLIB_CHECK_VERSION(2, 36, 0) g_type_init (); #endif covers = get_cover_list (argv[2]); if (covers == NULL) { g_print ("Error, %s should be a directory containing pictures\n", argv[2]); return 1; } nb_covers = g_list_length (covers); db = itdb_parse (argv[1], NULL); if (db == NULL) { g_print ("Error reading iPod database\n"); return 1; } for (it = db->tracks; it != NULL; it = it->next) { Itdb_Track *song; const char *coverpath; song = (Itdb_Track*)it->data; itdb_artwork_remove_thumbnails (song->artwork); coverpath = g_list_nth_data (covers, g_random_int_range (0, nb_covers)); itdb_track_set_thumbnails (song, coverpath); /* g_print ("%s - %s - %s gets %s\n", song->artist, song->album, song->title, coverpath);*/ } /* if (db->tracks != NULL) { Itdb_Track *song; const char *coverpath; song = (Itdb_Track *)db->tracks->data; coverpath = g_list_nth_data (covers, g_random_int_range (0, nb_covers)); itdb_track_remove_thumbnail (song); itdb_track_set_thumbnail (song, coverpath); }*/ itdb_write (db, NULL); itdb_free (db); g_list_foreach (covers, (GFunc)g_free, NULL); g_list_free (covers); return 0; }
int main (int argc, char **argv) { Itdb_iTunesDB *db; if (argc < 2) { g_print ("Usage: %s mountpoint\n", argv[0]); return 1; } setlocale (LC_ALL, ""); g_type_init (); db = itdb_parse (argv[1], NULL); if (db == NULL) { g_print ("Error reading iPod database\n"); return 1; } g_print ("========== ArtworkDB ==========\n"); save_thumbnails (db); itdb_free (db); return 0; }
static void rb_ipod_db_dispose (GObject *object) { RbIpodDbPrivate *priv = IPOD_DB_GET_PRIVATE (object); gboolean db_dirty = FALSE; if (priv->saving_thread != NULL) { g_thread_join (priv->saving_thread); priv->saving_thread = NULL; } if (priv->save_idle_id != 0) { g_source_remove (priv->save_idle_id); priv->save_idle_id = 0; } /* Be careful, the order of the following cleanups is important, first * we process the queued ipod database modifications, which may trigger * modifications of save_timeout_id, then we make sure we cancel * potential in progress saves, and finally we sync the database */ if (priv->delayed_actions) { if (g_queue_get_length (priv->delayed_actions) != 0) { rb_ipod_db_process_delayed_actions (RB_IPOD_DB(object)); db_dirty = TRUE; } /* The queue should be empty, but better be safe than * leaking */ g_queue_foreach (priv->delayed_actions, (GFunc)rb_ipod_free_delayed_action, NULL); g_queue_free (priv->delayed_actions); priv->delayed_actions = NULL; } if (priv->save_timeout_id != 0) { g_source_remove (priv->save_timeout_id); priv->save_timeout_id = 0; db_dirty = TRUE; } if (priv->itdb != NULL) { if (db_dirty) { rb_itdb_save (RB_IPOD_DB (object), NULL); } itdb_free (priv->itdb); priv->itdb = NULL; } G_OBJECT_CLASS (rb_ipod_db_parent_class)->dispose (object); }
int main (int argc, char *argv[]) { GError *error=NULL; Itdb_iTunesDB *itdb; gchar *infile = NULL; gchar *outfile = NULL; if (argc >= 2) infile = argv[1]; if (argc >= 3) outfile = argv[2]; if (infile == 0) { printf ("Usage: %s <infile> [<outfile>]\n", g_basename(argv[0])); exit (0); } itdb = itdb_parse_file (infile, &error); printf ("%p\n", itdb); if (error) { if (error->message) puts (error->message); g_error_free (error); error = NULL; } if (itdb) { printf ("tracks: %d\n", g_list_length (itdb->tracks)); printf ("playlists: %d\n", g_list_length (itdb->playlists)); if (outfile) itdb_write_file (itdb, outfile, &error); if (error) { if (error->message) puts (error->message); g_error_free (error); error = NULL; } } itdb_free (itdb); return 0; }
Itdb_iTunesDB* IpodDeviceHelper::parseItdb( const QString &mountPoint, QString &errorMsg ) { Itdb_iTunesDB *itdb; GError *error = 0; errorMsg.clear(); itdb = itdb_parse( QFile::encodeName( mountPoint ), &error ); if( error ) { if( itdb ) itdb_free( itdb ); itdb = 0; errorMsg = QString::fromUtf8( error->message ); g_error_free( error ); error = 0; } if( !itdb && errorMsg.isEmpty() ) errorMsg = i18n( "Cannot parse iTunes database due to an unreported error." ); return itdb; }
GpodDb::~GpodDb () { itdb_free (DB_); }