aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Sommerfeld <3226626+ksooo@users.noreply.github.com>2023-06-13 22:30:43 +0200
committerGitHub <noreply@github.com>2023-06-13 22:30:43 +0200
commit2f5330994b3adafad42dce9c7b058295177bc9e9 (patch)
tree075c88e6908228e7ea881c03e861d13920e341a1
parent5eb7778d314b348edd30e570419687272cb5ed60 (diff)
parent22461be34f5afc9c20d988b819681cdd1d77ae1a (diff)
Merge pull request #23398 from ksooo/video-fix-23305-nexus
[Nexus][video] Fix watched/unwatched filter not working when creating playli…
-rw-r--r--xbmc/video/VideoUtils.cpp39
1 files changed, 34 insertions, 5 deletions
diff --git a/xbmc/video/VideoUtils.cpp b/xbmc/video/VideoUtils.cpp
index 5987238565..44609aa3c8 100644
--- a/xbmc/video/VideoUtils.cpp
+++ b/xbmc/video/VideoUtils.cpp
@@ -185,6 +185,20 @@ void CAsyncGetItemsForPlaylist::GetItemsForPlaylist(const std::shared_ptr<CFileI
items.Sort(sortDesc);
}
+ if (items.GetContent().empty() && !items.IsVideoDb() && !items.IsVirtualDirectoryRoot() &&
+ !items.IsSourcesPath() && !items.IsLibraryFolder())
+ {
+ CVideoDatabase db;
+ if (db.Open())
+ {
+ std::string content = db.GetContentForPath(items.GetPath());
+ if (content.empty() && !items.IsPlugin())
+ content = "files";
+
+ items.SetContent(content);
+ }
+ }
+
if (m_resume)
{
// put last played item at the begin of the playlist; add start offsets for videos
@@ -226,6 +240,7 @@ void CAsyncGetItemsForPlaylist::GetItemsForPlaylist(const std::shared_ptr<CFileI
const bool unwatchedOnly = watchedMode == WatchedModeUnwatched;
const bool watchedOnly = watchedMode == WatchedModeWatched;
+ bool fetchedPlayCounts = false;
for (const auto& i : items)
{
if (i->m_bIsFolder)
@@ -235,11 +250,25 @@ void CAsyncGetItemsForPlaylist::GetItemsForPlaylist(const std::shared_ptr<CFileI
if (StringUtils::EndsWithNoCase(path, "sample")) // skip sample folders
continue;
}
- else if (i->HasVideoInfoTag() &&
- ((unwatchedOnly && i->GetVideoInfoTag()->GetPlayCount() > 0) ||
- (watchedOnly && i->GetVideoInfoTag()->GetPlayCount() <= 0)))
- continue;
-
+ else
+ {
+ if (!fetchedPlayCounts &&
+ (!i->HasVideoInfoTag() || !i->GetVideoInfoTag()->IsPlayCountSet()))
+ {
+ CVideoDatabase db;
+ if (db.Open())
+ {
+ fetchedPlayCounts = true;
+ db.GetPlayCounts(items.GetPath(), items);
+ }
+ }
+ if (i->HasVideoInfoTag() && i->GetVideoInfoTag()->IsPlayCountSet())
+ {
+ const int playCount = i->GetVideoInfoTag()->GetPlayCount();
+ if ((unwatchedOnly && playCount > 0) || (watchedOnly && playCount <= 0))
+ continue;
+ }
+ }
GetItemsForPlaylist(i);
}
}