Go to the documentation of this file. 1 #ifndef MUSICMETADATA_H_
2 #define MUSICMETADATA_H_
10 #include <QCoreApplication>
15 #include <QStringList>
44 m_filename(
""), m_hostname(
""), m_description(
"") {}
46 m_id(image->m_id), m_filename(image->m_filename),
47 m_hostname(image->m_hostname), m_imageType(image->m_imageType),
48 m_description(image->m_description), m_embedded(image->m_embedded) {}
54 bool m_embedded {
false};
76 static constexpr
const char*
STREAMUPDATEURL {
"https://services.mythtv.org/music/data/?data=streams" };
79 using UrlList = std::array<QString,STREAMURLCOUNT>;
89 explicit MusicMetadata(QString lfilename =
"", QString lartist =
"", QString lcompilation_artist =
"",
90 QString lalbum =
"", QString ltitle =
"", QString lgenre =
"",
91 int lyear = 0,
int ltracknum = 0, std::chrono::milliseconds llength = 0ms,
int lid = 0,
92 int lrating = 0,
int lplaycount = 0, QDateTime llastplay = QDateTime(),
93 QDateTime ldateadded = QDateTime(),
bool lcompilation =
false, QString lformat =
"")
94 : m_artist(std::move(lartist)),
95 m_compilationArtist(std::move(lcompilation_artist)),
96 m_album(std::move(lalbum)),
97 m_title(std::move(ltitle)),
98 m_genre(std::move(lgenre)),
99 m_format(std::move(lformat)),
101 m_trackNum(ltracknum),
104 m_lastPlay(std::move(llastplay)),
105 m_dateAdded(std::move(ldateadded)),
106 m_playCount(lplaycount),
107 m_compilation(lcompilation),
109 m_filename(std::move(lfilename))
114 MusicMetadata(
int lid, QString lbroadcaster, QString lchannel, QString ldescription,
const UrlList &lurls, QString llogourl,
115 QString lgenre, QString lmetaformat, QString lcountry, QString llanguage, QString lformat);
126 QString
Artist()
const {
return m_artist; }
129 const QString &lartist_sort =
nullptr)
133 m_artistSort = lartist_sort;
134 m_formattedArtist.clear(); m_formattedTitle.clear();
141 const QString &lcompilation_artist_sort =
nullptr)
143 m_compilationArtist = lcompilation_artist;
145 m_compilationArtistSort = lcompilation_artist_sort;
146 m_formattedArtist.clear(); m_formattedTitle.clear();
150 QString
Album()
const {
return m_album; }
153 const QString &lalbum_sort =
nullptr)
157 m_albumSort = lalbum_sort;
158 m_formattedArtist.clear(); m_formattedTitle.clear();
162 QString
Title()
const {
return m_title; }
165 const QString <itle_sort =
nullptr)
168 m_titleSort = ltitle_sort;
172 QString FormatArtist();
173 QString FormatTitle();
175 QString
Genre()
const {
return m_genre; }
182 int getDirectoryId();
188 int getCompilationArtistId();
196 int Year()
const {
return m_year; }
199 int Track()
const {
return m_trackNum; }
205 std::chrono::milliseconds
Length()
const {
return m_length; }
206 template <typename T, std::enable_if_t<std::chrono::__is_duration<T>::value,
bool> =
true>
226 QString Filename(
bool find =
true);
227 void setFilename(
const QString &lfilename);
228 QString getLocalFilename(
void);
236 QString
Format()
const {
return m_format; }
237 void setFormat(
const QString &lformat) { m_format = lformat; }
246 void setLastPlay(
const QDateTime& lastPlay);
255 m_compilation = state;
256 m_formattedArtist.clear();
257 m_formattedTitle.clear();
259 bool determineIfCompilation(
bool cd =
false);
265 void setChannel(
const QString &channel) { m_channel = channel; }
271 void setUrl(
const QString &url,
size_t index = 0);
272 QString Url(
size_t index = 0);
274 void setLogoUrl(
const QString &logourl) { m_logoUrl = logourl; }
280 void setCountry(
const QString &country) { m_country = country; }
283 void setLanguage(
const QString &language) { m_language = language; }
288 void reloadMetadata(
void);
289 void dumpToDatabase(
void);
290 void setField(
const QString &field,
const QString &data);
291 void getField(
const QString& field, QString *data);
292 void toMap(
InfoMap &metadataMap,
const QString &
prefix =
"");
303 static void setArtistAndTrackFormats();
304 static QStringList fillFieldList(
const QString& field);
305 static bool updateStreamList(
void);
308 QString getAlbumArtFile(
void);
313 void reloadAlbumArtImages(
void);
320 void setCompilationFormatting(
bool cd =
false);
321 QString formatReplaceSymbols(
const QString &format);
322 void checkEmptyFields(
void);
323 void ensureSortFields(
void);
324 void saveHostname(
void);
340 int m_trackCount {0};
343 std::chrono::milliseconds m_length {0ms};
345 int m_directoryId {-1};
347 int m_compartistId {-1};
354 int m_tempPlayCount {0};
355 bool m_compilation {
false};
365 uint64_t m_fileSize {0};
366 bool m_changed {
false};
408 :
MThread(
"MetadataLoading"), m_parent(parent_ptr) {}
429 int count()
const {
return m_numPcs; }
432 bool startLoading(
void);
436 void clearCDData(
void);
441 void setCDTitle(
const QString &a_title) { m_cdTitle = a_title; }
445 bool cleanOutThreads();
450 bool isValidID(
int an_id);
466 bool m_doneLoading {
false};
468 int m_playCountMin {0};
469 int m_playCountMax {0};
470 qint64 m_lastPlayMin {0};
471 qint64 m_lastPlayMax {0};
483 void loadStreams(
void);
529 void scanForImages(
void);
534 QStringList getImageFilenames(
void)
const;
538 void dumpToDatabase(
void);
543 static ImageType getImageTypeFromName(
const QString &name);
546 void findImages(
void);
AlbumArtScannerThread(QStringList strList)
bool SendReceiveStringList(QStringList &strlist, bool quickTimeout=false, bool block=true)
Send a message to the backend and wait for a response.
MetadataPtrList * getAllCDMetadata(void)
MetadataPtrList m_allMusic
AlbumArtList * getImageList(void)
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
void setCDTitle(const QString &a_title)
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
MetadataPtrList * getAllMetadata(void)
QHash< QString, QString > InfoMap
StreamList * getStreams(void)
QString getCDTitle(void) const
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
void run(const QString &name, Class *object, void(Class::*fn)())
int getCDTrackCount(void) const
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
AlbumArtImage(const AlbumArtImage *const image)
QMap< int, MusicMetadata * > MusicMap
This is a wrapper around QThread that does several additional things.
QStringList getResult(void)
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)