From 8428c623f0cbb40008bcc624fe63df32f684612c Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Mon, 2 Jun 2025 12:49:20 +0200 Subject: [PATCH] Improves video version migration logic for movies Updates migration to fetch version type dynamically from the database rather than using hardcoded values, ensuring accurate mapping during database upgrades. Refines video version insertion query to utilize the correct item type from the version type table. Helps prevent mismatches and enhances database integrity. --- jellyfin_kodi/objects/kodi/movies.py | 4 ++-- jellyfin_kodi/objects/kodi/queries.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jellyfin_kodi/objects/kodi/movies.py b/jellyfin_kodi/objects/kodi/movies.py index 71cbe324..0d72ab5f 100644 --- a/jellyfin_kodi/objects/kodi/movies.py +++ b/jellyfin_kodi/objects/kodi/movies.py @@ -144,7 +144,7 @@ class Movies(Kodi): # subsequent runs to not be a meaningful delay if 131 <= version_id < 134: changes = self.omega_migration() - + if version_id >= 134: changes = self.piers_migration() @@ -178,7 +178,7 @@ class Movies(Kodi): # Sets all existing movies without a version to standard version for entry in self.cursor.fetchall(): - self.add_videoversion(entry[0], entry[1], "movie", "1", 40400) + self.add_videoversion(entry[0], entry[1], "movie", 40400, 40400) changes = True LOG.info("Piers database migration is complete") diff --git a/jellyfin_kodi/objects/kodi/queries.py b/jellyfin_kodi/objects/kodi/queries.py index 738b8c7f..8f194ee8 100644 --- a/jellyfin_kodi/objects/kodi/queries.py +++ b/jellyfin_kodi/objects/kodi/queries.py @@ -409,12 +409,12 @@ VALUES (?, ?) add_set_obj = ["{Title}", "{Overview}"] add_video_version = """ INSERT INTO videoversion(idFile, idMedia, media_type, itemType, idType) -VALUES (?, ?, ?, ?, ?) +VALUES (?, ?, ?, (SELECT itemType FROM videoversiontype WHERE id = ?), ?) """ check_video_version = """ SELECT COUNT(name) FROM sqlite_master WHERE type='table' AND name='videoversion' """ -add_video_version_obj = ["{FileId}", "{MovieId}", "movie", "1", 40400] +add_video_version_obj = ["{FileId}", "{MovieId}", "movie", 40400, 40400] add_musicvideo = """ INSERT INTO musicvideo(idMVideo, idFile, c00, c04, c05, c06, c07, c08, c09, c10, c11, c12, premiered)