From 099e17d95feaafec4f7072272178adad34eed0a4 Mon Sep 17 00:00:00 2001 From: Andrew Fyfe Date: Tue, 21 Apr 2015 11:53:29 +0100 Subject: [PATCH] FIX: update link between movie and tv shows when saving a movies details --- xbmc/video/VideoDatabase.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 96fa5fddebcfa..d4a8e264c6f7e 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -2187,6 +2187,26 @@ int CVideoDatabase::UpdateDetailsForMovie(int idMovie, const CVideoInfoTag& deta } } + if (updatedDetails.find("showlink") != updatedDetails.end()) + { + // remove existing links + vector tvShowIds; + GetLinksToTvShow(idMovie, tvShowIds); + for (const auto& idTVShow : tvShowIds) + LinkMovieToTvshow(idMovie, idTVShow, true); + + // setup links to shows if the linked shows are in the db + for (const auto& showLink : details.m_showLink) + { + CFileItemList items; + GetTvShowsByName(showLink, items); + if (!items.IsEmpty()) + LinkMovieToTvshow(idMovie, items[0]->GetVideoInfoTag()->m_iDbId, false); + else + CLog::Log(LOGWARNING, "%s: Failed to link movie %s to show %s", __FUNCTION__, details.m_strTitle.c_str(), showLink.c_str()); + } + } + // and update the movie table std::string sql = "update movie set " + GetValueString(details, VIDEODB_ID_MIN, VIDEODB_ID_MAX, DbMovieOffsets); if (idSet > 0)