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