[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / music / Artist.h
blob2ec77a82549d730e713fc760fc3bf893b047ce6d
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "XBDateTime.h"
12 #include "utils/ScraperUrl.h"
13 #include "utils/StringUtils.h"
15 #include <map>
16 #include <string>
17 #include <utility>
18 #include <vector>
20 class TiXmlNode;
21 class CAlbum;
22 class CMusicDatabase;
24 class CDiscoAlbum
26 public:
27 std::string strAlbum;
28 std::string strYear;
29 std::string strReleaseGroupMBID;
32 class CArtist
34 public:
35 int idArtist = -1;
36 bool operator<(const CArtist& a) const
38 if (strMusicBrainzArtistID.empty() && a.strMusicBrainzArtistID.empty())
40 if (strArtist < a.strArtist) return true;
41 if (strArtist > a.strArtist) return false;
42 return false;
45 if (strMusicBrainzArtistID < a.strMusicBrainzArtistID) return true;
46 if (strMusicBrainzArtistID > a.strMusicBrainzArtistID) return false;
47 return false;
50 void MergeScrapedArtist(const CArtist& source, bool override = true);
52 void Reset()
54 strArtist.clear();
55 strSortName.clear();
56 strType.clear();
57 strGender.clear();
58 strDisambiguation.clear();
59 genre.clear();
60 strBiography.clear();
61 styles.clear();
62 moods.clear();
63 instruments.clear();
64 strBorn.clear();
65 strFormed.clear();
66 strDied.clear();
67 strDisbanded.clear();
68 yearsActive.clear();
69 thumbURL.Clear();
70 art.clear();
71 discography.clear();
72 idArtist = -1;
73 strPath.clear();
74 dateAdded.Reset();
75 dateUpdated.Reset();
76 dateNew.Reset();
77 bScrapedMBID = false;
78 strLastScraped.clear();
81 /*! \brief Load artist information from an XML file.
82 See CVideoInfoTag::Load for a description of the types of elements we load.
83 \param element the root XML element to parse.
84 \param append whether information should be added to the existing tag, or whether it should be reset first.
85 \param prioritise if appending, whether additive tags should be prioritised (i.e. replace or prepend) over existing values. Defaults to false.
86 \sa CVideoInfoTag::Load
88 bool Load(const TiXmlElement *element, bool append = false, bool prioritise = false);
89 bool Save(TiXmlNode *node, const std::string &tag, const std::string& strPath);
91 void SetDateAdded(const std::string& strDateAdded);
92 void SetDateUpdated(const std::string& strDateUpdated);
93 void SetDateNew(const std::string& strDateNew);
95 std::string strArtist;
96 std::string strSortName;
97 std::string strMusicBrainzArtistID;
98 std::string strType;
99 std::string strGender;
100 std::string strDisambiguation;
101 std::vector<std::string> genre;
102 std::string strBiography;
103 std::vector<std::string> styles;
104 std::vector<std::string> moods;
105 std::vector<std::string> instruments;
106 std::string strBorn;
107 std::string strFormed;
108 std::string strDied;
109 std::string strDisbanded;
110 std::vector<std::string> yearsActive;
111 std::string strPath;
112 CScraperUrl thumbURL; // Data for available remote art
113 std::map<std::string, std::string> art; // Current artwork - thumb, fanart etc.
114 std::vector<CDiscoAlbum> discography;
115 CDateTime dateAdded; // From related file creation or modification times, or when (re-)scanned
116 CDateTime dateUpdated; // Time db record Last modified
117 CDateTime dateNew; // Time db record created
118 bool bScrapedMBID = false;
119 std::string strLastScraped;
122 class CArtistCredit
124 friend class CAlbum;
125 friend class CMusicDatabase;
127 public:
128 CArtistCredit() = default;
129 explicit CArtistCredit(std::string strArtist) : m_strArtist(std::move(strArtist)) {}
130 CArtistCredit(std::string strArtist, std::string strMusicBrainzArtistID)
131 : m_strArtist(std::move(strArtist)), m_strMusicBrainzArtistID(std::move(strMusicBrainzArtistID))
134 CArtistCredit(std::string strArtist, std::string strSortName, std::string strMusicBrainzArtistID)
135 : m_strArtist(std::move(strArtist)),
136 m_strSortName(std::move(strSortName)),
137 m_strMusicBrainzArtistID(std::move(strMusicBrainzArtistID))
141 bool operator<(const CArtistCredit& a) const
143 if (m_strMusicBrainzArtistID.empty() && a.m_strMusicBrainzArtistID.empty())
145 if (m_strArtist < a.m_strArtist) return true;
146 if (m_strArtist > a.m_strArtist) return false;
147 return false;
150 if (m_strMusicBrainzArtistID < a.m_strMusicBrainzArtistID) return true;
151 if (m_strMusicBrainzArtistID > a.m_strMusicBrainzArtistID) return false;
152 return false;
155 std::string GetArtist() const { return m_strArtist; }
156 std::string GetSortName() const { return m_strSortName; }
157 std::string GetMusicBrainzArtistID() const { return m_strMusicBrainzArtistID; }
158 int GetArtistId() const { return idArtist; }
159 bool HasScrapedMBID() const { return m_bScrapedMBID; }
160 void SetArtist(const std::string &strArtist) { m_strArtist = strArtist; }
161 void SetSortName(const std::string &strSortName) { m_strSortName = strSortName; }
162 void SetMusicBrainzArtistID(const std::string &strMusicBrainzArtistID) { m_strMusicBrainzArtistID = strMusicBrainzArtistID; }
163 void SetArtistId(int idArtist) { this->idArtist = idArtist; }
164 void SetScrapedMBID(bool scrapedMBID) { this->m_bScrapedMBID = scrapedMBID; }
166 private:
167 int idArtist = -1;
168 std::string m_strArtist;
169 std::string m_strSortName;
170 std::string m_strMusicBrainzArtistID;
171 bool m_bScrapedMBID = false; // Flag that mbid is from album merge of scarper results not derived from tags
174 typedef std::vector<CArtist> VECARTISTS;
175 typedef std::vector<CArtistCredit> VECARTISTCREDITS;
177 const std::string BLANKARTIST_FAKEMUSICBRAINZID = "Artist Tag Missing";
178 const std::string BLANKARTIST_NAME = "[Missing Tag]";
179 const int BLANKARTIST_ID = 1;
180 const std::string VARIOUSARTISTS_MBID = "89ad4ac3-39f7-470e-963a-56509c546377";
182 #define ROLE_ARTIST 1 //Default role
184 class CMusicRole
186 public:
187 CMusicRole() = default;
188 CMusicRole(std::string strRole, std::string strArtist)
189 : idRole(-1), m_strRole(std::move(strRole)), m_strArtist(std::move(strArtist)), idArtist(-1)
192 CMusicRole(int role, std::string strRole, std::string strArtist, int ArtistId)
193 : idRole(role),
194 m_strRole(std::move(strRole)),
195 m_strArtist(std::move(strArtist)),
196 idArtist(ArtistId)
199 std::string GetArtist() const { return m_strArtist; }
200 std::string GetRoleDesc() const { return m_strRole; }
201 int GetRoleId() const { return idRole; }
202 int GetArtistId() const { return idArtist; }
203 void SetArtistId(int iArtistId) { idArtist = iArtistId; }
205 bool operator==(const CMusicRole& a) const
207 if (StringUtils::EqualsNoCase(m_strRole, a.m_strRole))
208 return StringUtils::EqualsNoCase(m_strArtist, a.m_strArtist);
209 else
210 return false;
212 private:
213 int idRole;
214 std::string m_strRole;
215 std::string m_strArtist;
216 int idArtist;
219 typedef std::vector<CMusicRole> VECMUSICROLES;