2 * Copyright (C) 2005-2013 Team XBMC
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)
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, see
17 * <http://www.gnu.org/licenses/>.
22 #include "music/tags/MusicInfoTag.h"
23 #include "utils/Variant.h"
26 using namespace MUSIC_INFO;
28 CSong::CSong(CMusicInfoTag& tag)
31 tag.GetReleaseDate(stTime);
32 strTitle = tag.GetTitle();
33 genre = tag.GetGenre();
34 strFileName = tag.GetURL();
35 artist = tag.GetArtist();
36 strAlbum = tag.GetAlbum();
37 albumArtist = tag.GetAlbumArtist();
38 strMusicBrainzTrackID = tag.GetMusicBrainzTrackID();
39 strMusicBrainzArtistID = tag.GetMusicBrainzArtistID();
40 strMusicBrainzAlbumID = tag.GetMusicBrainzAlbumID();
41 strMusicBrainzAlbumArtistID = tag.GetMusicBrainzAlbumArtistID();
42 strMusicBrainzTRMID = tag.GetMusicBrainzTRMID();
43 strComment = tag.GetComment();
44 rating = tag.GetRating();
46 iTrack = tag.GetTrackAndDiskNumber();
47 iDuration = tag.GetDuration();
48 bCompilation = tag.GetCompilation();
49 embeddedArt = tag.GetCoverArtInfo();
56 iKaraokeDelay = 0; //! Karaoke song lyrics-music delay in 1/10 seconds.
65 void CSong::Serialize(CVariant& value) const
67 value["filename"] = strFileName;
68 value["title"] = strTitle;
69 value["artist"] = artist;
70 value["album"] = strAlbum;
71 value["albumartist"] = albumArtist;
72 value["genre"] = genre;
73 value["duration"] = iDuration;
74 value["track"] = iTrack;
75 value["year"] = iYear;
76 value["musicbrainztrackid"] = strMusicBrainzTrackID;
77 value["musicbrainzartistid"] = strMusicBrainzArtistID;
78 value["musicbrainzalbumid"] = strMusicBrainzAlbumID;
79 value["musicbrainzalbumartistid"] = strMusicBrainzAlbumArtistID;
80 value["musicbrainztrmid"] = strMusicBrainzTRMID;
81 value["comment"] = strComment;
82 value["rating"] = rating;
83 value["timesplayed"] = iTimesPlayed;
84 value["lastplayed"] = lastPlayed.IsValid() ? lastPlayed.GetAsDBDateTime() : "";
85 value["karaokenumber"] = (int64_t) iKaraokeNumber;
86 value["albumid"] = iAlbumId;
98 strMusicBrainzTrackID.Empty();
99 strMusicBrainzArtistID.Empty();
100 strMusicBrainzAlbumID.Empty();
101 strMusicBrainzAlbumArtistID.Empty();
102 strMusicBrainzTRMID.Empty();
114 strKaraokeLyrEncoding.Empty();
117 bCompilation = false;
121 bool CSong::HasArt() const
123 if (!strThumb.empty()) return true;
124 if (!embeddedArt.empty()) return true;
128 bool CSong::ArtMatches(const CSong &right) const
130 return (right.strThumb == strThumb &&
131 embeddedArt.matches(right.embeddedArt));
138 std::map<CStdString, CSong>::const_iterator CSongMap::Begin()
140 return m_map.begin();
143 std::map<CStdString, CSong>::const_iterator CSongMap::End()
148 void CSongMap::Add(const CStdString &file, const CSong &song)
150 CStdString lower = file;
152 m_map.insert(pair<CStdString, CSong>(lower, song));
155 CSong* CSongMap::Find(const CStdString &file)
157 CStdString lower = file;
159 map<CStdString, CSong>::iterator it = m_map.find(lower);
160 if (it == m_map.end())
162 return &(*it).second;
165 void CSongMap::Clear()
167 m_map.erase(m_map.begin(), m_map.end());
172 return (int)m_map.size();