Permalink
Browse files

update the pre-Frodo art in the database to poster/banner based on as…

…pect ratio
  • Loading branch information...
Jonathan Marshall
Jonathan Marshall committed Oct 28, 2012
1 parent 89e40ca commit 412b01891cb870142b5e6973d3169ea14043c21c
Showing with 48 additions and 1 deletion.
  1. +3 −0 xbmc/DatabaseManager.cpp
  2. +44 −0 xbmc/video/VideoDatabase.cpp
  3. +1 −1 xbmc/video/VideoDatabase.h
@@ -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); }
@@ -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)
@@ -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;
@@ -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"; };

0 comments on commit 412b018

Please sign in to comment.