Skip to content

Commit

Permalink
[musicdb] export art from the texturecache (or as XML nodes) when exp…
Browse files Browse the repository at this point in the history
…orting the music library
  • Loading branch information
Jonathan Marshall committed Jul 3, 2012
1 parent 06e7b4d commit 2592424
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions xbmc/music/MusicDatabase.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include "utils/AutoPtrHandle.h" #include "utils/AutoPtrHandle.h"
#include "interfaces/AnnouncementManager.h" #include "interfaces/AnnouncementManager.h"
#include "dbwrappers/dataset.h" #include "dbwrappers/dataset.h"
#include "utils/XMLUtils.h"


using namespace std; using namespace std;
using namespace AUTOPTR; using namespace AUTOPTR;
Expand Down Expand Up @@ -4519,6 +4520,15 @@ void CMusicDatabase::ExportToXML(const CStdString &xmlFile, bool singleFiles, bo
CStdString strPath; CStdString strPath;
GetArtistPath(artist.idArtist,strPath); GetArtistPath(artist.idArtist,strPath);
artist.Save(pMain, "artist", strPath); artist.Save(pMain, "artist", strPath);

map<string, string> artwork;
if (GetArtForItem(artist.idArtist, "artist", artwork) && !singleFiles)
{ // append to the XML
TiXmlElement additionalNode("art");
for (map<string, string>::const_iterator i = artwork.begin(); i != artwork.end(); ++i)
XMLUtils::SetString(&additionalNode, i->first.c_str(), i->second);
pMain->LastChild()->InsertEndChild(additionalNode);
}
if (singleFiles) if (singleFiles)
{ {
if (!CDirectory::Exists(strPath)) if (!CDirectory::Exists(strPath))
Expand All @@ -4533,13 +4543,14 @@ void CMusicDatabase::ExportToXML(const CStdString &xmlFile, bool singleFiles, bo
CLog::Log(LOGERROR, "%s: Artist nfo export failed! ('%s')", __FUNCTION__, nfoFile.c_str()); CLog::Log(LOGERROR, "%s: Artist nfo export failed! ('%s')", __FUNCTION__, nfoFile.c_str());
} }


if (images) if (images && !artwork.empty())
{ {
CFileItem item(artist); CStdString savedThumb = URIUtils::AddFileToFolder(strPath,"folder.jpg");
if (CFile::Exists(item.GetCachedArtistThumb()) && (overwrite || !CFile::Exists(URIUtils::AddFileToFolder(strPath,"folder.jpg")))) CStdString savedFanart = URIUtils::AddFileToFolder(strPath,"fanart.jpg");
CFile::Cache(item.GetCachedArtistThumb(),URIUtils::AddFileToFolder(strPath,"folder.jpg")); if (artwork.find("thumb") != artwork.end() && (overwrite || !CFile::Exists(savedThumb)))
if (CFile::Exists(item.GetCachedFanart()) && (overwrite || !CFile::Exists(URIUtils::AddFileToFolder(strPath,"fanart.jpg")))) CTextureCache::Get().Export(artwork["thumb"], savedThumb);
CFile::Cache(item.GetCachedFanart(),URIUtils::AddFileToFolder(strPath,"fanart.jpg")); if (artwork.find("fanart") != artwork.end() && (overwrite || !CFile::Exists(savedFanart)))
CTextureCache::Get().Export(artwork["fanart"], savedFanart);
} }
xmlDoc.Clear(); xmlDoc.Clear();
TiXmlDeclaration decl("1.0", "UTF-8", "yes"); TiXmlDeclaration decl("1.0", "UTF-8", "yes");
Expand Down

0 comments on commit 2592424

Please sign in to comment.