Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[database] - add setting for hiding watched movies/episodes in recently added lists #5747

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions addons/resource.language.en_gb/resources/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -11176,7 +11176,13 @@ msgctxt "#20469"
msgid "Keep current set (%s)"
msgstr ""

#empty strings from id 20470 to 21329
#. Label of setting "Videos -> Library -> Hide watched videos in recently added list (home screen)"
#: system/settings/settings.xml
msgctxt "#20470"
msgid "Hide watched videos in recently added list (home screen)"
msgstr ""

#empty strings from id 20471 to 21329
#up to 21329 is reserved for the video db !! !

#: system/settings/settings.xml
Expand Down Expand Up @@ -16012,7 +16018,13 @@ msgctxt "#36435"
msgid "Use DVDPlayer for decoding of video files with MMAL acceleration."
msgstr ""

#empty strings from id 36436 to 36499
#. Description of setting "Videos -> Library -> Hide watched videos in recently added list."
#: system/settings/settings.xml
msgctxt "#36436"
msgid "If enabled all watched items in the recently added list on the home screen will be hidden. This includes movies, episodes and musicvideos. The effect depends on the used skin and its settings."
msgstr ""

#empty strings from id 36437 to 36499
#end reservation

#. label of a setting for the stereoscopic 3D mode of the GUI that is/should be applied
Expand Down
5 changes: 5 additions & 0 deletions system/settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,11 @@
<default>false</default>
<control type="toggle" />
</setting>
<setting id="videolibrary.hiderecentlywatchedvideos" type="boolean" label="20470" help="36436">
<level>1</level>
<default>true</default>
<control type="toggle" />
</setting>
</group>
<group id="2">
<setting id="videolibrary.updateonstartup" type="boolean" label="22000" help="36146">
Expand Down
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