diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po index 57c44ea9760ad..d8d9453f1865b 100644 --- a/addons/resource.language.en_gb/resources/strings.po +++ b/addons/resource.language.en_gb/resources/strings.po @@ -23962,7 +23962,13 @@ msgctxt "#40036" msgid "You are about to convert a movie version into a movie extra. Are you sure?" msgstr "" -#empty strings with id 40037 to 40199 +#. Addition of new version to a movie: the user chose a movie that has multiple versions. Ask for confirmation. +#: xbmc/video/dialogs/GUIDialogVideoManagerVersions.cpp +msgctxt "#40037" +msgid "The movie to be added has multiple versions.[CR]The type of the default version will be selected in the next dialog. The other versions will keep their current type.[CR]Do you want to continue?" +msgstr "" + +#empty strings with id 40038 to 40199 #. Select default video version setting #: system/settings/settings.xml diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 0990a8d28c4ef..b97252ae750d0 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -12226,6 +12226,8 @@ bool CVideoDatabase::ConvertVideoToVersion(VideoDbContentType itemType, int idVideoVersion) { int idFile = -1; + MediaType mediaType; + VideoContentTypeToString(itemType, mediaType); if (itemType == VideoDbContentType::MOVIES) { @@ -12241,24 +12243,22 @@ bool CVideoDatabase::ConvertVideoToVersion(VideoDbContentType itemType, if (dbIdSource != dbIdTarget) { - // First transfer the extras to the new movie. - // A movie with versions cannot be transformed into a version of another movie so there is no - // problem with moving all extras to the new movie. With the the current data model it's not - // possible to tell which extras initially belonged to which version. + // Transfer all assets (versions, extras,...) to the new movie. ExecuteQuery( - PrepareSQL("UPDATE videoversion SET idMedia = %i WHERE idMedia = %i AND itemType = %i", - dbIdTarget, dbIdSource, VideoAssetType::EXTRA)); - - ExecuteQuery(PrepareSQL("UPDATE videoversion SET idMedia = %i, idType = %i WHERE idFile = %i", - dbIdTarget, idVideoVersion, idFile)); + PrepareSQL("UPDATE videoversion SET idMedia = %i WHERE idMedia = %i AND media_type = '%s'", + dbIdTarget, dbIdSource, mediaType.c_str())); + // version-level art doesn't need any change. + // 'movie' art is converted to 'videoversion' art. SetVideoVersionDefaultArt(idFile, dbIdSource, itemType); - DeleteMovie(dbIdSource); + if (itemType == VideoDbContentType::MOVIES) + DeleteMovie(dbIdSource); } - else - ExecuteQuery(PrepareSQL("UPDATE videoversion SET idType = %i WHERE idFile = %i", idVideoVersion, - idFile)); + + // Rename the default version + ExecuteQuery( + PrepareSQL("UPDATE videoversion SET idType = %i WHERE idFile = %i", idVideoVersion, idFile)); CommitTransaction(); diff --git a/xbmc/video/dialogs/GUIDialogVideoManagerVersions.cpp b/xbmc/video/dialogs/GUIDialogVideoManagerVersions.cpp index 1b8290be94649..48cee292e9106 100644 --- a/xbmc/video/dialogs/GUIDialogVideoManagerVersions.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoManagerVersions.cpp @@ -353,6 +353,16 @@ bool CGUIDialogVideoManagerVersions::ChooseVideoAndConvertToVideoVersion( if (!selectedItem) return false; + CFileItemList list; + videoDb.GetVideoVersions(itemType, selectedItem->GetVideoInfoTag()->m_iDbId, list, + VideoAssetType::VERSION); + + // ask confirmation for the addition of a movie with multiple versions to another movie + if (list.Size() > 1 && !CGUIDialogYesNo::ShowAndGetInput(CVariant{40014}, CVariant{40037})) + { + return false; + } + // choose a video version for the video const int idVideoVersion{ChooseVideoAsset(selectedItem, VideoAssetType::VERSION)}; if (idVideoVersion < 0)