Browse files

Merge pull request #665 from Montellese/set_smartplaylist_cleanup

fix movies being part of multiple 1-movie-set being listed multiple times
  • Loading branch information...
2 parents 17c23a1 + fff6573 commit 489c2978982fa9f27d8307369bb84b7a19cb2d11 @Montellese Montellese committed Jan 31, 2012
Showing with 14 additions and 22 deletions.
  1. +11 −6 xbmc/playlists/SmartPlayList.cpp
  2. +2 −15 xbmc/video/VideoDatabase.cpp
  3. +1 −1 xbmc/video/VideoDatabase.h
View
17 xbmc/playlists/SmartPlayList.cpp
@@ -264,12 +264,15 @@ vector<CSmartPlaylistRule::DATABASE_FIELD> CSmartPlaylistRule::GetFields(const C
fields.push_back(FIELD_AIRDATE);
fields.push_back(FIELD_PLAYCOUNT);
fields.push_back(FIELD_LASTPLAYED);
- fields.push_back(FIELD_INPROGRESS);
if (!sortOrders)
+ {
+ fields.push_back(FIELD_INPROGRESS);
fields.push_back(FIELD_GENRE);
+ }
fields.push_back(FIELD_YEAR); // premiered
fields.push_back(FIELD_DIRECTOR);
- fields.push_back(FIELD_ACTOR);
+ if (!sortOrders)
+ fields.push_back(FIELD_ACTOR);
fields.push_back(FIELD_EPISODE);
fields.push_back(FIELD_SEASON);
fields.push_back(FIELD_FILENAME);
@@ -291,7 +294,8 @@ vector<CSmartPlaylistRule::DATABASE_FIELD> CSmartPlaylistRule::GetFields(const C
fields.push_back(FIELD_WRITER);
fields.push_back(FIELD_PLAYCOUNT);
fields.push_back(FIELD_LASTPLAYED);
- fields.push_back(FIELD_INPROGRESS);
+ if (!sortOrders)
+ fields.push_back(FIELD_INPROGRESS);
fields.push_back(FIELD_GENRE);
fields.push_back(FIELD_COUNTRY);
fields.push_back(FIELD_YEAR); // premiered
@@ -304,7 +308,8 @@ vector<CSmartPlaylistRule::DATABASE_FIELD> CSmartPlaylistRule::GetFields(const C
fields.push_back(FIELD_HASTRAILER);
fields.push_back(FIELD_FILENAME);
fields.push_back(FIELD_PATH);
- fields.push_back(FIELD_SET);
+ if (!sortOrders)
+ fields.push_back(FIELD_SET);
isVideo = true;
// fields.push_back(FIELD_DATEADDED); // no date added yet in db
}
@@ -677,7 +682,7 @@ CStdString CSmartPlaylistRule::GetDatabaseField(DATABASE_FIELD field, const CStd
else if (field == FIELD_PATH) result = "strPath";
else if (field == FIELD_RANDOM) result = "RANDOM()"; // only used for order clauses
else if (field == FIELD_DATEADDED) result = "idMovie"; // only used for order clauses
- else if (field == FIELD_SET) result = "idSet"; // only used for order clauses
+ else if (field == FIELD_SET) result = "cant_order_by_set";
return result;
}
else if (type == "musicvideos")
@@ -719,7 +724,7 @@ CStdString CSmartPlaylistRule::GetDatabaseField(DATABASE_FIELD field, const CStd
else if (field == FIELD_PLAYCOUNT) result = "watched";
else if (field == FIELD_RANDOM) result = "RANDOM()"; // only used for order clauses
else if (field == FIELD_DATEADDED) result = "idShow"; // only used for order clauses
- else if (field == FIELD_PATH) return "strPath";
+ else if (field == FIELD_PATH) result = "strPath";
return result;
}
if (type == "episodes")
View
17 xbmc/video/VideoDatabase.cpp
@@ -363,21 +363,8 @@ void CVideoDatabase::CreateViews()
CLog::Log(LOGINFO, "create movieview");
m_pDS->exec("DROP VIEW IF EXISTS movieview");
- CStdString movieview = PrepareSQL("CREATE VIEW movieview AS SELECT "
- "movie.*,"
- "files.strFileName AS strFileName,"
- "path.strPath AS strPath,"
- "files.playCount AS playCount,"
- "files.lastPlayed AS lastPlayed,"
- " NULLIF(setlinkmovie.idSet, 0) AS idSet "
- "FROM movie"
- " LEFT JOIN setlinkmovie ON"
- " setlinkmovie.idMovie=movie.idMovie"
- " LEFT JOIN files ON"
- " files.idFile=movie.idFile"
- " LEFT JOIN path ON"
- " path.idPath=files.idPath");
- m_pDS->exec(movieview.c_str());
+ m_pDS->exec("create view movieview as select movie.*,files.strFileName as strFileName,path.strPath as strPath,files.playCount as playCount,files.lastPlayed as lastPlayed "
+ "from movie join files on files.idFile=movie.idFile join path on path.idPath=files.idPath");
}
//********************************************************************************************************************************
View
2 xbmc/video/VideoDatabase.h
@@ -722,7 +722,7 @@ class CVideoDatabase : public CDatabase
*/
bool LookupByFolders(const CStdString &path, bool shows = false);
- virtual int GetMinVersion() const { return 59; };
+ virtual int GetMinVersion() const { return 60; };
virtual int GetExportVersion() const { return 1; };
const char *GetBaseDBName() const { return "MyVideos"; };

0 comments on commit 489c297

Please sign in to comment.