changed: update version strings for beta4
[xbmc.git] / xbmc / utils / MusicArtistInfo.cpp
blob1893aff2069a7637f5d8975610bac8cac39ad74f
1 /*
2 * Copyright (C) 2005-2008 Team XBMC
3 * http://www.xbmc.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 #include "MusicArtistInfo.h"
23 #include "ScraperParser.h"
24 #include "addons/Scraper.h"
25 #include "XMLUtils.h"
26 #include "Settings.h"
27 #include "CharsetConverter.h"
28 #include "log.h"
30 using namespace MUSIC_GRABBER;
31 using namespace XFILE;
32 using namespace std;
34 CMusicArtistInfo::CMusicArtistInfo(void)
36 m_bLoaded = false;
39 CMusicArtistInfo::~CMusicArtistInfo(void)
43 CMusicArtistInfo::CMusicArtistInfo(const CStdString& strArtist, const CScraperUrl& strArtistURL)
45 m_artist.strArtist = strArtist;
46 m_artistURL = strArtistURL;
47 m_bLoaded = false;
50 const CArtist& CMusicArtistInfo::GetArtist() const
52 return m_artist;
55 CArtist& CMusicArtistInfo::GetArtist()
57 return m_artist;
60 void CMusicArtistInfo::SetArtist(const CArtist& artist)
62 m_artist = artist;
63 m_bLoaded = true;
66 const CScraperUrl& CMusicArtistInfo::GetArtistURL() const
68 return m_artistURL;
71 bool CMusicArtistInfo::Parse(const TiXmlElement* artist, bool bChained)
73 if (!m_artist.Load(artist,bChained))
74 return false;
76 SetLoaded(true);
78 return true;
81 bool CMusicArtistInfo::Load(CFileCurl& http, const ADDON::ScraperPtr& scraper)
83 // load our scraper xml
84 if (!scraper->Load())
85 return false;
87 vector<CStdString> extras;
88 extras.push_back(m_strSearch);
90 vector<CStdString> xml = scraper->Run("GetArtistDetails",GetArtistURL(),http,&extras);
92 bool ret=true;
93 for (vector<CStdString>::iterator it = xml.begin();
94 it != xml.end(); ++it)
96 // ok, now parse the xml file
97 TiXmlDocument doc;
98 doc.Parse(it->c_str(),0,TIXML_ENCODING_UTF8);
99 if (!doc.RootElement())
101 CLog::Log(LOGERROR, "%s: Unable to parse xml",__FUNCTION__);
102 return false;
105 ret = Parse(doc.RootElement(),it!=xml.begin());
108 return ret;
111 void CMusicArtistInfo::SetLoaded(bool bOnOff)
113 m_bLoaded = bOnOff;
116 bool CMusicArtistInfo::Loaded() const
118 return m_bLoaded;