aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrystalP <crystalp@kodi.tv>2024-02-11 18:43:09 -0500
committerGitHub <noreply@github.com>2024-02-11 18:43:09 -0500
commit16f8f02fddf00e72762974614a1259aa87bc2648 (patch)
tree2584c7486110c8a85362d3259a21f8a9c0a1dbaa
parent72272892955462036e69f9f047ea2b5045ceceff (diff)
parent9b571439aced321d2468fdf0c696a25e99b284e7 (diff)
Merge pull request #24683 from CrystalP/videodb-versions
Videodb versions: add version fix and remove quality pre-populated version types
-rw-r--r--addons/resource.language.en_gb/resources/strings.po84
-rw-r--r--xbmc/video/VideoDatabase.cpp44
2 files changed, 44 insertions, 84 deletions
diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po
index 2fc940bf33..a0f0d79fb0 100644
--- a/addons/resource.language.en_gb/resources/strings.po
+++ b/addons/resource.language.en_gb/resources/strings.po
@@ -24202,11 +24202,7 @@ msgctxt "#40404"
msgid "Remastered Version"
msgstr ""
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40405"
-msgid "4K"
-msgstr ""
+#empty string id 40405 do not reuse
#. Name of a video version, like "Director's Cut"
#: xbmc/video/VideoDatabase.cpp
@@ -24280,83 +24276,7 @@ msgctxt "#40417"
msgid "Black and White Edition"
msgstr ""
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40418"
-msgid "BluRay"
-msgstr ""
-
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40419"
-msgid "WEB-DL"
-msgstr ""
-
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40420"
-msgid "3D"
-msgstr ""
-
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40421"
-msgid "8K"
-msgstr ""
-
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40422"
-msgid "IMAX"
-msgstr ""
-
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40423"
-msgid "UHD"
-msgstr ""
-
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40424"
-msgid "FHD"
-msgstr ""
-
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40425"
-msgid "HD"
-msgstr ""
-
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40426"
-msgid "SD"
-msgstr ""
-
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40427"
-msgid "DVD"
-msgstr ""
-
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40428"
-msgid "VHS"
-msgstr ""
-
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40429"
-msgid "VCD"
-msgstr ""
-
-#. Name of a video version, like "Director's Cut"
-#: xbmc/video/VideoDatabase.cpp
-msgctxt "#40430"
-msgid "REMUX"
-msgstr ""
+#empty strings from id 40418 to 40430 do not reuse
#. Name of a video version, like "Director's Cut"
#: xbmc/video/VideoDatabase.cpp
diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp
index 15ea40ad23..d175929bb6 100644
--- a/xbmc/video/VideoDatabase.cpp
+++ b/xbmc/video/VideoDatabase.cpp
@@ -313,7 +313,8 @@ void CVideoDatabase::CreateAnalytics()
"DELETE FROM tag_link WHERE media_id=old.idMovie AND media_type='movie'; "
"DELETE FROM rating WHERE media_id=old.idMovie AND media_type='movie'; "
"DELETE FROM uniqueid WHERE media_id=old.idMovie AND media_type='movie'; "
- "DELETE FROM videoversion WHERE idFile=old.idFile AND media_type='movie'; "
+ "DELETE FROM videoversion "
+ "WHERE idFile=old.idFile AND idMedia=old.idMovie AND media_type='movie'; "
"END");
m_pDS->exec("CREATE TRIGGER delete_tvshow AFTER DELETE ON tvshow FOR EACH ROW BEGIN "
"DELETE FROM actor_link WHERE media_id=old.idShow AND media_type='tvshow'; "
@@ -6341,11 +6342,46 @@ void CVideoDatabase::UpdateTables(int iVersion)
"AND itemType = %i",
VideoAssetTypeOwner::USER, VideoAssetType::VERSION));
}
+
+ if (iVersion < 131)
+ {
+ // Remove quality-like predefined version types
+
+ // Retrieve current utilization per type
+ m_pDS->query("SELECT vvt.id, vvt.name, count(vv.idType) "
+ "FROM videoversiontype vvt "
+ " LEFT JOIN videoversion vv ON vvt.id = vv.idType "
+ "WHERE vvt.id = 40405 OR vvt.id BETWEEN 40418 AND 40430 "
+ "GROUP BY vvt.id");
+
+ while (!m_pDS->eof())
+ {
+ const int typeId{m_pDS->fv(0).get_asInt()};
+ const std::string typeName{m_pDS->fv(1).get_asString()};
+ const int versionsCount{m_pDS->fv(2).get_asInt()};
+
+ if (versionsCount > 0)
+ {
+ // type used by some versions, recreate as user type and link the versions to the new id
+ m_pDS2->exec(PrepareSQL(
+ "INSERT INTO videoversiontype (id, name, owner, itemType) VALUES(NULL, '%s', %i, %i)",
+ typeName.c_str(), VideoAssetTypeOwner::USER, VideoAssetType::VERSION));
+
+ const int newId{static_cast<int>(m_pDS2->lastinsertid())};
+
+ m_pDS2->exec(
+ PrepareSQL("UPDATE videoversion SET idType = %i WHERE idType = %i", newId, typeId));
+ }
+ m_pDS2->exec(PrepareSQL("DELETE FROM videoversiontype WHERE id = %i", typeId));
+ m_pDS->next();
+ }
+ m_pDS->close();
+ }
}
int CVideoDatabase::GetSchemaVersion() const
{
- return 130;
+ return 131;
}
bool CVideoDatabase::LookupByFolders(const std::string &path, bool shows)
@@ -11904,6 +11940,10 @@ void CVideoDatabase::InitializeVideoVersionTypeTable(int schemaVersion)
for (int id = VIDEO_VERSION_ID_BEGIN; id <= VIDEO_VERSION_ID_END; ++id)
{
+ // Exclude removed pre-populated "quality" values
+ if (id == 40405 || (id >= 40418 && id <= 40430))
+ continue;
+
const std::string& type{g_localizeStrings.Get(id)};
if (schemaVersion < 127)
{