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.
This commit is contained in:
Jeroen De Meerleer 2025-06-02 12:49:20 +02:00
commit 8428c623f0
No known key found for this signature in database
GPG key ID: 28CCCB8F62BFADD6
2 changed files with 4 additions and 4 deletions

View file

@ -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")

View file

@ -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)