Skip to content

Commit

Permalink
update the pre-Frodo art in the database to poster/banner based on as…
Browse files Browse the repository at this point in the history
…pect ratio
  • Loading branch information
Jonathan Marshall committed Oct 31, 2012
1 parent 89e40ca commit 412b018
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions xbmc/DatabaseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ void CDatabaseManager::Initialize(bool addonsOnly)
if (addonsOnly)
return;
CLog::Log(LOGDEBUG, "%s, updating databases...", __FUNCTION__);

// NOTE: Order here is important. In particular, CTextureDatabase has to be updated
// before CVideoDatabase.
{ CViewDatabase db; UpdateDatabase(db); }
{ CTextureDatabase db; UpdateDatabase(db); }
{ CMusicDatabase db; UpdateDatabase(db, &g_advancedSettings.m_databaseMusic); }
Expand Down
44 changes: 44 additions & 0 deletions xbmc/video/VideoDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3872,6 +3872,17 @@ bool CVideoDatabase::ScraperInUse(const CStdString &scraperID) const
return false;
}

class CArtItem
{
public:
CArtItem() { art_id = 0; media_id = 0; };
int art_id;
string art_type;
string art_url;
int media_id;
string media_type;
};

bool CVideoDatabase::UpdateOldVersion(int iVersion)
{
if (iVersion < 43)
Expand Down Expand Up @@ -4142,6 +4153,39 @@ bool CVideoDatabase::UpdateOldVersion(int iVersion)
m_pDS->exec(PrepareSQL("UPDATE files SET strFilename='%s' WHERE idFile=%d", filename.c_str(), i->first));
}
}
if (iVersion < 72)
{ // Update thumb to poster or banner as applicable
CTextureDatabase db;
if (db.Open())
{
m_pDS->query("select art_id,url,media_id,media_type from art where type='thumb' and media_type in ('movie', 'musicvideo', 'tvshow', 'season', 'set')");
vector<CArtItem> art;
while (!m_pDS->eof())
{
CTextureDetails details;
if (db.GetCachedTexture(m_pDS->fv(1).get_asString(), details))
{
CArtItem item;
item.art_id = m_pDS->fv(0).get_asInt();
item.art_url = m_pDS->fv(1).get_asString();
item.art_type = CVideoInfoScanner::GetArtTypeFromSize(details.width, details.height);
item.media_id = m_pDS->fv(2).get_asInt();
item.media_type = m_pDS->fv(3).get_asString();
if (item.art_type != "thumb")
art.push_back(item);
}
m_pDS->next();
}
m_pDS->close();
for (vector<CArtItem>::iterator i = art.begin(); i != art.end(); ++i)
{
if (GetArtForItem(i->media_id, i->media_type, i->art_type).empty())
m_pDS->exec(PrepareSQL("update art set type='%s' where art_id=%d", i->art_type.c_str(), i->art_id));
else
m_pDS->exec(PrepareSQL("delete from art where art_id=%d", i->art_id));
}
}
}
// always recreate the view after any table change
CreateViews();
return true;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/video/VideoDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ class CVideoDatabase : public CDatabase
*/
bool LookupByFolders(const CStdString &path, bool shows = false);

virtual int GetMinVersion() const { return 71; };
virtual int GetMinVersion() const { return 72; };
virtual int GetExportVersion() const { return 1; };
const char *GetBaseDBName() const { return "MyVideos"; };

Expand Down

0 comments on commit 412b018

Please sign in to comment.