aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmarshallnz <jcmarsha@gmail.com>2014-05-26 18:06:46 +1200
committerjmarshallnz <jcmarsha@gmail.com>2014-05-26 18:06:46 +1200
commit27770a30a75797ea296fdb76852456665b5f1bb5 (patch)
treef244a4766e7a665a8ddce2423e6d47de3ae1eec5
parent14850f61dccdaaef90178569f2c8946d89a5a74a (diff)
parentd30ede7e9436fff5e419418dd079d692f94ee15e (diff)
Merge pull request #4798 from jmarshallnz/no_imdb_no_problem
[videodb] don't lookup playcounts when adding movies with no imdb/year
-rw-r--r--xbmc/video/VideoDatabase.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp
index 26ec0ee788..2e8fa74b53 100644
--- a/xbmc/video/VideoDatabase.cpp
+++ b/xbmc/video/VideoDatabase.cpp
@@ -2080,26 +2080,27 @@ int CVideoDatabase::SetDetailsForMovie(const CStdString& strFilenameAndPath, con
SetArtForItem(idMovie, MediaTypeMovie, artwork);
- // query DB for any movies matching imdbid and year
- CStdString strSQL = PrepareSQL("select files.playCount, files.lastPlayed from movie,files where files.idFile=movie.idFile and movie.c%02d='%s' and movie.c%02d=%i and movie.idMovie!=%i and files.playCount > 0", VIDEODB_ID_IDENT, details.m_strIMDBNumber.c_str(), VIDEODB_ID_YEAR, details.m_iYear, idMovie);
- m_pDS->query(strSQL.c_str());
-
- if (!m_pDS->eof())
- {
- int playCount = m_pDS->fv("files.playCount").get_asInt();
+ if (!details.m_strIMDBNumber.empty() && details.m_iYear)
+ { // query DB for any movies matching imdbid and year
+ CStdString strSQL = PrepareSQL("select files.playCount, files.lastPlayed from movie,files where files.idFile=movie.idFile and movie.c%02d='%s' and movie.c%02d=%i and movie.idMovie!=%i and files.playCount > 0", VIDEODB_ID_IDENT, details.m_strIMDBNumber.c_str(), VIDEODB_ID_YEAR, details.m_iYear, idMovie);
+ m_pDS->query(strSQL.c_str());
- CDateTime lastPlayed;
- lastPlayed.SetFromDBDateTime(m_pDS->fv("files.lastPlayed").get_asString());
+ if (!m_pDS->eof())
+ {
+ int playCount = m_pDS->fv("files.playCount").get_asInt();
- int idFile = GetFileId(strFilenameAndPath);
+ CDateTime lastPlayed;
+ lastPlayed.SetFromDBDateTime(m_pDS->fv("files.lastPlayed").get_asString());
- // update with playCount and lastPlayed
- strSQL = PrepareSQL("update files set playCount=%i,lastPlayed='%s' where idFile=%i", playCount, lastPlayed.GetAsDBDateTime().c_str(), idFile);
- m_pDS->exec(strSQL.c_str());
- }
+ int idFile = GetFileId(strFilenameAndPath);
- m_pDS->close();
+ // update with playCount and lastPlayed
+ strSQL = PrepareSQL("update files set playCount=%i,lastPlayed='%s' where idFile=%i", playCount, lastPlayed.GetAsDBDateTime().c_str(), idFile);
+ m_pDS->exec(strSQL.c_str());
+ }
+ m_pDS->close();
+ }
// update our movie table (we know it was added already above)
// and insert the new row
CStdString sql = "update movie set " + GetValueString(details, VIDEODB_ID_MIN, VIDEODB_ID_MAX, DbMovieOffsets);