All pastes #1666519 Raw Edit

teuf

public text v1 · immutable
#1666519 ·published 2009-11-11 14:16 UTC
rendered paste body
diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.cindex 1548f0d..cd4e68b 100644--- a/src/itdb_itunesdb.c+++ b/src/itdb_itunesdb.c@@ -1975,7 +1975,7 @@ static glong get_mhip (FImport *fimp, glong mhip_seek)    be. On error -1 is returned and fimp->error is set    appropriately. */ /* get_mhyp */-static glong get_playlist (FImport *fimp, glong mhyp_seek)+static glong get_playlist (FImport *fimp, guint mhsd_type, glong mhyp_seek) {   guint32 i, mhipnum, mhod_num;   glong nextseek, mhod_seek, mhip_seek;@@ -2157,7 +2157,11 @@ static glong get_playlist (FImport *fimp, glong mhyp_seek) #endif    /* add new playlist */-  itdb_playlist_add (fimp->itdb, plitem, -1);+  if (mhsd_type == 5) {+      itdb_playlist_add (fimp->itdb, plitem, -1);+  } else {+      itdb_playlist_add (fimp->itdb, plitem, -1);+  }    mhip_seek = mhod_seek; @@ -2751,6 +2755,7 @@ static gboolean parse_playlists (FImport *fimp, glong mhsd_seek)     FContents *cts;     glong seek, mhlp_seek;     guint32 nr_playlists, i;+    guint mhsd_type;      g_return_val_if_fail (fimp, FALSE);     g_return_val_if_fail (fimp->itdb, FALSE);@@ -2762,11 +2767,11 @@ static gboolean parse_playlists (FImport *fimp, glong mhsd_seek)      g_return_val_if_fail (check_header_seek (cts, "mhsd", mhsd_seek), 			  FALSE);+    mhsd_type = get32lint (cts, mhsd_seek+12);      /* The mhlp header should be the next after the mhsd header. In        order to allow slight changes in the format, we skip headers        until we find an mhlp inside the given mhsd */-     mhlp_seek = find_next_a_in_b (cts, "mhlp", mhsd_seek, mhsd_seek);     CHECK_ERROR (fimp, FALSE); @@ -2791,7 +2796,7 @@ static gboolean parse_playlists (FImport *fimp, glong mhsd_seek)     { 	/* seek could be -1 if first mhyp could not be found */ 	if (seek != -1)-	    seek = get_playlist (fimp, seek);+	    seek = get_playlist (fimp, mhsd_type, seek); 	if (fimp->error) return FALSE; 	if (seek == -1) 	{   /* this should not be -- issue warning */diff --git a/src/itdb_sqlite.c b/src/itdb_sqlite.cindex 5b3b325..4ad4122 100644--- a/src/itdb_sqlite.c+++ b/src/itdb_sqlite.c@@ -742,13 +742,21 @@ static int mk_Library(Itdb_iTunesDB *itdb, 	else 	    sqlite3_bind_int(stmt_item, ++idx, 0); 	/* album_pid -7670716306765259718 */-	this_album = g_hash_table_lookup(album_ids, track);+	if (track->album != NULL) {+	    this_album = g_hash_table_lookup(album_ids, track);+	} else {+	    this_album = NULL;+	} 	if (this_album) { 	    album_pid = this_album->sql_id; 	} 	sqlite3_bind_int64(stmt_item, ++idx, album_pid); 	/* artist_pid -7576753259813584028 */-	this_artist = g_hash_table_lookup(artist_ids, track);+	if (track->artist != NULL) {+	    this_artist = g_hash_table_lookup(artist_ids, track);+	} else {+	    this_artist = NULL;+	} 	if (this_artist) { 	    artist_pid = this_artist->sql_id; 	}