Permalink
Browse files

update old embedded music and video art URLs in the databases

  • Loading branch information...
Jonathan Marshall
Jonathan Marshall committed Oct 22, 2012
1 parent 02613b0 commit 481bb8e7ffe16e40646cbd2051cdb510e4b8d2c2
Showing with 28 additions and 2 deletions.
  1. +13 −0 xbmc/music/MusicDatabase.cpp
  2. +1 −1 xbmc/music/MusicDatabase.h
  3. +13 −0 xbmc/video/VideoDatabase.cpp
  4. +1 −1 xbmc/video/VideoDatabase.h
@@ -3636,6 +3636,19 @@ bool CMusicDatabase::UpdateOldVersion(int version)
g_settings.Save();
}

if (version < 29)
{ // update old art URLs
m_pDS->query("select art_id,url from art where url like 'image://%%'");
vector< pair<int, string> > art;
while (!m_pDS->eof())
{
art.push_back(make_pair(m_pDS->fv(0).get_asInt(), CURL(m_pDS->fv(1).get_asString()).Get()));
m_pDS->next();
}
m_pDS->close();
for (vector< pair<int, string> >::iterator i = art.begin(); i != art.end(); ++i)
m_pDS->exec(PrepareSQL("update art set url='%s' where art_id=%d", i->second.c_str(), i->first));
}
// always recreate the views after any table change
CreateViews();

@@ -278,7 +278,7 @@ class CMusicDatabase : public CDatabase
std::map<CStdString, CAlbum> m_albumCache;

virtual bool CreateTables();
virtual int GetMinVersion() const { return 28; };
virtual int GetMinVersion() const { return 29; };
const char *GetBaseDBName() const { return "MyMusic"; };

int AddSong(const CSong& song, bool bCheck = true, int idAlbum = -1);
@@ -4111,6 +4111,19 @@ bool CVideoDatabase::UpdateOldVersion(int iVersion)
}
m_pDS->exec("DROP TABLE IF EXISTS setlinkmovie");
}
if (iVersion < 70)
{ // update old art URLs
m_pDS->query("select art_id,url from art where url like 'image://%%'");
vector< pair<int, string> > art;
while (!m_pDS->eof())
{
art.push_back(make_pair(m_pDS->fv(0).get_asInt(), CURL(m_pDS->fv(1).get_asString()).Get()));
m_pDS->next();
}
m_pDS->close();
for (vector< pair<int, string> >::iterator i = art.begin(); i != art.end(); ++i)
m_pDS->exec(PrepareSQL("update art set url='%s' where art_id=%d", i->second.c_str(), i->first));
}
// 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 69; };
virtual int GetMinVersion() const { return 70; };
virtual int GetExportVersion() const { return 1; };
const char *GetBaseDBName() const { return "MyVideos"; };

0 comments on commit 481bb8e

Please sign in to comment.