Permalink
Browse files

Add userratings to seasons

  • Loading branch information...
Razzeee committed Dec 25, 2015
1 parent 1ee82c3 commit 287d14ba5c0d2cbcd01bed1d5859013e5e77d92e
@@ -1408,7 +1408,8 @@
"permission": "UpdateData",
"params": [
{ "name": "seasonid", "$ref": "Library.Id", "required": true },
{ "name": "art", "type": [ "null", { "$ref": "Media.Artwork.Set", "required": true } ], "default": null }
{ "name": "art", "type": [ "null", { "$ref": "Media.Artwork.Set", "required": true } ], "default": null },
{ "name": "userrating", "$ref": "Optional.Integer" }
],
"returns": "string"
},
@@ -540,7 +540,7 @@
"extends": "Item.Fields.Base",
"items": { "type": "string",
"enum": [ "season", "showtitle", "playcount", "episode", "fanart", "thumbnail", "tvshowid",
"watchedepisodes", "art" ]
"watchedepisodes", "art", "userrating" ]
}
},
"Video.Fields.Episode": {
@@ -727,7 +727,8 @@
"showtitle": { "type": "string" },
"episode": { "type": "integer" },
"watchedepisodes": { "type": "integer" },
"tvshowid": { "$ref": "Library.Id" }
"tvshowid": { "$ref": "Library.Id" },
"userrating": { "type": "integer" }
}
},
"Video.Details.Episode": {
@@ -1 +1 @@
7.0.1
7.0.2
@@ -191,7 +191,7 @@ void CVideoDatabase::CreateTables()
m_pDS->exec("CREATE TABLE sets ( idSet integer primary key, strSet text, strOverview text)");

CLog::Log(LOGINFO, "create seasons table");
m_pDS->exec("CREATE TABLE seasons ( idSeason integer primary key, idShow integer, season integer, name text)");
m_pDS->exec("CREATE TABLE seasons ( idSeason integer primary key, idShow integer, season integer, name text, userrating integer)");

CLog::Log(LOGINFO, "create art table");
m_pDS->exec("CREATE TABLE art(art_id INTEGER PRIMARY KEY, media_id INTEGER, media_type TEXT, type TEXT, url TEXT)");
@@ -2407,6 +2407,10 @@ int CVideoDatabase::SetDetailsForSeason(const CVideoInfoTag& details, const std:
std::string sql = PrepareSQL("UPDATE seasons SET season=%i", details.m_iSeason);
if (!details.m_strSortTitle.empty())
sql += PrepareSQL(", name='%s'", details.m_strSortTitle.c_str());
if (details.m_iUserRating > 0 && details.m_iUserRating < 11)
sql += PrepareSQL(", userrating = %i", details.m_iUserRating);
else
sql += ", userrating = NULL";
sql += PrepareSQL(" WHERE idSeason=%i", idSeason);
m_pDS->exec(sql.c_str());
CommitTransaction();
@@ -4680,11 +4684,13 @@ void CVideoDatabase::UpdateTables(int iVersion)
m_pDS->next();
}
}
if (iVersion < 101)
m_pDS->exec("ALTER TABLE seasons ADD userrating INTEGER");
}

int CVideoDatabase::GetSchemaVersion() const
{
return 100;
return 101;
}

bool CVideoDatabase::LookupByFolders(const std::string &path, bool shows)
@@ -5914,6 +5920,7 @@ bool CVideoDatabase::GetSeasonsByWhere(const std::string& strBaseDir, const Filt
pItem->GetVideoInfoTag()->m_strPlot = m_pDS->fv(VIDEODB_ID_SEASON_TVSHOW_PLOT).get_asString();
pItem->GetVideoInfoTag()->m_premiered.SetFromDBDate(m_pDS->fv(VIDEODB_ID_SEASON_TVSHOW_PREMIERED).get_asString());
pItem->GetVideoInfoTag()->m_firstAired.SetFromDBDate(m_pDS->fv(VIDEODB_ID_SEASON_PREMIERED).get_asString());
pItem->GetVideoInfoTag()->m_iUserRating = m_pDS->fv(VIDEODB_ID_SEASON_USER_RATING).get_asInt();

// season premiered date based on first episode airdate associated to the season
// tvshow premiered date is used as a fallback
@@ -9424,6 +9431,8 @@ bool CVideoDatabase::SetVideoUserRating(int dbId, int rating, const MediaType& m
sql = PrepareSQL("UPDATE musicvideo SET userrating=%i WHERE idMVideo = %i", rating, dbId);
else if (mediaType == MediaTypeTvShow)
sql = PrepareSQL("UPDATE tvshow SET userrating=%i WHERE idShow = %i", rating, dbId);
else if (mediaType == MediaTypeSeason)
sql = PrepareSQL("UPDATE seasons SET userrating=%i WHERE idSeason = %i", rating, dbId);

m_pDS->exec(sql);
return true;
@@ -240,23 +240,25 @@ const struct SDbTableOffsets DbTvShowOffsets[] =
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strSortTitle)},
};

// TODO is this comment valid for seasons? There is no offset structure or am I wrong?
typedef enum // this enum MUST match the offset struct further down!! and make sure to keep min and max at -1 and sizeof(offsets)
{
VIDEODB_ID_SEASON_MIN = -1,
VIDEODB_ID_SEASON_ID = 0,
VIDEODB_ID_SEASON_TVSHOW_ID = 1,
VIDEODB_ID_SEASON_NUMBER = 2,
VIDEODB_ID_SEASON_NAME = 3,
VIDEODB_ID_SEASON_TVSHOW_PATH = 4,
VIDEODB_ID_SEASON_TVSHOW_TITLE = 5,
VIDEODB_ID_SEASON_TVSHOW_PLOT = 6,
VIDEODB_ID_SEASON_TVSHOW_PREMIERED = 7,
VIDEODB_ID_SEASON_TVSHOW_GENRE = 8,
VIDEODB_ID_SEASON_TVSHOW_STUDIO = 9,
VIDEODB_ID_SEASON_TVSHOW_MPAA = 10,
VIDEODB_ID_SEASON_EPISODES_TOTAL = 11,
VIDEODB_ID_SEASON_EPISODES_WATCHED = 12,
VIDEODB_ID_SEASON_PREMIERED = 13,
VIDEODB_ID_SEASON_USER_RATING = 4,
VIDEODB_ID_SEASON_TVSHOW_PATH = 5,
VIDEODB_ID_SEASON_TVSHOW_TITLE = 6,
VIDEODB_ID_SEASON_TVSHOW_PLOT = 7,
VIDEODB_ID_SEASON_TVSHOW_PREMIERED = 8,
VIDEODB_ID_SEASON_TVSHOW_GENRE = 9,
VIDEODB_ID_SEASON_TVSHOW_STUDIO = 10,
VIDEODB_ID_SEASON_TVSHOW_MPAA = 11,
VIDEODB_ID_SEASON_EPISODES_TOTAL = 12,
VIDEODB_ID_SEASON_EPISODES_WATCHED = 13,
VIDEODB_ID_SEASON_PREMIERED = 14,
VIDEODB_ID_SEASON_MAX
} VIDEODB_SEASON_IDS;

0 comments on commit 287d14b

Please sign in to comment.