Skip to content

Commit

Permalink
Merge pull request xbmc#24683 from CrystalP/videodb-versions
Browse files Browse the repository at this point in the history
Videodb versions: add version fix and remove quality pre-populated version types
  • Loading branch information
CrystalP committed Feb 11, 2024
2 parents 7227289 + 9b57143 commit 16f8f02
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 84 deletions.
84 changes: 2 additions & 82 deletions addons/resource.language.en_gb/resources/strings.po
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
44 changes: 42 additions & 2 deletions xbmc/video/VideoDatabase.cpp
Expand Up @@ -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'; "
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 16f8f02

Please sign in to comment.