Skip to content
Browse files

Merge pull request #661 from jmarshallnz/sets_in_smartplaylists

bring sets back into smartplaylists now that a UI option is there
  • Loading branch information...
2 parents 0f9b3ed + 4aab872 commit b80fae4440dacc3195268669534d681698d688bf @jmarshallnz jmarshallnz committed Jan 27, 2012
Showing with 14 additions and 10 deletions.
  1. +14 −10 xbmc/video/VideoDatabase.cpp
View
24 xbmc/video/VideoDatabase.cpp
@@ -4710,17 +4710,21 @@ bool CVideoDatabase::GetMoviesByWhere(const CStdString& strBaseDir, const CStdSt
if (NULL == m_pDS.get()) return false;
CStdString strSQL = "select * from movieview ";
-
- if (where.size())
- strSQL += where;
- else
- {
- if (fetchSets && g_guiSettings.GetBool("videolibrary.groupmoviesets"))
- {
- GetSetsNav("videodb://1/7/", items, VIDEODB_CONTENT_MOVIES, "");
- strSQL += PrepareSQL("WHERE movieview.idMovie NOT IN (SELECT idMovie FROM setlinkmovie s1 JOIN(SELECT idSet, COUNT(1) AS c FROM setlinkmovie GROUP BY idSet HAVING c>1) s2 ON s2.idSet=s1.idSet)");
- }
+ if (fetchSets && g_guiSettings.GetBool("videolibrary.groupmoviesets"))
+ {
+ // user wants sets (and we're not fetching a particular set node), so grab all sets that match this where clause first
+ CStdString setsWhere;
+ if (where.size())
+ setsWhere = " where movie.idMovie in (select movieview.idMovie from movieview " + where + ")";
+ GetSetsNav("videodb://1/7/", items, VIDEODB_CONTENT_MOVIES, setsWhere);
+ CStdString movieSetsWhere = "movieview.idMovie NOT IN (SELECT idMovie FROM setlinkmovie s1 JOIN(SELECT idSet, COUNT(1) AS c FROM setlinkmovie GROUP BY idSet HAVING c>1) s2 ON s2.idSet=s1.idSet)";
+ if (where.size())
+ strSQL += where + PrepareSQL(" and " + movieSetsWhere);
+ else
+ strSQL += PrepareSQL(" WHERE " + movieSetsWhere);
}
+ else
+ strSQL += where;
if (order.size())
strSQL += " " + order;

1 comment on commit b80fae4

@MartijnKaijser
Team Kodi member

This fixes trac ticket #11949 i think

Please sign in to comment.
Something went wrong with that request. Please try again.