kodi
Song.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
16 #include "Artist.h"
17 #include "XBDateTime.h"
18 #include "music/tags/ReplayGain.h"
19 #include "utils/EmbeddedArt.h"
20 #include "utils/ISerializable.h"
21 
22 #include <map>
23 #include <string>
24 #include <vector>
25 
26 class CVariant;
27 
34 class CGenre
35 {
36 public:
37  int idGenre;
38  std::string strGenre;
39 };
40 
41 class CFileItem;
42 
48 class CSong final : public ISerializable
49 {
50 public:
51  CSong() ;
52  explicit CSong(CFileItem& item);
53  void Clear() ;
54  void MergeScrapedSong(const CSong& source, bool override);
55  void Serialize(CVariant& value) const override;
56 
57  bool operator<(const CSong &song) const
58  {
59  if (strFileName < song.strFileName) return true;
60  if (strFileName > song.strFileName) return false;
61  if (iTrack < song.iTrack) return true;
62  return false;
63  }
64 
68  const std::vector<std::string> GetArtist() const;
69 
73  const std::string GetArtistSort() const;
74 
78  const std::vector<std::string> GetMusicBrainzArtistID() const;
79 
84  const std::string GetArtistString() const;
85 
89  const std::vector<int> GetArtistIDArray() const;
90 
96  const std::vector<std::string> GetAlbumArtist() const { return m_albumArtist; }
97 
101  const std::string GetAlbumArtistSort() const { return m_strAlbumArtistSort; }
102 
106  const std::string GetDiscSubtitle() const;
107 
111  const std::string GetComposerSort() const { return m_strComposerSort; }
112 
118  const VECMUSICROLES& GetContributors() const { return m_musicRoles; }
119  //void AddArtistRole(const int &role, const std::string &artist);
120  void AppendArtistRole(const CMusicRole& musicRole);
121 
127  void SetAlbumArtist(const std::vector<std::string>& albumartists) { m_albumArtist = albumartists; }
128 
133  bool HasArtistCredits() const { return !artistCredits.empty(); }
134 
138  bool HasContributors() const { return !m_musicRoles.empty(); }
139 
143  bool HasArt() const;
144 
148  bool ArtMatches(const CSong &right) const;
149 
157  void SetArtistCredits(const std::vector<std::string>& names, const std::vector<std::string>& hints,
158  const std::vector<std::string>& mbids);
159 
160  int idSong;
161  int idAlbum;
162  std::string strFileName;
163  std::string strTitle;
164  std::string strArtistSort;
165  std::string strArtistDesc;
166  VECARTISTCREDITS artistCredits;
167  std::string strAlbum;
168  std::vector<std::string> genre;
169  std::string strThumb;
170  EmbeddedArtInfo embeddedArt;
171  std::string strMusicBrainzTrackID;
172  std::string strComment;
173  std::string strMood;
174  std::string strCueSheet;
175  float rating;
176  int userrating;
177  int votes;
178  int iTrack;
179  int iDuration;
180  std::string strOrigReleaseDate;
181  std::string strReleaseDate;
182  std::string strDiscSubtitle;
183  int iTimesPlayed;
184  CDateTime lastPlayed;
185  CDateTime dateAdded; // File creation or modification time, or when tags (re-)scanned
186  CDateTime dateUpdated; // Time db record Last modified
187  CDateTime dateNew; // Time db record created
188  int iStartOffset;
189  int iEndOffset;
190  bool bCompilation;
191  int iBPM;
192  int iSampleRate;
193  int iBitRate;
194  int iChannels;
195  std::string strRecordLabel; // Record label from tag for album processing by CMusicInfoScanner::FileItemsToAlbums
196  std::string strAlbumType; // (Musicbrainz release type) album type from tag for album processing by CMusicInfoScanner::FileItemsToAlbums
197  std::string songVideoURL; // url to song video
198 
199  ReplayGain replayGain;
200 private:
201  std::vector<std::string> m_albumArtist; // Album artist from tag for album processing, no desc or MBID
202  std::string m_strAlbumArtistSort; // Albumartist sort string from tag for album processing by CMusicInfoScanner::FileItemsToAlbums
203  std::string m_strComposerSort;
204  VECMUSICROLES m_musicRoles;
205 };
206 
212 typedef std::vector<CSong> VECSONGS;
213 
218 typedef std::map<std::string, VECSONGS> MAPSONGS;
219 
225 typedef std::vector<CGenre> VECGENRES;
std::vector< CGenre > VECGENRES
A vector of std::string objects, used for CMusicDatabase.
Definition: Song.h:225
const std::vector< std::string > GetAlbumArtist() const
Get album artist names associated with song from tag data Note for initial album processing only...
Definition: Song.h:96
Definition: Artist.h:194
Definition: ReplayGain.h:16
const std::string GetComposerSort() const
Get composer sort name string.
Definition: Song.h:111
std::map< std::string, VECSONGS > MAPSONGS
A map of a vector of CSong objects key by filename, used for CMusicDatabase.
Definition: Song.h:218
const std::string GetAlbumArtistSort() const
Get album artist sort name string.
Definition: Song.h:101
Definition: Variant.h:31
const VECMUSICROLES & GetContributors() const
Get the full list of artist names and the role each played for those that contributed to the recordin...
Definition: Song.h:118
void SetAlbumArtist(const std::vector< std::string > &albumartists)
Set album artist vector. Album artist is held local to song until album created for initial processin...
Definition: Song.h:127
Definition: EmbeddedArt.h:17
Definition: ISerializable.h:13
std::vector< CSong > VECSONGS
A vector of CSong objects, used for CMusicDatabase.
Definition: Song.h:212
bool HasArtistCredits() const
Whether this song has any artists in artist credits vector Tests if artist credits has been populated...
Definition: Song.h:133
Class to store and read album information from CMusicDatabase.
Definition: Song.h:34
DateTime class, which uses FileTime as it&#39;s base.
Definition: XBDateTime.h:63
bool HasContributors() const
Whether this song has any artists in music roles (contributors) vector Tests if contributors has been...
Definition: Song.h:138
Class to store and read song information from CMusicDatabase.
Definition: Song.h:48
Represents a file on a share.
Definition: FileItem.h:102