From 14aac683c8efcd7e3ce0672ddf446bf5c4e22706 Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Wed, 26 Jun 2024 23:14:39 +0200 Subject: [video] GUIDialogVideoBookmarks: Use correct item path to write and read bookmarks. --- xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp b/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp index 344b0b5a07..f97c8c1d21 100644 --- a/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp @@ -188,10 +188,7 @@ void CGUIDialogVideoBookmarks::Delete(int item) { CVideoDatabase videoDatabase; videoDatabase.Open(); - std::string path(g_application.CurrentFile()); - if (g_application.CurrentFileItem().HasProperty("original_listitem_url") && - !URIUtils::IsVideoDb(g_application.CurrentFileItem().GetProperty("original_listitem_url").asString())) - path = g_application.CurrentFileItem().GetProperty("original_listitem_url").asString(); + const std::string path{g_application.CurrentFileItem().GetDynPath()}; videoDatabase.ClearBookMarkOfFile(path, m_bookmarks[item], m_bookmarks[item].type); videoDatabase.Close(); CUtil::DeleteVideoDatabaseDirectoryCache(); @@ -205,10 +202,7 @@ void CGUIDialogVideoBookmarks::OnRefreshList() std::vector items; // open the d/b and retrieve the bookmarks for the current movie - m_filePath = g_application.CurrentFile(); - if (g_application.CurrentFileItem().HasProperty("original_listitem_url") && - !URIUtils::IsVideoDb(g_application.CurrentFileItem().GetProperty("original_listitem_url").asString())) - m_filePath = g_application.CurrentFileItem().GetProperty("original_listitem_url").asString(); + m_filePath = g_application.CurrentFileItem().GetDynPath(); CVideoDatabase videoDatabase; videoDatabase.Open(); @@ -355,10 +349,7 @@ void CGUIDialogVideoBookmarks::ClearBookmarks() { CVideoDatabase videoDatabase; videoDatabase.Open(); - std::string path = g_application.CurrentFile(); - if (g_application.CurrentFileItem().HasProperty("original_listitem_url") && - !URIUtils::IsVideoDb(g_application.CurrentFileItem().GetProperty("original_listitem_url").asString())) - path = g_application.CurrentFileItem().GetProperty("original_listitem_url").asString(); + const std::string path{g_application.CurrentFileItem().GetDynPath()}; videoDatabase.ClearBookMarksOfFile(path, CBookmark::STANDARD); videoDatabase.ClearBookMarksOfFile(path, CBookmark::RESUME); videoDatabase.ClearBookMarksOfFile(path, CBookmark::EPISODE); @@ -471,10 +462,7 @@ bool CGUIDialogVideoBookmarks::AddBookmark(CVideoInfoTag* tag) videoDatabase.AddBookMarkForEpisode(*tag, bookmark); else { - std::string path = g_application.CurrentFile(); - if (g_application.CurrentFileItem().HasProperty("original_listitem_url") && - !URIUtils::IsVideoDb(g_application.CurrentFileItem().GetProperty("original_listitem_url").asString())) - path = g_application.CurrentFileItem().GetProperty("original_listitem_url").asString(); + const std::string path{g_application.CurrentFileItem().GetDynPath()}; videoDatabase.AddBookMarkToFile(path, bookmark, CBookmark::STANDARD); } videoDatabase.Close(); -- cgit v1.2.3 From 66dc6399f08ef0487a7bf59811e3433b09eb87af Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Thu, 27 Jun 2024 13:04:22 +0200 Subject: [FileItem] Fix CFileItem::LoadDetails not to pass item's path to CVideoDatabase::Get*Info methods. The path is actually not needed because we always have the media id available here. Even worse, item's path could be a videodb URL which leads to misbehavior once passed to CVideoDatabase::Get*Info methods, including writing wrong entries to video db's 'files' and 'path' tables. The latter causes all kind of weird follow-up issues, like not being able to resume playback from the right position once a bookmark for a movie was created by the user. --- xbmc/FileItem.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp index 43ca4749ed..98360446a3 100644 --- a/xbmc/FileItem.cpp +++ b/xbmc/FileItem.cpp @@ -2430,12 +2430,12 @@ bool CFileItem::LoadDetails() bool ret{false}; auto tag{std::make_unique()}; if (params.GetMovieId() >= 0) - ret = db.GetMovieInfo(GetPath(), *tag, static_cast(params.GetMovieId()), + ret = db.GetMovieInfo({}, *tag, static_cast(params.GetMovieId()), static_cast(params.GetVideoVersionId())); else if (params.GetMVideoId() >= 0) - ret = db.GetMusicVideoInfo(GetPath(), *tag, static_cast(params.GetMVideoId())); + ret = db.GetMusicVideoInfo({}, *tag, static_cast(params.GetMVideoId())); else if (params.GetEpisodeId() >= 0) - ret = db.GetEpisodeInfo(GetPath(), *tag, static_cast(params.GetEpisodeId())); + ret = db.GetEpisodeInfo({}, *tag, static_cast(params.GetEpisodeId())); else if (params.GetSetId() >= 0) // movie set ret = db.GetSetInfo(static_cast(params.GetSetId()), *tag, this); else if (params.GetTvShowId() >= 0) @@ -2448,7 +2448,7 @@ bool CFileItem::LoadDetails() ret = db.GetSeasonInfo(idSeason, *tag, this); } else - ret = db.GetTvShowInfo(GetPath(), *tag, static_cast(params.GetTvShowId()), this); + ret = db.GetTvShowInfo({}, *tag, static_cast(params.GetTvShowId()), this); } if (ret) -- cgit v1.2.3