Skip to content
This repository
Browse code

Merge pull request #1836 from Montellese/fix_13596

smartplaylists: two fixes
  • Loading branch information...
commit d63420e7b5a393b879c3719fbf8f3038896c1cc3 2 parents b49cacb + b8d3e4e
Chris Browet authored November 24, 2012
6  language/English/strings.po
@@ -9702,7 +9702,11 @@ msgctxt "#21456"
9702 9702
 msgid "External storage"
9703 9703
 msgstr ""
9704 9704
 
9705  
-#empty strings from id 21457 to 21459
  9705
+msgctxt "#21457"
  9706
+msgid "Watched episode count"
  9707
+msgstr ""
  9708
+
  9709
+#empty strings from id 21458 to 21459
9706 9710
 
9707 9711
 msgctxt "#21460"
9708 9712
 msgid "Subtitle location"
21  xbmc/playlists/SmartPlayList.cpp
@@ -91,7 +91,7 @@ static const translateField fields[] = {
91 91
   { "season",            FieldSeason,                  SortBySeason,                   CSmartPlaylistRule::NUMERIC_FIELD,    20373 },
92 92
   { "episode",           FieldEpisodeNumber,           SortByEpisodeNumber,            CSmartPlaylistRule::NUMERIC_FIELD,    20359 },
93 93
   { "numepisodes",       FieldNumberOfEpisodes,        SortByNumberOfEpisodes,         CSmartPlaylistRule::NUMERIC_FIELD,    20360 },
94  
-  { "numwatched",        FieldNumberOfWatchedEpisodes, SortByNumberOfWatchedEpisodes,  CSmartPlaylistRule::NUMERIC_FIELD,    21441 },
  94
+  { "numwatched",        FieldNumberOfWatchedEpisodes, SortByNumberOfWatchedEpisodes,  CSmartPlaylistRule::NUMERIC_FIELD,    21457 },
95 95
   { "videoresolution",   FieldVideoResolution,         SortByVideoResolution,          CSmartPlaylistRule::NUMERIC_FIELD,    21443 },
96 96
   { "videocodec",        FieldVideoCodec,              SortByVideoCodec,               CSmartPlaylistRule::TEXTIN_FIELD,     21445 },
97 97
   { "videoaspect",       FieldVideoAspectRatio,        SortByVideoAspectRatio,         CSmartPlaylistRule::NUMERIC_FIELD,    21374 },
@@ -693,9 +693,20 @@ CStdString CSmartPlaylistRule::GetWhereClause(const CDatabase &db, const CStdStr
693 693
     case OPERATOR_DOES_NOT_CONTAIN:
694 694
       negate = " NOT"; operatorString = " LIKE '%%%s%%'"; break;
695 695
     case OPERATOR_EQUALS:
696  
-      operatorString = " LIKE '%s'"; break;
  696
+      if (GetFieldType(m_field) == NUMERIC_FIELD || GetFieldType(m_field) == SECONDS_FIELD)
  697
+        operatorString = " = %s";
  698
+      else
  699
+        operatorString = " LIKE '%s'";
  700
+      break;
697 701
     case OPERATOR_DOES_NOT_EQUAL:
698  
-      negate = " NOT"; operatorString = " LIKE '%s'"; break;
  702
+      if (GetFieldType(m_field) == NUMERIC_FIELD || GetFieldType(m_field) == SECONDS_FIELD)
  703
+        operatorString = " != %s";
  704
+      else
  705
+      {
  706
+        negate = " NOT";
  707
+        operatorString = " LIKE '%s'";
  708
+      }
  709
+      break;
699 710
     case OPERATOR_STARTS_WITH:
700 711
       operatorString = " LIKE '%s%%'"; break;
701 712
     case OPERATOR_ENDS_WITH:
@@ -891,6 +902,8 @@ CStdString CSmartPlaylistRule::GetWhereClause(const CDatabase &db, const CStdStr
891 902
         query = GetField(FieldId, strType) + negate + " IN (SELECT idShow FROM tvshowview WHERE " + GetField(m_field, strType) + parameter + ")";
892 903
       else if ((m_field == FieldLastPlayed || m_field == FieldDateAdded) && (m_operator == OPERATOR_LESS_THAN || m_operator == OPERATOR_BEFORE || m_operator == OPERATOR_NOT_IN_THE_LAST))
893 904
         query = GetField(m_field, strType) + " IS NULL OR " + GetField(m_field, strType) + parameter;
  905
+      else if (m_field == FieldPlaycount)
  906
+        query = "CASE WHEN COALESCE(" + GetField(FieldNumberOfEpisodes, strType) + " - " + GetField(FieldNumberOfWatchedEpisodes, strType) + ", 0) > 0 THEN 0 ELSE 1 END " + parameter;
894 907
     }
895 908
     else if (strType == "episodes")
896 909
     {
@@ -925,7 +938,7 @@ CStdString CSmartPlaylistRule::GetWhereClause(const CDatabase &db, const CStdStr
925 938
       query = table + ".idFile" + negate + " IN (SELECT DISTINCT idFile FROM streamdetails WHERE strSubtitleLanguage " + parameter + ")";
926 939
     else if (m_field == FieldVideoAspectRatio)
927 940
       query = table + ".idFile" + negate + " IN (SELECT DISTINCT idFile FROM streamdetails WHERE fVideoAspect " + parameter + ")";
928  
-    if (m_field == FieldPlaycount && strType != "songs" && strType != "albums")
  941
+    if (m_field == FieldPlaycount && strType != "songs" && strType != "albums" && strType != "tvshows")
929 942
     { // playcount IS stored as NULL OR number IN video db
930 943
       if ((m_operator == OPERATOR_EQUALS && it->Equals("0")) ||
931 944
           (m_operator == OPERATOR_DOES_NOT_EQUAL && !it->Equals("0")) ||

0 notes on commit d63420e

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