Permalink
Browse files

[videodb] fetch season year based on first aired episode

  • Loading branch information...
mkortstiege committed Jul 2, 2015
1 parent 99f9254 commit 8765daf81b8c529182887da0f11bd62cd67bcc0b
Showing with 12 additions and 4 deletions.
  1. +11 −4 xbmc/video/VideoDatabase.cpp
  2. +1 −0 xbmc/video/VideoDatabase.h
@@ -396,7 +396,8 @@ void CVideoDatabase::CreateViews()
" tvshow_view.c%02d AS studio,"
" tvshow_view.c%02d AS mpaa,"
" count(DISTINCT episode_view.idEpisode) AS episodes,"
" count(files.playCount) AS playCount "
" count(files.playCount) AS playCount,"
" min(episode_view.c%02d) AS aired "
"FROM seasons"
" JOIN tvshow_view ON"
" tvshow_view.idShow = seasons.idShow"
@@ -407,7 +408,7 @@ void CVideoDatabase::CreateViews()
"GROUP BY seasons.idSeason",
VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_PLOT, VIDEODB_ID_TV_PREMIERED,
VIDEODB_ID_TV_GENRE, VIDEODB_ID_TV_STUDIOS, VIDEODB_ID_TV_MPAA,
VIDEODB_ID_EPISODE_SEASON);
VIDEODB_ID_EPISODE_AIRED, VIDEODB_ID_EPISODE_SEASON);
m_pDS->exec(seasonview.c_str());

CLog::Log(LOGINFO, "create musicvideo_view");
@@ -4752,7 +4753,7 @@ void CVideoDatabase::UpdateTables(int iVersion)

int CVideoDatabase::GetSchemaVersion() const
{
return 93;
return 94;
}

bool CVideoDatabase::LookupByFolders(const std::string &path, bool shows)
@@ -5972,7 +5973,13 @@ bool CVideoDatabase::GetSeasonsByWhere(const std::string& strBaseDir, const Filt
pItem->GetVideoInfoTag()->m_strShowTitle = m_pDS->fv(VIDEODB_ID_SEASON_TVSHOW_TITLE).get_asString();
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());
if (pItem->GetVideoInfoTag()->m_premiered.IsValid())
pItem->GetVideoInfoTag()->m_firstAired.SetFromDBDate(m_pDS->fv(VIDEODB_ID_SEASON_PREMIERED).get_asString());

// season premiered date based on first episode airdate associated to the season
// tvshow premiered date is used as a fallback
if (pItem->GetVideoInfoTag()->m_firstAired.IsValid())
pItem->GetVideoInfoTag()->m_iYear = pItem->GetVideoInfoTag()->m_firstAired.GetYear();
else if (pItem->GetVideoInfoTag()->m_premiered.IsValid())
pItem->GetVideoInfoTag()->m_iYear = pItem->GetVideoInfoTag()->m_premiered.GetYear();
pItem->GetVideoInfoTag()->m_genre = StringUtils::Split(m_pDS->fv(VIDEODB_ID_SEASON_TVSHOW_GENRE).get_asString(), g_advancedSettings.m_videoItemSeparator);
pItem->GetVideoInfoTag()->m_studio = StringUtils::Split(m_pDS->fv(VIDEODB_ID_SEASON_TVSHOW_STUDIO).get_asString(), g_advancedSettings.m_videoItemSeparator);
@@ -247,6 +247,7 @@ typedef enum // this enum MUST match the offset struct further down!! and make s
VIDEODB_ID_SEASON_TVSHOW_MPAA = 9,
VIDEODB_ID_SEASON_EPISODES_TOTAL = 10,
VIDEODB_ID_SEASON_EPISODES_WATCHED = 11,
VIDEODB_ID_SEASON_PREMIERED = 12,
VIDEODB_ID_SEASON_MAX
} VIDEODB_SEASON_IDS;

0 comments on commit 8765daf

Please sign in to comment.