Skip to content

Commit

Permalink
smartplaylists: add tag field for tvshows and musicvideos
Browse files Browse the repository at this point in the history
  • Loading branch information
Montellese committed Feb 4, 2013
1 parent 3fb2f9d commit b22f67f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 8 additions & 3 deletions xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp
Expand Up @@ -298,10 +298,15 @@ void CGUIDialogSmartPlaylistRule::OnBrowse()
}
else if (m_rule.m_field == FieldTag)
{
if (m_type == "movies")
videodatabase.GetTagsNav(basePath + "9/", items, VIDEODB_CONTENT_MOVIES);
else
VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES;
if (m_type == "tvshows")
type = VIDEODB_CONTENT_TVSHOWS;
else if (m_type == "musicvideos")
type = VIDEODB_CONTENT_MUSICVIDEOS;
else if (m_type != "movies")
return;

videodatabase.GetTagsNav(basePath + "9/", items, type);
iLabel = 20459;
}
else
Expand Down
6 changes: 6 additions & 0 deletions xbmc/playlists/SmartPlayList.cpp
Expand Up @@ -418,6 +418,7 @@ vector<Field> CSmartPlaylistRule::GetFields(const CStdString &type)
fields.push_back(FieldDateAdded);
fields.push_back(FieldLastPlayed);
fields.push_back(FieldInProgress);
fields.push_back(FieldTag);
}
else if (type == "episodes")
{
Expand Down Expand Up @@ -489,6 +490,7 @@ vector<Field> CSmartPlaylistRule::GetFields(const CStdString &type)
fields.push_back(FieldDirector);
fields.push_back(FieldStudio);
fields.push_back(FieldPlot);
fields.push_back(FieldTag);
fields.push_back(FieldDateAdded);
isVideo = true;
}
Expand Down Expand Up @@ -899,6 +901,8 @@ CStdString CSmartPlaylistRule::GetWhereClause(const CDatabase &db, const CStdStr
query = GetField(FieldId, strType) + negate + " IN (SELECT idMVideo FROM directorlinkmusicvideo JOIN actors ON actors.idActor=directorlinkmusicvideo.idDirector WHERE actors.strActor" + parameter + ")";
else if ((m_field == FieldLastPlayed || m_field == FieldDateAdded) && (m_operator == OPERATOR_LESS_THAN || m_operator == OPERATOR_BEFORE || m_operator == OPERATOR_NOT_IN_THE_LAST))
query = GetField(m_field, strType) + " IS NULL OR " + GetField(m_field, strType) + parameter;
else if (m_field == FieldTag)
query = GetField(FieldId, strType) + negate + " IN (SELECT idMedia FROM taglinks JOIN tag ON tag.idTag = taglinks.idTag WHERE tag.strTag" + parameter + " AND taglinks.media_type = 'musicvideo')";
}
else if (strType == "tvshows")
{
Expand All @@ -918,6 +922,8 @@ CStdString CSmartPlaylistRule::GetWhereClause(const CDatabase &db, const CStdStr
query = GetField(m_field, strType) + " IS NULL OR " + GetField(m_field, strType) + parameter;
else if (m_field == FieldPlaycount)
query = "CASE WHEN COALESCE(" + GetField(FieldNumberOfEpisodes, strType) + " - " + GetField(FieldNumberOfWatchedEpisodes, strType) + ", 0) > 0 THEN 0 ELSE 1 END " + parameter;
else if (m_field == FieldTag)
query = GetField(FieldId, strType) + negate + " IN (SELECT idMedia FROM taglinks JOIN tag ON tag.idTag = taglinks.idTag WHERE tag.strTag" + parameter + " AND taglinks.media_type = 'tvshow')";
}
else if (strType == "episodes")
{
Expand Down

0 comments on commit b22f67f

Please sign in to comment.