bool CArtist::Save(TiXmlNode *node, const CStdString &tag, const CStdString& strPath) { if (!node) return false; // we start with a <tag> tag TiXmlElement artistElement(tag.c_str()); TiXmlNode *artist = node->InsertEndChild(artistElement); if (!artist) return false; XMLUtils::SetString(artist, "name", strArtist); XMLUtils::SetString(artist, "musicBrainzArtistID", strMusicBrainzArtistID); XMLUtils::SetStringArray(artist, "genre", genre); XMLUtils::SetStringArray(artist, "style", styles); XMLUtils::SetStringArray(artist, "mood", moods); XMLUtils::SetStringArray(artist, "yearsactive", yearsActive); XMLUtils::SetStringArray(artist, "instruments", instruments); XMLUtils::SetString(artist, "born", strBorn); XMLUtils::SetString(artist, "formed", strFormed); XMLUtils::SetString(artist, "biography", strBiography); XMLUtils::SetString(artist, "died", strDied); XMLUtils::SetString(artist, "disbanded", strDisbanded); if (!thumbURL.m_xml.empty()) { CXBMCTinyXML doc; doc.Parse(thumbURL.m_xml); const TiXmlNode* thumb = doc.FirstChild("thumb"); while (thumb) { artist->InsertEndChild(*thumb); thumb = thumb->NextSibling("thumb"); } } XMLUtils::SetString(artist, "path", strPath); if (fanart.m_xml.size()) { CXBMCTinyXML doc; doc.Parse(fanart.m_xml); artist->InsertEndChild(*doc.RootElement()); } // albums for (vector< pair<CStdString,CStdString> >::const_iterator it = discography.begin(); it != discography.end(); ++it) { // add a <album> tag TiXmlElement cast("album"); TiXmlNode *node = artist->InsertEndChild(cast); TiXmlElement title("title"); TiXmlNode *titleNode = node->InsertEndChild(title); TiXmlText name(it->first); titleNode->InsertEndChild(name); TiXmlElement year("year"); TiXmlNode *yearNode = node->InsertEndChild(year); TiXmlText name2(it->second); yearNode->InsertEndChild(name2); } return true; }
bool CVideoInfoTag::Save(TiXmlNode *node, const std::string &tag, bool savePathInfo, const TiXmlElement *additionalNode) { if (!node) return false; // we start with a <tag> tag TiXmlElement movieElement(tag.c_str()); TiXmlNode *movie = node->InsertEndChild(movieElement); if (!movie) return false; XMLUtils::SetString(movie, "title", m_strTitle); if (!m_strOriginalTitle.empty()) XMLUtils::SetString(movie, "originaltitle", m_strOriginalTitle); if (!m_strShowTitle.empty()) XMLUtils::SetString(movie, "showtitle", m_strShowTitle); if (!m_strSortTitle.empty()) XMLUtils::SetString(movie, "sorttitle", m_strSortTitle); if (!m_ratings.empty()) { TiXmlElement ratings("ratings"); for (const auto& it : m_ratings) { TiXmlElement rating("rating"); rating.SetAttribute("name", it.first.c_str()); XMLUtils::SetFloat(&rating, "value", it.second.rating); XMLUtils::SetInt(&rating, "votes", it.second.votes); rating.SetAttribute("max", 10); if (it.first == m_strDefaultRating) rating.SetAttribute("default", "true"); ratings.InsertEndChild(rating); } movie->InsertEndChild(ratings); } XMLUtils::SetInt(movie, "userrating", m_iUserRating); if (m_EpBookmark.timeInSeconds > 0) { TiXmlElement epbookmark("episodebookmark"); XMLUtils::SetFloat(&epbookmark, "position", (float)m_EpBookmark.timeInSeconds); if (!m_EpBookmark.playerState.empty()) { TiXmlElement playerstate("playerstate"); CXBMCTinyXML doc; doc.Parse(m_EpBookmark.playerState); playerstate.InsertEndChild(*doc.RootElement()); epbookmark.InsertEndChild(playerstate); } movie->InsertEndChild(epbookmark); } XMLUtils::SetInt(movie, "top250", m_iTop250); if (tag == "episodedetails" || tag == "tvshow") { XMLUtils::SetInt(movie, "season", m_iSeason); XMLUtils::SetInt(movie, "episode", m_iEpisode); XMLUtils::SetInt(movie, "displayseason",m_iSpecialSortSeason); XMLUtils::SetInt(movie, "displayepisode",m_iSpecialSortEpisode); } if (tag == "musicvideo") { XMLUtils::SetInt(movie, "track", m_iTrack); XMLUtils::SetString(movie, "album", m_strAlbum); } XMLUtils::SetString(movie, "outline", m_strPlotOutline); XMLUtils::SetString(movie, "plot", m_strPlot); XMLUtils::SetString(movie, "tagline", m_strTagLine); XMLUtils::SetInt(movie, "runtime", GetDuration() / 60); if (!m_strPictureURL.m_xml.empty()) { CXBMCTinyXML doc; doc.Parse(m_strPictureURL.m_xml); const TiXmlNode* thumb = doc.FirstChild("thumb"); while (thumb) { movie->InsertEndChild(*thumb); thumb = thumb->NextSibling("thumb"); } } if (m_fanart.m_xml.size()) { CXBMCTinyXML doc; doc.Parse(m_fanart.m_xml); movie->InsertEndChild(*doc.RootElement()); } XMLUtils::SetString(movie, "mpaa", m_strMPAARating); XMLUtils::SetInt(movie, "playcount", m_playCount); XMLUtils::SetDate(movie, "lastplayed", m_lastPlayed); if (savePathInfo) { XMLUtils::SetString(movie, "file", m_strFile); XMLUtils::SetString(movie, "path", m_strPath); XMLUtils::SetString(movie, "filenameandpath", m_strFileNameAndPath); XMLUtils::SetString(movie, "basepath", m_basePath); } if (!m_strEpisodeGuide.empty()) { CXBMCTinyXML doc; doc.Parse(m_strEpisodeGuide); if (doc.RootElement()) movie->InsertEndChild(*doc.RootElement()); else XMLUtils::SetString(movie, "episodeguide", m_strEpisodeGuide); } XMLUtils::SetString(movie, "id", GetUniqueID()); for (const auto& uniqueid : m_uniqueIDs) { TiXmlElement uniqueID("uniqueid"); uniqueID.SetAttribute("type", uniqueid.first); if (uniqueid.first == m_strDefaultUniqueID) uniqueID.SetAttribute("default", "true"); TiXmlText value(uniqueid.second); uniqueID.InsertEndChild(value); movie->InsertEndChild(uniqueID); } XMLUtils::SetStringArray(movie, "genre", m_genre); XMLUtils::SetStringArray(movie, "country", m_country); if (!m_strSet.empty()) { TiXmlElement set("set"); XMLUtils::SetString(&set, "name", m_strSet); if (!m_strSetOverview.empty()) XMLUtils::SetString(&set, "overview", m_strSetOverview); movie->InsertEndChild(set); } XMLUtils::SetStringArray(movie, "tag", m_tags); XMLUtils::SetStringArray(movie, "credits", m_writingCredits); XMLUtils::SetStringArray(movie, "director", m_director); if (HasPremiered()) XMLUtils::SetDate(movie, "premiered", m_premiered); if (HasYear()) XMLUtils::SetInt(movie, "year", GetYear()); XMLUtils::SetString(movie, "status", m_strStatus); XMLUtils::SetString(movie, "code", m_strProductionCode); XMLUtils::SetDate(movie, "aired", m_firstAired); XMLUtils::SetStringArray(movie, "studio", m_studio); XMLUtils::SetString(movie, "trailer", m_strTrailer); if (m_streamDetails.HasItems()) { // it goes fileinfo/streamdetails/[video|audio|subtitle] TiXmlElement fileinfo("fileinfo"); TiXmlElement streamdetails("streamdetails"); for (int iStream=1; iStream<=m_streamDetails.GetVideoStreamCount(); iStream++) { TiXmlElement stream("video"); XMLUtils::SetString(&stream, "codec", m_streamDetails.GetVideoCodec(iStream)); XMLUtils::SetFloat(&stream, "aspect", m_streamDetails.GetVideoAspect(iStream)); XMLUtils::SetInt(&stream, "width", m_streamDetails.GetVideoWidth(iStream)); XMLUtils::SetInt(&stream, "height", m_streamDetails.GetVideoHeight(iStream)); XMLUtils::SetInt(&stream, "durationinseconds", m_streamDetails.GetVideoDuration(iStream)); XMLUtils::SetString(&stream, "stereomode", m_streamDetails.GetStereoMode(iStream)); streamdetails.InsertEndChild(stream); } for (int iStream=1; iStream<=m_streamDetails.GetAudioStreamCount(); iStream++) { TiXmlElement stream("audio"); XMLUtils::SetString(&stream, "codec", m_streamDetails.GetAudioCodec(iStream)); XMLUtils::SetString(&stream, "language", m_streamDetails.GetAudioLanguage(iStream)); XMLUtils::SetInt(&stream, "channels", m_streamDetails.GetAudioChannels(iStream)); streamdetails.InsertEndChild(stream); } for (int iStream=1; iStream<=m_streamDetails.GetSubtitleStreamCount(); iStream++) { TiXmlElement stream("subtitle"); XMLUtils::SetString(&stream, "language", m_streamDetails.GetSubtitleLanguage(iStream)); streamdetails.InsertEndChild(stream); } fileinfo.InsertEndChild(streamdetails); movie->InsertEndChild(fileinfo); } /* if has stream details */ // cast for (iCast it = m_cast.begin(); it != m_cast.end(); ++it) { // add a <actor> tag TiXmlElement cast("actor"); TiXmlNode *node = movie->InsertEndChild(cast); XMLUtils::SetString(node, "name", it->strName); XMLUtils::SetString(node, "role", it->strRole); XMLUtils::SetInt(node, "order", it->order); XMLUtils::SetString(node, "thumb", it->thumbUrl.GetFirstThumb().m_url); } XMLUtils::SetStringArray(movie, "artist", m_artist); XMLUtils::SetStringArray(movie, "showlink", m_showLink); for (const auto& namedSeason : m_namedSeasons) { TiXmlElement season("namedseason"); season.SetAttribute("number", namedSeason.first); season.SetValue(namedSeason.second); movie->InsertEndChild(season); } TiXmlElement resume("resume"); XMLUtils::SetFloat(&resume, "position", (float)m_resumePoint.timeInSeconds); XMLUtils::SetFloat(&resume, "total", (float)m_resumePoint.totalTimeInSeconds); movie->InsertEndChild(resume); XMLUtils::SetDateTime(movie, "dateadded", m_dateAdded); if (additionalNode) movie->InsertEndChild(*additionalNode); return true; }
bool CVideoInfoTag::Save(TiXmlNode *node, const CStdString &tag, bool savePathInfo, const TiXmlElement *additionalNode) { if (!node) return false; // we start with a <tag> tag TiXmlElement movieElement(tag.c_str()); TiXmlNode *movie = node->InsertEndChild(movieElement); if (!movie) return false; XMLUtils::SetString(movie, "title", m_strTitle); if (!m_strOriginalTitle.IsEmpty()) XMLUtils::SetString(movie, "originaltitle", m_strOriginalTitle); if (!m_strShowTitle.IsEmpty()) XMLUtils::SetString(movie, "showtitle", m_strShowTitle); if (!m_strSortTitle.IsEmpty()) XMLUtils::SetString(movie, "sorttitle", m_strSortTitle); XMLUtils::SetFloat(movie, "rating", m_fRating); XMLUtils::SetFloat(movie, "epbookmark", m_fEpBookmark); XMLUtils::SetInt(movie, "year", m_iYear); XMLUtils::SetInt(movie, "top250", m_iTop250); if (tag == "episodedetails" || tag == "tvshow") { XMLUtils::SetInt(movie, "season", m_iSeason); XMLUtils::SetInt(movie, "episode", m_iEpisode); XMLUtils::SetString(movie, "uniqueid", m_strUniqueId); XMLUtils::SetInt(movie, "displayseason",m_iSpecialSortSeason); XMLUtils::SetInt(movie, "displayepisode",m_iSpecialSortEpisode); } if (tag == "musicvideo") { XMLUtils::SetInt(movie, "track", m_iTrack); XMLUtils::SetString(movie, "album", m_strAlbum); } XMLUtils::SetString(movie, "votes", m_strVotes); XMLUtils::SetString(movie, "outline", m_strPlotOutline); XMLUtils::SetString(movie, "plot", m_strPlot); XMLUtils::SetString(movie, "tagline", m_strTagLine); XMLUtils::SetInt(movie, "runtime", GetDuration() / 60); if (!m_strPictureURL.m_xml.empty()) { CXBMCTinyXML doc; doc.Parse(m_strPictureURL.m_xml); const TiXmlNode* thumb = doc.FirstChild("thumb"); while (thumb) { movie->InsertEndChild(*thumb); thumb = thumb->NextSibling("thumb"); } } if (m_fanart.m_xml.size()) { CXBMCTinyXML doc; doc.Parse(m_fanart.m_xml); movie->InsertEndChild(*doc.RootElement()); } XMLUtils::SetString(movie, "mpaa", m_strMPAARating); XMLUtils::SetInt(movie, "playcount", m_playCount); XMLUtils::SetDate(movie, "lastplayed", m_lastPlayed); if (savePathInfo) { XMLUtils::SetString(movie, "file", m_strFile); XMLUtils::SetString(movie, "path", m_strPath); XMLUtils::SetString(movie, "filenameandpath", m_strFileNameAndPath); XMLUtils::SetString(movie, "basepath", m_basePath); } if (!m_strEpisodeGuide.IsEmpty()) { CXBMCTinyXML doc; doc.Parse(m_strEpisodeGuide); if (doc.RootElement()) movie->InsertEndChild(*doc.RootElement()); else XMLUtils::SetString(movie, "episodeguide", m_strEpisodeGuide); } XMLUtils::SetString(movie, "id", m_strIMDBNumber); XMLUtils::SetStringArray(movie, "genre", m_genre); XMLUtils::SetStringArray(movie, "country", m_country); XMLUtils::SetString(movie, "set", m_strSet); XMLUtils::SetStringArray(movie, "tag", m_tags); XMLUtils::SetStringArray(movie, "credits", m_writingCredits); XMLUtils::SetStringArray(movie, "director", m_director); XMLUtils::SetDate(movie, "premiered", m_premiered); XMLUtils::SetString(movie, "status", m_strStatus); XMLUtils::SetString(movie, "code", m_strProductionCode); XMLUtils::SetDate(movie, "aired", m_firstAired); XMLUtils::SetStringArray(movie, "studio", m_studio); XMLUtils::SetString(movie, "trailer", m_strTrailer); if (m_streamDetails.HasItems()) { // it goes fileinfo/streamdetails/[video|audio|subtitle] TiXmlElement fileinfo("fileinfo"); TiXmlElement streamdetails("streamdetails"); for (int iStream=1; iStream<=m_streamDetails.GetVideoStreamCount(); iStream++) { TiXmlElement stream("video"); XMLUtils::SetString(&stream, "codec", m_streamDetails.GetVideoCodec(iStream)); XMLUtils::SetFloat(&stream, "aspect", m_streamDetails.GetVideoAspect(iStream)); XMLUtils::SetInt(&stream, "width", m_streamDetails.GetVideoWidth(iStream)); XMLUtils::SetInt(&stream, "height", m_streamDetails.GetVideoHeight(iStream)); XMLUtils::SetInt(&stream, "durationinseconds", m_streamDetails.GetVideoDuration(iStream)); streamdetails.InsertEndChild(stream); } for (int iStream=1; iStream<=m_streamDetails.GetAudioStreamCount(); iStream++) { TiXmlElement stream("audio"); XMLUtils::SetString(&stream, "codec", m_streamDetails.GetAudioCodec(iStream)); XMLUtils::SetString(&stream, "language", m_streamDetails.GetAudioLanguage(iStream)); XMLUtils::SetInt(&stream, "channels", m_streamDetails.GetAudioChannels(iStream)); streamdetails.InsertEndChild(stream); } for (int iStream=1; iStream<=m_streamDetails.GetSubtitleStreamCount(); iStream++) { TiXmlElement stream("subtitle"); XMLUtils::SetString(&stream, "language", m_streamDetails.GetSubtitleLanguage(iStream)); streamdetails.InsertEndChild(stream); } fileinfo.InsertEndChild(streamdetails); movie->InsertEndChild(fileinfo); } /* if has stream details */ // cast for (iCast it = m_cast.begin(); it != m_cast.end(); ++it) { // add a <actor> tag TiXmlElement cast("actor"); TiXmlNode *node = movie->InsertEndChild(cast); TiXmlElement actor("name"); TiXmlNode *actorNode = node->InsertEndChild(actor); TiXmlText name(it->strName); actorNode->InsertEndChild(name); TiXmlElement role("role"); TiXmlNode *roleNode = node->InsertEndChild(role); TiXmlText character(it->strRole); roleNode->InsertEndChild(character); TiXmlElement thumb("thumb"); TiXmlNode *thumbNode = node->InsertEndChild(thumb); TiXmlText th(it->thumbUrl.GetFirstThumb().m_url); thumbNode->InsertEndChild(th); } XMLUtils::SetStringArray(movie, "artist", m_artist); XMLUtils::SetStringArray(movie, "showlink", m_showLink); TiXmlElement resume("resume"); XMLUtils::SetFloat(&resume, "position", (float)m_resumePoint.timeInSeconds); XMLUtils::SetFloat(&resume, "total", (float)m_resumePoint.totalTimeInSeconds); movie->InsertEndChild(resume); XMLUtils::SetString(movie, "dateadded", m_dateAdded.GetAsDBDateTime()); if (additionalNode) movie->InsertEndChild(*additionalNode); return true; }
bool CAlbum::Save(TiXmlNode *node, const CStdString &tag, const CStdString& strPath) { if (!node) return false; // we start with a <tag> tag TiXmlElement albumElement(tag.c_str()); TiXmlNode *album = node->InsertEndChild(albumElement); if (!album) return false; XMLUtils::SetString(album, "title", strAlbum); XMLUtils::SetString(album, "musicBrainzAlbumID", strMusicBrainzAlbumID); XMLUtils::SetStringArray(album, "artist", artist); XMLUtils::SetStringArray(album, "genre", genre); XMLUtils::SetStringArray(album, "style", styles); XMLUtils::SetStringArray(album, "mood", moods); XMLUtils::SetStringArray(album, "theme", themes); XMLUtils::SetBoolean(album, "compilation", bCompilation); XMLUtils::SetString(album, "review", strReview); XMLUtils::SetString(album, "type", strType); XMLUtils::SetString(album, "releasedate", m_strDateOfRelease); XMLUtils::SetString(album, "label", strLabel); XMLUtils::SetString(album, "type", strType); if (!thumbURL.m_xml.empty()) { CXBMCTinyXML doc; doc.Parse(thumbURL.m_xml); const TiXmlNode* thumb = doc.FirstChild("thumb"); while (thumb) { album->InsertEndChild(*thumb); thumb = thumb->NextSibling("thumb"); } } XMLUtils::SetString(album, "path", strPath); XMLUtils::SetInt(album, "rating", iRating); XMLUtils::SetInt(album, "year", iYear); for( VECARTISTCREDITS::const_iterator artistCredit = artistCredits.begin();artistCredit != artistCredits.end();++artistCredit) { // add an <albumArtistCredits> tag TiXmlElement albumArtistCreditsElement("albumArtistCredits"); TiXmlNode *albumArtistCreditsNode = album->InsertEndChild(albumArtistCreditsElement); XMLUtils::SetString(albumArtistCreditsNode, "artist", artistCredit->m_strArtist); XMLUtils::SetString(albumArtistCreditsNode, "musicBrainzArtistID", artistCredit->m_strMusicBrainzArtistID); XMLUtils::SetString(albumArtistCreditsNode, "joinphrase", artistCredit->m_strJoinPhrase); XMLUtils::SetString(albumArtistCreditsNode, "featuring", artistCredit->GetArtist()); } for( VECSONGS::const_iterator song = songs.begin(); song != songs.end(); ++song) { // add a <song> tag TiXmlElement cast("track"); TiXmlNode *node = album->InsertEndChild(cast); for( VECARTISTCREDITS::const_iterator artistCredit = song->artistCredits.begin(); artistCredit != artistCredits.end(); ++artistCredit) { // add an <albumArtistCredits> tag TiXmlElement songArtistCreditsElement("songArtistCredits"); TiXmlNode *songArtistCreditsNode = node->InsertEndChild(songArtistCreditsElement); XMLUtils::SetString(songArtistCreditsNode, "artist", artistCredit->m_strArtist); XMLUtils::SetString(songArtistCreditsNode, "musicBrainzArtistID", artistCredit->m_strMusicBrainzArtistID); XMLUtils::SetString(songArtistCreditsNode, "joinphrase", artistCredit->m_strJoinPhrase); XMLUtils::SetString(songArtistCreditsNode, "featuring", artistCredit->GetArtist()); } XMLUtils::SetString(node, "musicBrainzTrackID", song->strMusicBrainzTrackID); XMLUtils::SetString(node, "title", song->strTitle); XMLUtils::SetInt(node, "position", song->iTrack); XMLUtils::SetString(node, "duration", StringUtils::SecondsToTimeString(song->iDuration)); } return true; }
bool CAlbum::Save(TiXmlNode *node, const CStdString &tag, const CStdString& strPath) { if (!node) return false; // we start with a <tag> tag TiXmlElement albumElement(tag.c_str()); TiXmlNode *album = node->InsertEndChild(albumElement); if (!album) return false; XMLUtils::SetString(album, "title", strAlbum); XMLUtils::SetAdditiveString(album, "artist", g_advancedSettings.m_musicItemSeparator, strArtist); XMLUtils::SetAdditiveString(album, "genre", g_advancedSettings.m_musicItemSeparator, strGenre); XMLUtils::SetAdditiveString(album, "style", g_advancedSettings.m_musicItemSeparator, strStyles); XMLUtils::SetAdditiveString(album, "mood", g_advancedSettings.m_musicItemSeparator, strMoods); XMLUtils::SetAdditiveString(album, "theme", g_advancedSettings.m_musicItemSeparator, strThemes); XMLUtils::SetString(album, "review", strReview); XMLUtils::SetString(album, "type", strType); XMLUtils::SetString(album, "releasedate", m_strDateOfRelease); XMLUtils::SetString(album, "label", strLabel); XMLUtils::SetString(album, "type", strType); if (!thumbURL.m_xml.empty()) { CXBMCTinyXML doc; doc.Parse(thumbURL.m_xml); const TiXmlNode* thumb = doc.FirstChild("thumb"); while (thumb) { album->InsertEndChild(*thumb); thumb = thumb->NextSibling("thumb"); } } XMLUtils::SetString(album, "path", strPath); XMLUtils::SetInt(album, "rating", iRating); XMLUtils::SetInt(album, "year", iYear); for( VECSONGS::const_iterator it = songs.begin();it != songs.end();++it) { // add a <song> tag TiXmlElement cast("track"); TiXmlNode *node = album->InsertEndChild(cast); TiXmlElement title("title"); TiXmlNode *titleNode = node->InsertEndChild(title); TiXmlText name(it->strTitle); titleNode->InsertEndChild(name); TiXmlElement year("position"); TiXmlNode *yearNode = node->InsertEndChild(year); CStdString strTrack; strTrack.Format("%i",it->iTrack); TiXmlText name2(strTrack); yearNode->InsertEndChild(name2); TiXmlElement duration("duration"); TiXmlNode *durNode = node->InsertEndChild(duration); TiXmlText name3(StringUtils::SecondsToTimeString(it->iDuration)); durNode->InsertEndChild(name3); } return true; }