diff --git a/src/ipod_nano7_db.py b/src/ipod_nano7_db.py index 3cf5253..8df3ebb 100644 --- a/src/ipod_nano7_db.py +++ b/src/ipod_nano7_db.py @@ -30,28 +30,46 @@ from artwork.types import ArtworkEntry logger = logging.getLogger(__name__) MASTER_CONTAINER_PID = 203092939621887772 # "iPod" master playlist +MUSIC_CONTAINER_PID = 4872745547565090077 # Music smart playlist LIBRARY_SCHEMA_SQL = """ CREATE TABLE IF NOT EXISTS version_info ( - major INTEGER, minor INTEGER, device_update_level INTEGER, - platform INTEGER + 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 IF NOT EXISTS db_info ( - primary_container_pid INTEGER + pid INTEGER NOT NULL PRIMARY KEY, + primary_container_pid INTEGER, + media_folder_url TEXT, audio_language INTEGER DEFAULT -1, + subtitle_language INTEGER DEFAULT -1, genius_cuid TEXT, + bib BLOB, rib BLOB ); CREATE TABLE IF NOT EXISTS container ( - pid INTEGER PRIMARY KEY, distinguished_kind INTEGER, - is_hidden INTEGER, is_master INTEGER, media_kind INTEGER, - name TEXT, parent_pid INTEGER + pid INTEGER NOT NULL PRIMARY KEY, + distinguished_kind INTEGER, date_created INTEGER, + date_modified INTEGER, name TEXT, name_order INTEGER, + parent_pid INTEGER DEFAULT 0, media_kinds INTEGER, + workout_template_id INTEGER DEFAULT 0, is_hidden INTEGER, + smart_is_folder INTEGER DEFAULT 0, smart_is_dynamic INTEGER, + smart_is_filtered INTEGER, smart_is_genius INTEGER DEFAULT 0, + smart_enabled_only INTEGER DEFAULT 0, smart_is_limited INTEGER, + smart_limit_kind INTEGER, smart_limit_order INTEGER, + smart_evaluation_order INTEGER DEFAULT 1, + smart_limit_value INTEGER, smart_reverse_limit_order INTEGER, + smart_criteria BLOB, description TEXT ); CREATE TABLE IF NOT EXISTS genre_map ( - pid INTEGER PRIMARY KEY, name TEXT, name_order INTEGER, - has_songs INTEGER, has_music_videos INTEGER, item_count INTEGER, - computed_has_songs INTEGER, computed_has_music_videos INTEGER, - computed_item_count INTEGER + id INTEGER NOT NULL PRIMARY KEY, + genre TEXT NOT NULL UNIQUE, 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 ); CREATE TABLE IF NOT EXISTS location_kind_map ( @@ -73,6 +91,7 @@ CREATE TABLE IF NOT EXISTS item ( artwork_cache_id INTEGER, total_time_ms INTEGER, track_number INTEGER, track_count INTEGER, disc_number INTEGER, disc_count INTEGER, album_pid INTEGER, artist_pid INTEGER, + genre_id INTEGER, title TEXT, artist TEXT, album TEXT, album_artist TEXT, sort_title TEXT, sort_artist TEXT, sort_album TEXT, sort_album_artist TEXT, title_order INTEGER, artist_order INTEGER, @@ -121,15 +140,34 @@ CREATE TABLE IF NOT EXISTS track_size_calc ( ); INSERT OR IGNORE INTO track_size_calc (kind, size) VALUES ('audio', 0); -INSERT OR IGNORE INTO version_info (major, minor, device_update_level, platform) VALUES (1, 111, 1104, 2); -INSERT OR IGNORE INTO db_info (primary_container_pid) VALUES (203092939621887772); + +INSERT OR IGNORE INTO version_info (id, major, minor, compatibility, update_level, device_update_level, platform) + VALUES (1, 1, 111, 0, 0, 1104, 2); + +INSERT OR IGNORE INTO db_info (pid, primary_container_pid, media_folder_url, audio_language, subtitle_language, genius_cuid, bib, rib) + VALUES (203092939621887772, 203092939621887772, NULL, -1, -1, NULL, NULL, NULL); + INSERT OR IGNORE INTO location_kind_map (pid, name) VALUES (1, 'MPEG audio file'); INSERT OR IGNORE INTO location_kind_map (pid, name) VALUES (2, 'Purchased AAC audio file'); INSERT OR IGNORE INTO location_kind_map (pid, name) VALUES (3, 'AAC audio file'); -INSERT OR IGNORE INTO container (pid, distinguished_kind, is_hidden, is_master, media_kind, name, parent_pid) - VALUES (203092939621887772, 0, 1, 1, 1, 'iPod', NULL); -INSERT OR IGNORE INTO container (pid, distinguished_kind, is_hidden, is_master, media_kind, name, parent_pid) - VALUES (4872745547565090077, 4, 1, 0, 1, 'Music', NULL); + +INSERT OR IGNORE INTO container (pid, distinguished_kind, date_created, date_modified, + name, name_order, parent_pid, media_kinds, workout_template_id, is_hidden, + smart_is_folder, smart_is_dynamic, smart_is_filtered, + smart_is_genius, smart_enabled_only, smart_is_limited, + smart_limit_kind, smart_limit_order, smart_evaluation_order, + smart_limit_value, smart_reverse_limit_order, smart_criteria, description) + VALUES (203092939621887772, 0, 0, 0, 'iPod', 100, 0, 1, 0, 1, + 0, NULL, NULL, 0, 0, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL); + +INSERT OR IGNORE INTO container (pid, distinguished_kind, date_created, date_modified, + name, name_order, parent_pid, media_kinds, workout_template_id, is_hidden, + smart_is_folder, smart_is_dynamic, smart_is_filtered, + smart_is_genius, smart_enabled_only, smart_is_limited, + smart_limit_kind, smart_limit_order, smart_evaluation_order, + smart_limit_value, smart_reverse_limit_order, smart_criteria, description) + VALUES (4872745547565090077, 4, 0, 0, 'Music', 200, 0, 1, 0, 1, + 0, 1, 1, 0, 0, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL); """ DYNAMIC_SCHEMA_SQL = """