Skip to content

Commit

Permalink
[videodb] - evaluate the setting for hiding watched
Browse files Browse the repository at this point in the history
movies/episodes/musicvideos in
recently added job (should influence homescreen of skins only)
  • Loading branch information
Memphiz committed May 19, 2015
1 parent 42d7fc8 commit 506d78c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
10 changes: 5 additions & 5 deletions xbmc/utils/RecentlyAddedJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "utils/Variant.h"
#include "utils/StringUtils.h"
#include "settings/AdvancedSettings.h"
#include "settings/Settings.h"
#include "music/MusicThumbLoader.h"
#include "video/VideoThumbLoader.h"

Expand All @@ -57,8 +58,8 @@ bool CRecentlyAddedJob::UpdateVideo()
loader.OnLoaderStart();

videodatabase.Open();

if (videodatabase.GetRecentlyAddedMoviesNav("videodb://recentlyaddedmovies/", items, NUM_ITEMS))
bool hideWatched = CSettings::Get().GetBool("videolibrary.hiderecentlywatchedvideos");
if (videodatabase.GetRecentlyAddedMoviesNav("videodb://recentlyaddedmovies/", items, NUM_ITEMS, hideWatched))
{
for (; i < items.Size(); ++i)
{
Expand Down Expand Up @@ -97,8 +98,7 @@ bool CRecentlyAddedJob::UpdateVideo()

i = 0;
CFileItemList TVShowItems;

if (videodatabase.GetRecentlyAddedEpisodesNav("videodb://recentlyaddedepisodes/", TVShowItems, NUM_ITEMS))
if (videodatabase.GetRecentlyAddedEpisodesNav("videodb://recentlyaddedepisodes/", TVShowItems, NUM_ITEMS, hideWatched))
{
for (; i < TVShowItems.Size(); ++i)
{
Expand Down Expand Up @@ -151,7 +151,7 @@ bool CRecentlyAddedJob::UpdateVideo()
i = 0;
CFileItemList MusicVideoItems;

if (videodatabase.GetRecentlyAddedMusicVideosNav("videodb://recentlyaddedmusicvideos/", MusicVideoItems, NUM_ITEMS))
if (videodatabase.GetRecentlyAddedMusicVideosNav("videodb://recentlyaddedmusicvideos/", MusicVideoItems, NUM_ITEMS, hideWatched))
{
for (; i < MusicVideoItems.Size(); ++i)
{
Expand Down
27 changes: 24 additions & 3 deletions xbmc/video/VideoDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6579,27 +6579,48 @@ bool CVideoDatabase::GetMusicVideosNav(const std::string& strBaseDir, CFileItemL
return GetMusicVideosByWhere(videoUrl.ToString(), filter, items, true, sortDescription);
}

bool CVideoDatabase::GetRecentlyAddedMoviesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit)
bool CVideoDatabase::GetRecentlyAddedMoviesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit, bool hideWatched)
{
Filter filter;
filter.order = "dateAdded desc, idMovie desc";
filter.limit = PrepareSQL("%u", limit ? limit : g_advancedSettings.m_iVideoLibraryRecentlyAddedItems);

if (hideWatched)
{
filter.AppendWhere("playCount <= 0");// only query unwatched items
filter.AppendWhere("playCount IS NULL", false);
}

return GetMoviesByWhere(strBaseDir, filter, items);
}

bool CVideoDatabase::GetRecentlyAddedEpisodesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit)
bool CVideoDatabase::GetRecentlyAddedEpisodesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit, bool hideWatched)
{
Filter filter;
filter.order = "dateAdded desc, idEpisode desc";
filter.limit = PrepareSQL("%u", limit ? limit : g_advancedSettings.m_iVideoLibraryRecentlyAddedItems);

if (hideWatched)
{
filter.AppendWhere("playCount <= 0");// only query unwatched items
filter.AppendWhere("playCount IS NULL", false);
}

return GetEpisodesByWhere(strBaseDir, filter, items, false);
}

bool CVideoDatabase::GetRecentlyAddedMusicVideosNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit)
bool CVideoDatabase::GetRecentlyAddedMusicVideosNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit, bool hideWatched)
{
Filter filter;
filter.order = "dateAdded desc, idMVideo desc";
filter.limit = PrepareSQL("%u", limit ? limit : g_advancedSettings.m_iVideoLibraryRecentlyAddedItems);

if (hideWatched)
{
filter.AppendWhere("playCount <= 0");// only query unwatched items
filter.AppendWhere("playCount IS NULL", false);
}

return GetMusicVideosByWhere(strBaseDir, filter, items);
}

Expand Down
6 changes: 3 additions & 3 deletions xbmc/video/VideoDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,9 @@ class CVideoDatabase : public CDatabase
bool GetEpisodesNav(const std::string& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idShow=-1, int idSeason=-1, const SortDescription &sortDescription = SortDescription());
bool GetMusicVideosNav(const std::string& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idArtist=-1, int idDirector=-1, int idStudio=-1, int idAlbum=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription());

bool GetRecentlyAddedMoviesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0);
bool GetRecentlyAddedEpisodesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0);
bool GetRecentlyAddedMusicVideosNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0);
bool GetRecentlyAddedMoviesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0, bool hideWatched=false);
bool GetRecentlyAddedEpisodesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0, bool hideWatched=false);
bool GetRecentlyAddedMusicVideosNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0, bool hideWatched=false);

bool HasContent();
bool HasContent(VIDEODB_CONTENT_TYPE type);
Expand Down

0 comments on commit 506d78c

Please sign in to comment.