Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:nuklly
libgpod
0005-iPod-Nano-6-libhashAB.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0005-iPod-Nano-6-libhashAB.patch of Package libgpod
diff --git a/src/itdb_sqlite.c b/src/itdb_sqlite.c index 3d3cf44..46995a8 100644 --- a/src/itdb_sqlite.c +++ b/src/itdb_sqlite.c @@ -46,6 +46,7 @@ /** time zone offset in seconds */ static uint32_t tzoffset = 0; +static uint32_t order_max = INT32_MAX; static uint32_t timeconv(time_t tv) { @@ -231,7 +232,7 @@ static int mk_Dynamic(Itdb_iTunesDB *itdb, const char *outpath) if (itdb->tracks) { printf("[%s] - processing %d tracks\n", __func__, g_list_length(itdb->tracks)); - if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"item_stats\" (item_pid,has_been_played,date_played,play_count_user,play_count_recent,date_skipped,skip_count_user,skip_count_recent,bookmark_time_ms,bookmark_time_ms_common,user_rating,user_rating_common) VALUES(?,?,?,?,?,?,?,?,?,?,?,?);", -1, &stmt, NULL)) { + if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"item_stats\" (item_pid,has_been_played,date_played,play_count_user,play_count_recent,date_skipped,skip_count_user,skip_count_recent,bookmark_time_ms,bookmark_time_ms_common,user_rating,user_rating_common,rental_expired,play_count_user_original,skip_count_user_original,genius_id) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", -1, &stmt, NULL)) { fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); goto leave; } @@ -245,32 +246,44 @@ static int mk_Dynamic(Itdb_iTunesDB *itdb, const char *outpath) fprintf(stderr, "[%s] 1 sqlite3_reset returned %d\n", __func__, res); } idx = 0; - /* item_pid */ + /* field 1: item_pid */ sqlite3_bind_int64(stmt, ++idx, track->dbid); - /* has_been_played */ + /* field 2: has_been_played */ sqlite3_bind_int(stmt, ++idx, (track->playcount > 0) ? 1 : 0); /* date_played */ - sqlite3_bind_int(stmt, ++idx, timeconv(track->time_played)); - /* play_count_user */ + /* sqlite3_bind_int(stmt, ++idx, timeconv(track->time_played)); */ + /* field 3: date_played: zero */ + sqlite3_bind_int(stmt, ++idx, 0); + /* field 4: play_count_user */ sqlite3_bind_int(stmt, ++idx, track->playcount); - /* play_count_recent */ + /* field 5: play_count_recent */ sqlite3_bind_int(stmt, ++idx, track->recent_playcount); /* date_skipped */ - sqlite3_bind_int(stmt, ++idx, timeconv(track->last_skipped)); - /* skip_count_user */ + /* sqlite3_bind_int(stmt, ++idx, timeconv(track->last_skipped)); */ + /* field 6: date_skipped: 0 */ + sqlite3_bind_int(stmt, ++idx, 0); + /* field 7: skip_count_user */ sqlite3_bind_int(stmt, ++idx, track->skipcount); - /* skip_count_recent */ + /* field 8: skip_count_recent */ sqlite3_bind_int(stmt, ++idx, track->recent_skipcount); - /* bookmark_time_ms */ + /* field 9: bookmark_time_ms */ sqlite3_bind_double(stmt, ++idx, track->bookmark_time); - /* bookmark_time_ms_common */ + /* field 10: bookmark_time_ms_common */ /* FIXME: is this the same as bookmark_time_ms ??! */ sqlite3_bind_double(stmt, ++idx, track->bookmark_time); - /* user_rating */ + /* field 11: user_rating */ sqlite3_bind_int(stmt, ++idx, track->rating); - /* user_rating_common */ + /* field 12: user_rating_common */ /* FIXME: don't know if this is the right value */ sqlite3_bind_int(stmt, ++idx, track->app_rating); + /* field 13: rental_expired */ + sqlite3_bind_int(stmt, ++idx, 0); + /* field 14: play_count_user_original */ + sqlite3_bind_int(stmt, ++idx, 0); + /* field 15: skip_count_user_original */ + sqlite3_bind_int(stmt, ++idx, 0); + /* field 16: genius_id */ + sqlite3_bind_int(stmt, ++idx, 0); res = sqlite3_step(stmt); if (res == SQLITE_DONE) { @@ -587,6 +600,22 @@ done: va_end(ap); } +const size_t MAX_CAT_SIZE = 256; + +// Check if val appears in arr. Return 1 if true, 0 if false +static int array_exist(uint64_t *arr, size_t size, uint64_t val) { + if(size == MAX_CAT_SIZE) { + return 1; // overflows + } else { + for(size_t i = 0; i < size; i ++) { + if(arr[i] == val) { + return 1; + } + } + return 0; + } +} + static int mk_Library(Itdb_iTunesDB *itdb, GHashTable *album_ids, GHashTable *artist_ids, GHashTable *composer_ids, const char *outpath) @@ -606,6 +635,18 @@ static int mk_Library(Itdb_iTunesDB *itdb, sqlite3_stmt *stmt_artist = NULL; sqlite3_stmt *stmt_composer = NULL; sqlite3_stmt *stmt_video_info = NULL; + + // TODO: genre, track_artist, track_size_calc + uint64_t artist_array[MAX_CAT_SIZE]; // we support at most 256 artists + size_t artist_cnt = 0; + uint64_t genre_array[MAX_CAT_SIZE]; // we support at most 256 genres + size_t genre_cnt = 0; + sqlite3_stmt *stmt_genre = NULL; + sqlite3_stmt *stmt_track_artist = NULL; + sqlite3_stmt *stmt_track_size_calc_audio = NULL; + sqlite3_stmt *stmt_track_size_calc_video = NULL; + sqlite3_stmt *stmt_track_size_calc_music_video = NULL; + char *errmsg = NULL; struct stat fst; GList *gl = NULL; @@ -652,78 +693,96 @@ static int mk_Library(Itdb_iTunesDB *itdb, } goto leave; } - sqlite3_exec(db, "BEGIN;", NULL, NULL, NULL); fprintf(stderr, "[%s] compiling SQL statements\n", __func__); if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"version_info\" VALUES(?,?,?,?,?,?,?);", -1, &stmt_version_info, NULL)) { - fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); + fprintf(stderr, "[%s] version_info sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); goto leave; } - if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"db_info\" VALUES(?,?,?,?,?,?,?,?);", -1, &stmt_db_info, NULL)) { - fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); + if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"db_info\" VALUES(?,?,?,?,?,?,?,?);", -1, &stmt_db_info, NULL)) { // 8 fields + fprintf(stderr, "[%s] db_info sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); goto leave; } if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"container\" " - "VALUES(?,?,?,?,:name,?,?,?,?,?,?,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);", -1, &stmt_container, NULL)) { - fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); + "VALUES(?,?,?,?,:name,?,?,?,?,?,?,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);", -1, &stmt_container, NULL)) { // 29 fields + fprintf(stderr, "[%s] container sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); goto leave; } - if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"genre_map\" (id,genre,genre_order) VALUES(?,?,0);", -1, &stmt_genre_map, NULL)) { - fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); + if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"genre_map\" (id,genre,genre_order,is_unknown,has_music,artist_count_calc,album_count_calc,compilation_count_calc) VALUES(?,?,?,1,1,1,1,0);", -1, &stmt_genre_map, NULL)) { // 8 fields + fprintf(stderr, "[%s] genre_map sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); goto leave; } if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"item\" " - "(pid,media_kind,date_modified,year,is_compilation,remember_bookmark,exclude_from_shuffle,artwork_status,artwork_cache_id," - "start_time_ms,stop_time_ms,total_time_ms,total_burn_time_ms,track_number,track_count,disc_number,disc_count," - "bpm,relative_volume,eq_preset,radio_stream_status,genre_id,album_pid,artist_pid,composer_pid,title,artist,album," - "album_artist,composer,sort_title,sort_artist,sort_album,sort_album_artist,sort_composer,title_order,artist_order," - "album_order,genre_order,composer_order,album_artist_order,album_by_artist_order,series_name_order,comment,grouping," - "description,description_long) " - "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", -1, &stmt_item, NULL)) { - fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); + "(pid,revision_level,media_kind,is_song,is_audio_book,is_music_video,is_movie,is_tv_show," // 8 fields + "is_home_video,is_ringtone,is_tone,is_voice_memo,is_book,is_rental,is_itunes_u," // 15 fields + "is_digital_booklet,is_podcast,date_modified,year,content_rating,content_rating_level,is_compilation," // 22 fields + "is_user_disabled,remember_bookmark,exclude_from_shuffle,part_of_gapless_album,chosen_by_auto_fill,artwork_status,artwork_cache_id," // 29 fields + "start_time_ms,stop_time_ms,total_time_ms,total_burn_time_ms,track_number,track_count,disc_number," // 36 fields + "disc_count,bpm,relative_volume,eq_preset,radio_stream_status,genius_id,genre_id,category_id,album_pid," // 45 fields + "artist_pid,composer_pid,title,artist,album,album_artist,composer,sort_title,sort_artist,sort_album,sort_album_artist,sort_composer," // 57 fields + "title_order,artist_order,album_order,genre_order,composer_order,album_artist_order,album_by_artist_order,series_name_order,comment,grouping," // 67 fields + "description,description_long,collection_description,copyright,track_artist_pid,physical_order,has_lyrics,date_released) " // 75 fields + "VALUES(?,?,?,?,?,?,?,?,?,?," // 10 fields + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?," // 30 fields + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?," // 50 fields + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?," // 70 fields + "?,?,?,?,?);", -1, &stmt_item, NULL)) { // 75 fields + fprintf(stderr, "[%s] insert item sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); goto leave; } - if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT OR IGNORE INTO \"location_kind_map\" VALUES(?,:kind);", -1, &stmt_location_kind_map, NULL)) { - fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); + if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT OR IGNORE INTO \"location_kind_map\" VALUES(?,:kind);", -1, &stmt_location_kind_map, NULL)) { // 2 fields + fprintf(stderr, "[%s] insert location_kind_map sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); goto leave; } - if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"avformat_info\" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?);", -1, &stmt_avformat_info, NULL)) { - fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); + if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"avformat_info\" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?);", -1, &stmt_avformat_info, NULL)) { // 14 fields + fprintf(stderr, "[%s] insert avformat_info sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); goto leave; } - if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"item_to_container\" VALUES(?,?,?,?);", -1, &stmt_item_to_container, NULL)) { - fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); + if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"item_to_container\" VALUES(?,?,?,?);", -1, &stmt_item_to_container, NULL)) { // 4 fields + fprintf(stderr, "[%s] insert item_to_container sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); goto leave; } - if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT OR IGNORE INTO \"album\" VALUES(?,?,?,?,?,?,?,?,?,?,?);", -1, &stmt_album, NULL)) { - fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); + if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT OR IGNORE INTO \"album\" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", -1, &stmt_album, NULL)) { // 21 fields + fprintf(stderr, "[%s] insert album sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); goto leave; } - if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT OR IGNORE INTO \"artist\" VALUES(?,?,?,?,?,?,?);", -1, &stmt_artist, NULL)) { - fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); + if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT OR IGNORE INTO \"artist\" VALUES(?,?,?,?,?,?,?,?,?,?);", -1, &stmt_artist, NULL)) { // 10 fields + fprintf(stderr, "[%s] insert artist sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); goto leave; } - if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT OR IGNORE INTO \"composer\" (pid,name,name_order,sort_name) VALUES(?,?,?,?);", -1, &stmt_composer, NULL)) { - fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); + if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT OR IGNORE INTO \"composer\" (pid,name,name_order,sort_name,is_unknown,has_music) VALUES(?,?,?,?,?,?);", -1, &stmt_composer, NULL)) { + fprintf(stderr, "[%s] insert composer sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); goto leave; } - if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"video_info\" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", -1, &stmt_video_info, NULL)) { - fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); + if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"video_info\" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", -1, &stmt_video_info, NULL)) { // 23 fields + fprintf(stderr, "[%s] insert video_info sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); goto leave; } + /* ========================== Dealing with genre, track_artist, and track_size_calc ===================================== */ + if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT OR IGNORE INTO \"track_artist\" VALUES(?,?,?,?,?,?,?,?,?);", + -1, &stmt_track_artist, NULL)) { + // f1: pid, f2: name, f3: name_order, f4: sort_name, f5: has_songs, f6: has_music_videos + // f7: has_non_compilation_tracks, f8: is_unknown, f9: album_count + fprintf(stderr, "[%s] insert track_artist sqlite3_prepare error: %s\n", __func__, sqlite3_errmsg(db)); + goto leave; + } printf("[%s] - inserting into \"version_info\"\n", __func__); /* INSERT INTO "version_info" VALUES(1,2,40,0,0,0,2); */ + /* INSERT INTO version_info VALUES(1,1,116,0,0,1104,1); */ + idx = 0; /* id */ sqlite3_bind_int(stmt_version_info, ++idx, 1); /* major */ /* FIXME: the versioning scheme needs to be updated in libgpod using */ /* major+minor version, this is a workaround */ - sqlite3_bind_int(stmt_version_info, ++idx, (itdb->version >= 0x28) ? 2 : 1); + /* sqlite3_bind_int(stmt_version_info, ++idx, (itdb->version >= 0x28) ? 2 : 1); */ + sqlite3_bind_int(stmt_version_info, ++idx, 1); // customized /* minor */ - sqlite3_bind_int(stmt_version_info, ++idx, itdb->version); + /* sqlite3_bind_int(stmt_version_info, ++idx, itdb->version); */ + sqlite3_bind_int(stmt_version_info, ++idx, 116); // customized /* compatibility */ /* This has an unknown meaning. use 0. */ sqlite3_bind_int(stmt_version_info, ++idx, 0); @@ -731,7 +790,8 @@ static int mk_Library(Itdb_iTunesDB *itdb, /* This has an unknown meaning. use 0. */ sqlite3_bind_int(stmt_version_info, ++idx, 0); /* device_update_level, default is 0 */ - sqlite3_bind_int(stmt_version_info, ++idx, 0); + /* sqlite3_bind_int(stmt_version_info, ++idx, 0); */ + sqlite3_bind_int(stmt_version_info, ++idx, 1104); // customized /* platform, 1 = MacOS, 2 = Windows */ sqlite3_bind_int(stmt_version_info, ++idx, itdb->priv->platform); @@ -763,7 +823,8 @@ static int mk_Library(Itdb_iTunesDB *itdb, sqlite3_bind_int(stmt_genre_map, ++idx, genre_index++); /* genre */ sqlite3_bind_text(stmt_genre_map, ++idx, track->genre, -1, SQLITE_STATIC); - + /* genre_order: Sign problem? */ + sqlite3_bind_int(stmt_genre_map, ++idx, order_max); res = sqlite3_step(stmt_genre_map); if (res != SQLITE_DONE) { fprintf(stderr, "[%s] sqlite3_step returned %d\n", __func__, res); @@ -938,6 +999,8 @@ static int mk_Library(Itdb_iTunesDB *itdb, idx = 0; /* pid */ sqlite3_bind_int64(stmt_item, ++idx, track->dbid); + /* revision_level */ + sqlite3_bind_null(stmt_item, ++idx); /* media_kind */ /* NOTE: this is one of */ /* song = 1 */ @@ -949,16 +1012,36 @@ static int mk_Library(Itdb_iTunesDB *itdb, /* podcast = 4 */ /* rental = 32768 */ sqlite3_bind_int(stmt_item, ++idx, track->mediatype); + int typearray[] = {1,8,32,2,64,-1,16384,-1,-1,-1,32768,-1,-1,4}; // 14 fields + for(size_t i = 0; i < (sizeof(typearray) / sizeof(int)); i ++) { + if(typearray[i] == -1) { // Unknown media type such as is_tv_show + sqlite3_bind_int(stmt_item, ++idx, 0); + } else if(track->mediatype == typearray[i]) { + sqlite3_bind_int(stmt_item, ++idx, 1); + } else { + sqlite3_bind_int(stmt_item, ++idx, 0); + } + } /* date_modified */ sqlite3_bind_int(stmt_item, ++idx, timeconv(track->time_modified)); /* year */ sqlite3_bind_int(stmt_item, ++idx, track->year); + /* content_rating */ + sqlite3_bind_int(stmt_item, ++idx, 0); + /* content_rating_level */ + sqlite3_bind_int(stmt_item, ++idx, 0); /* is_compilation */ sqlite3_bind_int(stmt_item, ++idx, track->compilation); + /* f23: is_user_disabled */ + sqlite3_bind_int(stmt_item, ++idx, 0); /* remember_bookmark */ sqlite3_bind_int(stmt_item, ++idx, track->remember_playback_position); /* exclude_from_shuffle */ sqlite3_bind_int(stmt_item, ++idx, track->skip_when_shuffling); + /* part_of_gapless_album */ + sqlite3_bind_int(stmt_item, ++idx, 0); + /* f27: chosen_by_auto_fill */ + sqlite3_bind_int(stmt_item, ++idx, 0); /* artwork_status 1 = has artwork, 2 = doesn't */ sqlite3_bind_int(stmt_item, ++idx, track->has_artwork); /* artwork_cache_id */ @@ -993,6 +1076,8 @@ static int mk_Library(Itdb_iTunesDB *itdb, sqlite3_bind_null(stmt_item, ++idx); /* radio_stream_status --> set to NULL */ sqlite3_bind_null(stmt_item, ++idx); + /* f42: genius_id */ + sqlite3_bind_int(stmt_item, ++idx, 0); /* genre_id */ genre_id = NULL; if (track->genre && *track->genre && (genre_id = g_hash_table_lookup(genre_map, track->genre)) != NULL) { @@ -1000,6 +1085,8 @@ static int mk_Library(Itdb_iTunesDB *itdb, } else sqlite3_bind_int(stmt_item, ++idx, 0); + /* category_id */ + sqlite3_bind_int(stmt_item, ++idx, 0); /* album_pid -7670716306765259718 */ this_album = g_hash_table_lookup(album_ids, track); if (this_album) { @@ -1024,10 +1111,10 @@ static int mk_Library(Itdb_iTunesDB *itdb, bind_first_text(stmt_item, ++idx, 1, track->artist); /* album */ bind_first_text(stmt_item, ++idx, 1, track->album); - /* album_artist */ + /* f51: album_artist */ bind_first_text(stmt_item, ++idx, 1, track->albumartist); /* composer */ - bind_first_text(stmt_item, ++idx, 1, track->composer); + bind_first_text(stmt_item, ++idx, 2, track->composer, "Unknown Composer"); /* sort_title */ bind_first_text(stmt_item, ++idx, 2, track->sort_title, track->title); /* sort_artist */ @@ -1037,7 +1124,7 @@ static int mk_Library(Itdb_iTunesDB *itdb, /* sort_album_artist */ bind_first_text(stmt_item, ++idx, 2, track->sort_albumartist, track->albumartist); /* sort_composer */ - bind_first_text(stmt_item, ++idx, 2, track->sort_composer, track->composer); + bind_first_text(stmt_item, ++idx, 3, track->sort_composer, track->composer, "Unknown Composer"); /* TODO figure out where these values are stored */ /* title_order */ @@ -1065,6 +1152,19 @@ static int mk_Library(Itdb_iTunesDB *itdb, /* description_long */ /* TODO libgpod doesn't know about it */ sqlite3_bind_null(stmt_item, ++idx); + /* f70: collection_description */ + sqlite3_bind_null(stmt_item, ++idx); + /* f71: copyright */ + sqlite3_bind_null(stmt_item, ++idx); + /* f72: track_artist_pid */ + sqlite3_bind_int(stmt_item, ++idx, 1); + /* f73: physical_order */ + sqlite3_bind_int(stmt_item, ++idx, 0); + /* f74: has_lyrics */ + sqlite3_bind_int(stmt_item, ++idx, 0); + /* f75: date_released */ + sqlite3_bind_int(stmt_item, ++idx, 0); + res = sqlite3_step(stmt_item); if (res != SQLITE_DONE) { @@ -1096,12 +1196,12 @@ static int mk_Library(Itdb_iTunesDB *itdb, fprintf(stderr, "[%s] 1 sqlite3_reset returned %d\n", __func__, res); } /* INSERT INTO "avformat_info" VALUES(-6197982141081478573,0,301,232,44100.0,9425664,1,576,2880,6224207,0,0,0); */ idx = 0; - /* item_pid */ + /* f1: item_pid */ sqlite3_bind_int64(stmt_avformat_info, ++idx, track->dbid); - /* sub_id */ + /* f2: sub_id */ /* TODO what is this? set to 0 */ sqlite3_bind_int64(stmt_avformat_info, ++idx, 0); - /* audio_format, TODO what's this? */ + /* f3: audio_format, TODO what's this? */ switch (track->filetype_marker) { case 0x4d503320: audio_format = 301; @@ -1115,8 +1215,10 @@ static int mk_Library(Itdb_iTunesDB *itdb, audio_format = 0; } sqlite3_bind_int(stmt_avformat_info, ++idx, audio_format); - /* bit_rate */ + /* f4: bit_rate */ sqlite3_bind_int(stmt_avformat_info, ++idx, track->bitrate); + /* f5: channels */ + sqlite3_bind_int(stmt_avformat_info, ++idx, 0); /* sample_rate */ sqlite3_bind_double(stmt_avformat_info, ++idx, track->samplerate); /* duration (in samples) (track->tracklen is in ms) */ @@ -1133,10 +1235,10 @@ static int mk_Library(Itdb_iTunesDB *itdb, /* analysis_inhibit_flags */ /* TODO don't know where this belongs to */ sqlite3_bind_int(stmt_avformat_info, ++idx, 0); - /* audio_fingerprint */ + /* f13: audio_fingerprint */ /* TODO this either */ sqlite3_bind_int(stmt_avformat_info, ++idx, 0); - /* volume_normalization_energy */ + /* f14: volume_normalization_energy */ sqlite3_bind_int(stmt_avformat_info, ++idx, track->soundcheck); res = sqlite3_step(stmt_avformat_info); @@ -1157,34 +1259,54 @@ static int mk_Library(Itdb_iTunesDB *itdb, } /* INSERT INTO "album" VALUES(-7670716306765259718,2,0,0,-7576753259813584028,0,'Enjoy The Silence 04 CDS',100,0,NULL,0); */ idx = 0; - /* pid */ + /* f1: pid */ sqlite3_bind_int64(stmt_album, ++idx, album_pid); - /* kind */ + /* f2: kind */ /* TODO use field from mhia */ sqlite3_bind_int(stmt_album, ++idx, 2); - /* artwork_status */ + /* f3: artwork_status */ /* TODO */ sqlite3_bind_int(stmt_album, ++idx, 0); - /* artwork_item_pid */ + /* f4: artwork_item_pid */ /* TODO */ sqlite3_bind_int(stmt_album, ++idx, 0); - /* artist_pid */ + /* f5: artist_pid */ sqlite3_bind_int64(stmt_album, ++idx, artist_pid); - /* user_rating */ + /* f6: user_rating */ sqlite3_bind_int(stmt_album, ++idx, 0); - /* name */ + /* f7: name */ sqlite3_bind_text(stmt_album, ++idx, track->album, -1, SQLITE_STATIC); - /* name_order */ + /* f8: name_order */ sqlite3_bind_int(stmt_album, ++idx, lookup_order(orders, ORDER_ALBUM_ARTIST, track)); - /* all_compilations */ + /* f9: all_compilations */ /* TODO */ sqlite3_bind_int(stmt_album, ++idx, 0); - /* feed_url */ + /* f10: feed_url */ /* TODO this is for podcasts? */ sqlite3_bind_null(stmt_album, ++idx); - /* season_number */ + /* f11: season_number */ /* TODO this is for tv shows?! */ sqlite3_bind_int(stmt_album, ++idx, 0); + /* f12: is_unknown */ + sqlite3_bind_int(stmt_album, ++idx, 0); + /* f13: has_songs */ + sqlite3_bind_int(stmt_album, ++idx, 1); + /* f14: has_music_videos */ + sqlite3_bind_int(stmt_album, ++idx, 0); + /* f15: sort_order */ + sqlite3_bind_int(stmt_album, ++idx, 100); + /* f16: artist_order */ + sqlite3_bind_int(stmt_album, ++idx, 100); + /* f17: has_any_compilation */ + sqlite3_bind_int(stmt_album, ++idx, 0); + /* f18: sort_name */ + sqlite3_bind_text(stmt_album, ++idx, track->album, -1, SQLITE_STATIC); + /* f19: artist_count_calc */ + sqlite3_bind_int(stmt_album, ++idx, 1); + /* f20: has_movies */ + sqlite3_bind_int(stmt_album, ++idx, 0); + /* f21: item_count */ + sqlite3_bind_int(stmt_album, ++idx, 1); res = sqlite3_step(stmt_album); if (res == SQLITE_DONE) { @@ -1195,7 +1317,7 @@ static int mk_Library(Itdb_iTunesDB *itdb, } - if (this_artist) { + if (this_artist && !array_exist(artist_array, artist_cnt, artist_pid)) { /* printf("[%s] -- inserting into \"artist\" (if required)\n", __func__); */ res = sqlite3_reset(stmt_artist); if (res != SQLITE_OK) { @@ -1221,13 +1343,51 @@ static int mk_Library(Itdb_iTunesDB *itdb, /* sort_name */ /* TODO always same as 'name'? */ sqlite3_bind_text(stmt_artist, ++idx, track->artist, -1, SQLITE_STATIC); + /* f8: is_unknown */ + sqlite3_bind_int(stmt_artist, ++idx, 0); + /* f9: has_songs */ + sqlite3_bind_int(stmt_artist, ++idx, 1); + /* f10: has_music_videos */ + sqlite3_bind_int(stmt_artist, ++idx, 0); res = sqlite3_step(stmt_artist); if (res == SQLITE_DONE) { - /* expected result */ + /* expected result */ } else { fprintf(stderr, "[%s] 8 sqlite3_step returned %d\n", __func__, res); } + + res = sqlite3_reset(stmt_track_artist); + if (res != SQLITE_OK) { + fprintf(stderr, "[%s] track_artist sqlite3_reset returned %d\n", __func__, res); + } + idx = 0; + /* pid */ + sqlite3_bind_int64(stmt_track_artist, ++idx, (uint64_t)(artist_cnt+1)); + /* name */ + sqlite3_bind_text(stmt_track_artist, ++idx, track->artist, -1, SQLITE_STATIC); + /* name_order */ + sqlite3_bind_int(stmt_track_artist, ++idx, 100); + /* sort_name */ + sqlite3_bind_text(stmt_track_artist, ++idx, track->artist, -1, SQLITE_STATIC); + /* has_songs */ + sqlite3_bind_int(stmt_track_artist, ++idx, 1); + /* has_music_videos */ + sqlite3_bind_int(stmt_track_artist, ++idx, 0); + /* has_non_compilation_tracks */ + sqlite3_bind_int(stmt_track_artist, ++idx, 1); + /* is_unknown */ + sqlite3_bind_int(stmt_track_artist, ++idx, 0); + /* album_count */ + sqlite3_bind_int(stmt_track_artist, ++idx, 1); + res = sqlite3_step(stmt_track_artist); + if(res == SQLITE_DONE) { + /* exptected result, set artist array */ + artist_array[artist_cnt++] = artist_pid; + } else { + fprintf(stderr, "[%s] track_artist sqlite3_step returned %d\n", __func__, res); + fprintf(stderr, "Error massage: %s\n", sqlite3_errmsg(db) ); + } } if (this_composer) { @@ -1246,6 +1406,10 @@ static int mk_Library(Itdb_iTunesDB *itdb, /* sort_name */ /* TODO always same as 'name'? */ sqlite3_bind_text(stmt_composer, ++idx, track->composer, -1, SQLITE_STATIC); + /* is_unknown */ + sqlite3_bind_int(stmt_composer, ++idx, 1); + /* has_music */ + sqlite3_bind_int(stmt_composer, ++idx, 1); res = sqlite3_step(stmt_composer); if (res == SQLITE_DONE) { @@ -1253,7 +1417,33 @@ static int mk_Library(Itdb_iTunesDB *itdb, } else { fprintf(stderr, "[%s] 8 sqlite3_step returned %d\n", __func__, res); } - } + } else { /* "Unknown Composer" occupies composer_pid 0 */ + res = sqlite3_reset(stmt_composer); + if (res != SQLITE_OK) { + fprintf(stderr, "[%s] 1 sqlite3_reset returned %d\n", __func__, res); + } + idx = 0; + /* pid */ + sqlite3_bind_int64(stmt_composer, ++idx, composer_pid); + /* name */ + sqlite3_bind_text(stmt_composer, ++idx, "Unknown Composer", -1, SQLITE_STATIC); + /* name_order */ + sqlite3_bind_int(stmt_composer, ++idx, lookup_order(orders, ORDER_COMPOSER, track)); + /* sort_name */ + /* TODO always same as 'name'? */ + sqlite3_bind_text(stmt_composer, ++idx, "Unknown Composer", -1, SQLITE_STATIC); + /* is_unknown */ + sqlite3_bind_int(stmt_composer, ++idx, 1); + /* has_music */ + sqlite3_bind_int(stmt_composer, ++idx, 1); + + res = sqlite3_step(stmt_composer); + if (res == SQLITE_DONE) { + /* expected result */ + } else { + fprintf(stderr, "[%s] 8 sqlite3_step returned %d\n", __func__, res); + } + } /* if it's a movie, music video or tv show */ if ((track->mediatype & ITDB_MEDIATYPE_MOVIE) || (track->mediatype & ITDB_MEDIATYPE_MUSICVIDEO) @@ -1359,6 +1549,9 @@ leave: if (stmt_artist) { sqlite3_finalize(stmt_artist); } + if (stmt_track_artist) { + sqlite3_finalize(stmt_track_artist); + } if (stmt_composer) { sqlite3_finalize(stmt_composer); } @@ -2124,6 +2317,7 @@ static gboolean mk_Locations_cbk(Itdb_iTunesDB *itdb, const char *dirname) break; } if (!success) { + printf("Failed here....\n"); g_array_free(cbk, TRUE); return FALSE; } @@ -2208,11 +2402,11 @@ static int copy_itdb_file(const gchar *from_dir, const gchar *to_dir, gchar *dstname = g_build_filename(to_dir, fname, NULL); if (itdb_cp(srcname, dstname, error)) { - fprintf(stderr, "itdbprep: copying '%s'\n", fname); - res++; + fprintf(stderr, "itdbprep: copying '%s'\n", fname); + res++; } if (error && *error) { - fprintf(stderr, "Error copying '%s' to '%s': %s\n", srcname, dstname, (*error)->message); + fprintf(stderr, "Error copying '%s' to '%s': %s\n", srcname, dstname, (*error)->message); } if (srcname) { diff --git a/src/itdb_sqlite_queries.h b/src/itdb_sqlite_queries.h index fd674a4..d63339a 100644 --- a/src/itdb_sqlite_queries.h +++ b/src/itdb_sqlite_queries.h @@ -22,10 +22,16 @@ /** creation statement for 'Dynamic.itdb' */ static const char Dynamic_create[] = "BEGIN TRANSACTION;" \ - "CREATE TABLE item_stats (item_pid INTEGER NOT NULL, has_been_played INTEGER DEFAULT 0, date_played INTEGER DEFAULT 0, play_count_user INTEGER DEFAULT 0, play_count_recent INTEGER DEFAULT 0, date_skipped INTEGER DEFAULT 0, skip_count_user INTEGER DEFAULT 0, skip_count_recent INTEGER DEFAULT 0, bookmark_time_ms REAL, bookmark_time_ms_common REAL, user_rating INTEGER DEFAULT 0, user_rating_common INTEGER DEFAULT 0, rental_expired INTEGER DEFAULT 0, hidden INTEGER DEFAULT 0, deleted INTEGER DEFAULT 0, has_changes INTEGER DEFAULT 0, PRIMARY KEY (item_pid));" \ + "CREATE TABLE item_stats (item_pid INTEGER NOT NULL, has_been_played INTEGER DEFAULT 0, date_played INTEGER DEFAULT 0, play_count_user INTEGER DEFAULT 0, play_count_recent INTEGER DEFAULT 0, date_skipped INTEGER DEFAULT 0, skip_count_user INTEGER DEFAULT 0, skip_count_recent INTEGER DEFAULT 0, bookmark_time_ms REAL, bookmark_time_ms_common REAL, user_rating INTEGER DEFAULT 0, user_rating_common INTEGER DEFAULT 0, rental_expired INTEGER DEFAULT 0, play_count_user_original INTEGER DEFAULT 0, skip_count_user_original INTEGER DEFAULT 0, genius_id INTEGER DEFAULT 0, PRIMARY KEY (item_pid));" \ "CREATE TABLE container_ui (container_pid INTEGER NOT NULL, play_order INTEGER DEFAULT 0, is_reversed INTEGER DEFAULT 0, album_field_order INTEGER DEFAULT 0, repeat_mode INTEGER DEFAULT 0, shuffle_items INTEGER DEFAULT 0, has_been_shuffled INTEGER DEFAULT 0, PRIMARY KEY (container_pid));" \ "CREATE TABLE rental_info (item_pid INTEGER NOT NULL, rental_date_started INTEGER DEFAULT 0, rental_duration INTEGER DEFAULT 0, rental_playback_date_started INTEGER DEFAULT 0, rental_playback_duration INTEGER DEFAULT 0, is_demo INTEGER DEFAULT 0, PRIMARY KEY (item_pid));" \ "COMMIT;"; +/* static const char Dynamic_create[] = */ +/* "BEGIN TRANSACTION;" \ */ +/* "CREATE TABLE item_stats (item_pid INTEGER NOT NULL, has_been_played INTEGER DEFAULT 0, date_played INTEGER DEFAULT 0, play_count_user INTEGER DEFAULT 0, play_count_recent INTEGER DEFAULT 0, date_skipped INTEGER DEFAULT 0, skip_count_user INTEGER DEFAULT 0, skip_count_recent INTEGER DEFAULT 0, bookmark_time_ms REAL, bookmark_time_ms_common REAL, user_rating INTEGER DEFAULT 0, user_rating_common INTEGER DEFAULT 0, rental_expired INTEGER DEFAULT 0, hidden INTEGER DEFAULT 0, deleted INTEGER DEFAULT 0, has_changes INTEGER DEFAULT 0, PRIMARY KEY (item_pid));" \ */ +/* "CREATE TABLE container_ui (container_pid INTEGER NOT NULL, play_order INTEGER DEFAULT 0, is_reversed INTEGER DEFAULT 0, album_field_order INTEGER DEFAULT 0, repeat_mode INTEGER DEFAULT 0, shuffle_items INTEGER DEFAULT 0, has_been_shuffled INTEGER DEFAULT 0, PRIMARY KEY (container_pid));" \ */ +/* "CREATE TABLE rental_info (item_pid INTEGER NOT NULL, rental_date_started INTEGER DEFAULT 0, rental_duration INTEGER DEFAULT 0, rental_playback_date_started INTEGER DEFAULT 0, rental_playback_duration INTEGER DEFAULT 0, is_demo INTEGER DEFAULT 0, PRIMARY KEY (item_pid));" \ */ +/* "COMMIT;"; */ /** creation statement for 'Extras.itdb' */ static const char Extras_create[] = @@ -50,40 +56,59 @@ static const char Library_create[] = "BEGIN TRANSACTION;" \ "CREATE TABLE version_info (id INTEGER PRIMARY KEY, major INTEGER, minor INTEGER, compatibility INTEGER DEFAULT 0, update_level INTEGER DEFAULT 0, device_update_level INTEGER DEFAULT 0, platform INTEGER DEFAULT 0);" \ "CREATE TABLE db_info (pid INTEGER NOT NULL, primary_container_pid INTEGER, media_folder_url TEXT, audio_language INTEGER, subtitle_language INTEGER, genius_cuid TEXT, bib BLOB, rib BLOB, PRIMARY KEY (pid));" \ - "CREATE TABLE item (pid INTEGER NOT NULL, revision_level INTEGER, media_kind INTEGER DEFAULT 0, is_song INTEGER DEFAULT 0, is_audio_book INTEGER DEFAULT 0, is_music_video INTEGER DEFAULT 0, is_movie INTEGER DEFAULT 0, is_tv_show INTEGER DEFAULT 0, is_ringtone INTEGER DEFAULT 0, is_voice_memo INTEGER DEFAULT 0, is_rental INTEGER DEFAULT 0, is_podcast INTEGER DEFAULT 0, date_modified INTEGER DEFAULT 0, date_backed_up INTEGER DEFAULT 0, year INTEGER DEFAULT 0, content_rating INTEGER DEFAULT 0, content_rating_level INTEGER DEFAULT 0, is_compilation INTEGER, is_user_disabled INTEGER DEFAULT 0, remember_bookmark INTEGER DEFAULT 0, exclude_from_shuffle INTEGER DEFAULT 0, part_of_gapless_album INTEGER DEFAULT 0, artwork_status INTEGER, artwork_cache_id INTEGER DEFAULT 0, start_time_ms REAL DEFAULT 0, stop_time_ms REAL DEFAULT 0, total_time_ms REAL DEFAULT 0, total_burn_time_ms REAL, track_number INTEGER DEFAULT 0, track_count INTEGER DEFAULT 0, disc_number INTEGER DEFAULT 0, disc_count INTEGER DEFAULT 0, bpm INTEGER DEFAULT 0, relative_volume INTEGER, eq_preset TEXT, radio_stream_status TEXT, genius_id INTEGER DEFAULT 0, genre_id INTEGER DEFAULT 0, category_id INTEGER DEFAULT 0, album_pid INTEGER DEFAULT 0, artist_pid INTEGER DEFAULT 0, composer_pid INTEGER DEFAULT 0, title TEXT, artist TEXT, album TEXT, album_artist TEXT, composer TEXT, sort_title TEXT, sort_artist TEXT, sort_album TEXT, sort_album_artist TEXT, sort_composer TEXT, title_order INTEGER, artist_order INTEGER, album_order INTEGER, genre_order INTEGER, composer_order INTEGER, album_artist_order INTEGER, album_by_artist_order INTEGER, series_name_order INTEGER, comment TEXT, grouping TEXT, description TEXT, description_long TEXT, PRIMARY KEY (pid));" \ - "CREATE TABLE avformat_info (item_pid INTEGER NOT NULL, sub_id INTEGER NOT NULL DEFAULT 0, audio_format INTEGER, bit_rate INTEGER DEFAULT 0, sample_rate REAL DEFAULT 0, duration INTEGER, gapless_heuristic_info INTEGER, gapless_encoding_delay INTEGER, gapless_encoding_drain INTEGER, gapless_last_frame_resynch INTEGER, analysis_inhibit_flags INTEGER, audio_fingerprint INTEGER, volume_normalization_energy INTEGER, PRIMARY KEY (item_pid,sub_id));" \ - "CREATE TABLE video_info (item_pid INTEGER NOT NULL, has_alternate_audio INTEGER, has_subtitles INTEGER, characteristics_valid INTEGER, has_closed_captions INTEGER, is_self_contained INTEGER, is_compressed INTEGER, is_anamorphic INTEGER, season_number INTEGER, audio_language INTEGER, audio_track_index INTEGER, audio_track_id INTEGER, subtitle_language INTEGER, subtitle_track_index INTEGER, subtitle_track_id INTEGER, series_name TEXT, sort_series_name TEXT, episode_id TEXT, episode_sort_id INTEGER, network_name TEXT, extended_content_rating TEXT, movie_info TEXT, PRIMARY KEY (item_pid));" \ + "CREATE TABLE item (pid INTEGER NOT NULL, revision_level INTEGER, media_kind INTEGER DEFAULT 0, is_song INTEGER DEFAULT 0, is_audio_book INTEGER DEFAULT 0, is_music_video INTEGER DEFAULT 0, is_movie INTEGER DEFAULT 0, is_tv_show INTEGER DEFAULT 0, is_home_video INTEGER DEFAULT 0, is_ringtone INTEGER DEFAULT 0, is_tone INTEGER DEFAULT 0, is_voice_memo INTEGER DEFAULT 0, is_book INTEGER DEFAULT 0, is_rental INTEGER DEFAULT 0, is_itunes_u INTEGER DEFAULT 0, is_digital_booklet INTEGER DEFAULT 0, is_podcast INTEGER DEFAULT 0, date_modified INTEGER DEFAULT 0, year INTEGER DEFAULT 0, content_rating INTEGER DEFAULT 0, content_rating_level INTEGER DEFAULT 0, is_compilation INTEGER, is_user_disabled INTEGER DEFAULT 0, remember_bookmark INTEGER DEFAULT 0, exclude_from_shuffle INTEGER DEFAULT 0, part_of_gapless_album INTEGER DEFAULT 0, chosen_by_auto_fill INTEGER DEFAULT 0, artwork_status INTEGER, artwork_cache_id INTEGER DEFAULT 0, start_time_ms REAL DEFAULT 0, stop_time_ms REAL DEFAULT 0, total_time_ms REAL DEFAULT 0, total_burn_time_ms REAL, track_number INTEGER DEFAULT 0, track_count INTEGER DEFAULT 0, disc_number INTEGER DEFAULT 0, disc_count INTEGER DEFAULT 0, bpm INTEGER DEFAULT 0, relative_volume INTEGER, eq_preset TEXT, radio_stream_status TEXT, genius_id INTEGER DEFAULT 0, genre_id INTEGER DEFAULT 0, category_id INTEGER DEFAULT 0, album_pid INTEGER DEFAULT 0, artist_pid INTEGER DEFAULT 0, composer_pid INTEGER DEFAULT 0, title TEXT, artist TEXT, album TEXT, album_artist TEXT, composer TEXT, sort_title TEXT, sort_artist TEXT, sort_album TEXT, sort_album_artist TEXT, sort_composer TEXT, title_order INTEGER, artist_order INTEGER, album_order INTEGER, genre_order INTEGER, composer_order INTEGER, album_artist_order INTEGER, album_by_artist_order INTEGER, series_name_order INTEGER, comment TEXT, grouping TEXT, description TEXT, description_long TEXT, collection_description TEXT, copyright TEXT, track_artist_pid INTEGER DEFAULT 0, physical_order INTEGER, has_lyrics INTEGER DEFAULT 0, date_released INTEGER DEFAULT 0, PRIMARY KEY (pid));" \ + "CREATE TABLE avformat_info (item_pid INTEGER NOT NULL, sub_id INTEGER NOT NULL DEFAULT 0, audio_format INTEGER, bit_rate INTEGER DEFAULT 0, channels INTEGER DEFAULT 0, sample_rate REAL DEFAULT 0, duration INTEGER, gapless_heuristic_info INTEGER, gapless_encoding_delay INTEGER, gapless_encoding_drain INTEGER, gapless_last_frame_resynch INTEGER, analysis_inhibit_flags INTEGER, audio_fingerprint INTEGER, volume_normalization_energy INTEGER, PRIMARY KEY (item_pid,sub_id));" \ + "CREATE TABLE video_info (item_pid INTEGER NOT NULL, has_alternate_audio INTEGER, has_subtitles INTEGER, characteristics_valid INTEGER, has_closed_captions INTEGER, is_self_contained INTEGER, is_compressed INTEGER, is_anamorphic INTEGER, is_hd INTEGER, season_number INTEGER, audio_language INTEGER, audio_track_index INTEGER, audio_track_id INTEGER, subtitle_language INTEGER, subtitle_track_index INTEGER, subtitle_track_id INTEGER, series_name TEXT, sort_series_name TEXT, episode_id TEXT, episode_sort_id INTEGER, network_name TEXT, extended_content_rating TEXT, movie_info TEXT, PRIMARY KEY (item_pid));" \ "CREATE TABLE video_characteristics (item_pid INTEGER, sub_id INTEGER DEFAULT 0, track_id INTEGER, height INTEGER, width INTEGER, depth INTEGER, codec INTEGER, frame_rate REAL, percentage_encrypted REAL, bit_rate INTEGER, peak_bit_rate INTEGER, buffer_size INTEGER, profile INTEGER, level INTEGER, complexity_level INTEGER, UNIQUE (item_pid,sub_id,track_id));" \ - "CREATE TABLE store_info (item_pid INTEGER NOT NULL, store_kind INTEGER, date_purchased INTEGER DEFAULT 0, date_released INTEGER DEFAULT 0, account_id INTEGER, key_versions INTEGER, key_platform_id INTEGER, key_id INTEGER, key_id2 INTEGER, store_item_id INTEGER, artist_id INTEGER, composer_id INTEGER, genre_id INTEGER, playlist_id INTEGER, storefront_id INTEGER, store_link_id INTEGER, relevance REAL, popularity REAL, PRIMARY KEY (item_pid));" \ + "CREATE TABLE store_info (item_pid INTEGER NOT NULL, store_kind INTEGER, date_purchased INTEGER DEFAULT 0, date_released INTEGER DEFAULT 0, account_id INTEGER, key_versions INTEGER, key_platform_id INTEGER, key_id INTEGER, key_id2 INTEGER, store_item_id INTEGER, artist_id INTEGER, composer_id INTEGER, genre_id INTEGER, playlist_id INTEGER, storefront_id INTEGER, store_link_id INTEGER, relevance REAL, popularity REAL, xid TEXT, flavor TEXT, PRIMARY KEY (item_pid));" \ "CREATE TABLE store_link (id INTEGER NOT NULL, url TEXT, PRIMARY KEY (id));" \ "CREATE TABLE podcast_info (item_pid INTEGER NOT NULL, date_released INTEGER DEFAULT 0, external_guid TEXT, feed_url TEXT, feed_keywords TEXT, PRIMARY KEY (item_pid));" \ - "CREATE TABLE container (pid INTEGER NOT NULL, distinguished_kind INTEGER, date_created INTEGER, date_modified INTEGER, name TEXT, name_order INTEGER, parent_pid INTEGER, media_kinds INTEGER, workout_template_id INTEGER, is_hidden INTEGER, smart_is_folder INTEGER, smart_is_dynamic INTEGER, smart_is_filtered INTEGER, smart_is_genius INTEGER, smart_enabled_only INTEGER, smart_is_limited INTEGER, smart_limit_kind INTEGER, smart_limit_order INTEGER, smart_limit_value INTEGER, smart_reverse_limit_order INTEGER, smart_criteria BLOB, description TEXT, PRIMARY KEY (pid));" \ + "CREATE TABLE container (pid INTEGER NOT NULL, distinguished_kind INTEGER, date_created INTEGER, date_modified INTEGER, name TEXT, name_order INTEGER, parent_pid INTEGER, media_kinds INTEGER, workout_template_id INTEGER, is_hidden INTEGER, smart_is_folder INTEGER, smart_is_dynamic INTEGER, smart_is_filtered INTEGER, smart_is_genius INTEGER, smart_enabled_only INTEGER, smart_is_limited INTEGER, smart_limit_kind INTEGER, smart_limit_order INTEGER, smart_evaluation_order INTEGER, smart_limit_value INTEGER, smart_reverse_limit_order INTEGER, smart_criteria BLOB, description TEXT, PRIMARY KEY (pid));" \ "CREATE TABLE item_to_container (item_pid INTEGER, container_pid INTEGER, physical_order INTEGER, shuffle_order INTEGER);" \ "CREATE TABLE container_seed (container_pid INTEGER NOT NULL, item_pid INTEGER NOT NULL, seed_order INTEGER DEFAULT 0, UNIQUE (container_pid,item_pid));" \ - "CREATE TABLE album (pid INTEGER NOT NULL, kind INTEGER, artwork_status INTEGER, artwork_item_pid INTEGER, artist_pid INTEGER, user_rating INTEGER, name TEXT, name_order INTEGER, all_compilations INTEGER, feed_url TEXT, season_number INTEGER, PRIMARY KEY (pid));" \ - "CREATE TABLE item_to_album (item_pid INTEGER, album_pid INTEGER);" \ - "CREATE TABLE artist (pid INTEGER NOT NULL, kind INTEGER, artwork_status INTEGER, artwork_album_pid INTEGER, name TEXT, name_order INTEGER, sort_name TEXT, PRIMARY KEY (pid));" \ - "CREATE TABLE item_to_artist (item_pid INTEGER, artist_pid INTEGER);" \ - "CREATE TABLE composer (pid INTEGER NOT NULL, name TEXT, name_order INTEGER, sort_name TEXT, PRIMARY KEY (pid));" \ - "CREATE TABLE item_to_composer (item_pid INTEGER, composer_pid INTEGER);" \ + "CREATE TABLE album (pid INTEGER NOT NULL, kind INTEGER, artwork_status INTEGER, artwork_item_pid INTEGER, artist_pid INTEGER, user_rating INTEGER, name TEXT, name_order INTEGER, all_compilations INTEGER, feed_url TEXT, season_number INTEGER, is_unknown INTEGER DEFAULT 0, has_songs INTEGER DEFAULT 0, has_music_videos INTEGER DEFAULT 0, sort_order INTEGER DEFAULT 0, artist_order INTEGER DEFAULT 0, has_any_compilations INTEGER DEFAULT 0, sort_name TEXT, artist_count_calc INTEGER DEFAULT 0 NOT NULL, has_movies INTEGER DEFAULT 0, item_count INTEGER DEFAULT 0, PRIMARY KEY (pid));" \ + "CREATE TABLE artist (pid INTEGER NOT NULL, kind INTEGER, artwork_status INTEGER, artwork_album_pid INTEGER, name TEXT, name_order INTEGER, sort_name TEXT, is_unknown INTEGER DEFAULT 0, has_songs INTEGER DEFAULT 0, has_music_videos INTEGER DEFAULT 0, PRIMARY KEY (pid));" \ + "CREATE TABLE composer (pid INTEGER NOT NULL, name TEXT, name_order INTEGER, sort_name TEXT, is_unknown INTEGER DEFAULT 0, has_music INTEGER DEFAULT 0, PRIMARY KEY (pid));" \ "CREATE TABLE location_kind_map (id INTEGER NOT NULL, kind TEXT NOT NULL, PRIMARY KEY (id), UNIQUE (kind));" \ - "CREATE TABLE genre_map (id INTEGER NOT NULL, genre TEXT NOT NULL, genre_order INTEGER DEFAULT 0, PRIMARY KEY (id), UNIQUE (genre));" \ + "CREATE TABLE genre_map (id INTEGER NOT NULL, genre TEXT NOT NULL, genre_order INTEGER DEFAULT 0, is_unknown INTEGER DEFAULT 0, has_music INTEGER DEFAULT 0, artist_count_calc INTEGER DEFAULT 0 NOT NULL, album_count_calc INTEGER DEFAULT 0 NOT NULL, compilation_count_calc INTEGER DEFAULT 0 NOT NULL, PRIMARY KEY (id), UNIQUE (genre));" \ "CREATE TABLE category_map (id INTEGER NOT NULL, category TEXT NOT NULL, PRIMARY KEY (id), UNIQUE (category));" \ - "CREATE TRIGGER insert_item AFTER INSERT ON item BEGIN " \ - "UPDATE item SET is_song=((new.media_kind&1)!=0), is_audio_book=((new.media_kind&8)!=0), is_music_video=((new.media_kind&32)!=0), is_movie=((new.media_kind&2)!=0), is_tv_show=((new.media_kind&64)!=0), is_ringtone=((new.media_kind&16384)!=0), is_podcast=((new.media_kind&4)!=0), is_rental=((new.media_kind&32768)!=0) WHERE pid = new.pid;" \ - "END;" \ - "CREATE TRIGGER update_item_media_kind AFTER UPDATE OF media_kind ON item BEGIN " \ - "UPDATE item SET is_song=((new.media_kind&1)!=0), is_audio_book=((new.media_kind&8)!=0), is_music_video=((new.media_kind&32)!=0), is_movie=((new.media_kind&2)!=0), is_tv_show=((new.media_kind&64)!=0), is_ringtone=((new.media_kind&16384)!=0), is_podcast=((new.media_kind&4)!=0), is_rental=((new.media_kind&32768)!=0) WHERE pid = new.pid;" \ - "END;" \ + "CREATE TABLE track_artist (pid INTEGER NOT NULL, name TEXT, name_order INTEGER, sort_name TEXT, has_songs INTEGER DEFAULT 0, has_music_videos INTEGER DEFAULT 0, has_non_compilation_tracks INTEGER DEFAULT 0, is_unknown INTEGER DEFAULT 0, album_count INTEGER DEFAULT 0, PRIMARY KEY (pid));" \ + "CREATE TABLE track_size_calc (pid INTEGER NOT NULL, kind TEXT NOT NULL, size INTEGER NOT NULL, PRIMARY KEY (pid), UNIQUE (kind));" \ + "CREATE INDEX idx_item_track_artist_pid ON item (track_artist_pid);" \ + "CREATE INDEX idx_item_album_pid ON item (album_pid);" \ + "CREATE INDEX item_artist_sort_order_idx ON item (artist_order,album_order,disc_number,track_number,sort_title,physical_order);" \ + "CREATE INDEX item_to_container_physical_order_idx ON item_to_container (physical_order);" \ + "CREATE INDEX item_album_order_idx ON item (album_order,disc_number,track_number,artist_order,sort_title,physical_order);" \ + "CREATE INDEX item_genre_id_idx ON item (genre_id);" \ + "CREATE INDEX item_title_order_idx ON item (title_order, media_kind);" \ + "CREATE INDEX item_composer_order_idx ON item (composer_pid, composer_order, media_kind);" \ + "CREATE INDEX item_to_container_container_pid_idx ON item_to_container (container_pid, physical_order, item_pid);" \ "COMMIT;"; + /* "END;" */ +/* "CREATE TABLE item_to_album (item_pid INTEGER, album_pid INTEGER);" \ */ +/* "CREATE TABLE item_to_artist (item_pid INTEGER, artist_pid INTEGER);" \ */ +/* "CREATE TABLE item_to_composer (item_pid INTEGER, composer_pid INTEGER);" \ */ + /* "CREATE TRIGGER insert_item AFTER INSERT ON item BEGIN " \ */ + /* "UPDATE item SET is_song=((new.media_kind&1)!=0), is_audio_book=((new.media_kind&8)!=0), is_music_video=((new.media_kind&32)!=0), is_movie=((new.media_kind&2)!=0), is_tv_show=((new.media_kind&64)!=0), is_ringtone=((new.media_kind&16384)!=0), is_podcast=((new.media_kind&4)!=0), is_rental=((new.media_kind&32768)!=0) WHERE pid = new.pid;" \ */ + /* "END;" \ */ + /* "CREATE TRIGGER update_item_media_kind AFTER UPDATE OF media_kind ON item BEGIN " \ */ + /* "UPDATE item SET is_song=((new.media_kind&1)!=0), is_audio_book=((new.media_kind&8)!=0), is_music_video=((new.media_kind&32)!=0), is_movie=((new.media_kind&2)!=0), is_tv_show=((new.media_kind&64)!=0), is_ringtone=((new.media_kind&16384)!=0), is_podcast=((new.media_kind&4)!=0), is_rental=((new.media_kind&32768)!=0) WHERE pid = new.pid;" \ */ + /** creation statement for 'Locations.itdb' */ +/* static const char Locations_create[] = */ +/* "BEGIN TRANSACTION;" \ */ +/* "CREATE TABLE location (item_pid INTEGER NOT NULL, sub_id INTEGER NOT NULL DEFAULT 0, base_location_id INTEGER DEFAULT 0, location_type INTEGER, location TEXT, extension INTEGER, kind_id INTEGER DEFAULT 0, date_created INTEGER DEFAULT 0, file_size INTEGER DEFAULT 0, file_creator INTEGER, file_type INTEGER, num_dir_levels_file INTEGER, num_dir_levels_lib INTEGER, PRIMARY KEY (item_pid,sub_id));" \ */ +/* "CREATE TABLE base_location (id INTEGER NOT NULL, path TEXT, PRIMARY KEY (id));" \ */ +/* "ANALYZE sqlite_master;" \ */ +/* "INSERT INTO \"sqlite_stat1\" VALUES('location','sqlite_autoindex_location_1','1 1 1');" \ */ +/* "COMMIT;"; */ static const char Locations_create[] = "BEGIN TRANSACTION;" \ "CREATE TABLE location (item_pid INTEGER NOT NULL, sub_id INTEGER NOT NULL DEFAULT 0, base_location_id INTEGER DEFAULT 0, location_type INTEGER, location TEXT, extension INTEGER, kind_id INTEGER DEFAULT 0, date_created INTEGER DEFAULT 0, file_size INTEGER DEFAULT 0, file_creator INTEGER, file_type INTEGER, num_dir_levels_file INTEGER, num_dir_levels_lib INTEGER, PRIMARY KEY (item_pid,sub_id));" \ "CREATE TABLE base_location (id INTEGER NOT NULL, path TEXT, PRIMARY KEY (id));" \ - "ANALYZE sqlite_master;" \ - "INSERT INTO \"sqlite_stat1\" VALUES('location','sqlite_autoindex_location_1','1 1 1');" \ "COMMIT;"; +/* "ANALYZE sqlite_master;" \ */ +/* "INSERT INTO \"sqlite_stat1\" VALUES('location','sqlite_autoindex_location_1','1 1 1');" \ */ #endif
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor