Skip to content

Latest commit

 

History

History
2023 lines (1737 loc) · 60.9 KB

videometadata.cpp

File metadata and controls

2023 lines (1737 loc) · 60.9 KB
 
Dec 14, 2008
Dec 14, 2008
1
#include <cmath> // for isnan()
Sep 3, 2003
Sep 3, 2003
2
Mar 25, 2008
Mar 25, 2008
3
#include <QDir>
Nov 10, 2019
Nov 10, 2019
4
#include <QFile>
Mar 25, 2008
Mar 25, 2008
5
#include <QFileInfo>
Feb 19, 2021
Feb 19, 2021
6
#include <QRegularExpression>
Mar 25, 2008
Mar 25, 2008
7
May 3, 2022
May 3, 2022
8
9
10
11
12
13
14
15
#include "libmyth/mythcontext.h"
#include "libmythbase/mythcorecontext.h"
#include "libmythbase/mythdate.h"
#include "libmythbase/mythdb.h"
#include "libmythbase/mythlogging.h"
#include "libmythbase/mythmiscutil.h"// for FileHash
#include "libmythbase/mythsorthelper.h"
#include "libmythbase/remotefile.h"
Nov 24, 2022
Nov 24, 2022
16
#include "libmythbase/remoteutil.h"
May 3, 2022
May 3, 2022
17
18
#include "libmythbase/storagegroup.h"
#include "libmythbase/stringutil.h"
May 27, 2022
May 27, 2022
19
#include "libmythbase/ternarycompare.h"
May 3, 2022
May 3, 2022
20
Aug 19, 2006
Aug 19, 2006
21
#include "dbaccess.h"
May 3, 2022
May 3, 2022
22
#include "globals.h"
Aug 30, 2010
Aug 30, 2010
23
#include "videometadatalistmanager.h"
Aug 13, 2009
Aug 13, 2009
24
#include "videoutils.h"
Dec 10, 2002
Dec 10, 2002
25
Aug 30, 2010
Aug 30, 2010
26
class VideoMetadataImp
Dec 10, 2002
Dec 10, 2002
27
{
Aug 19, 2006
Aug 19, 2006
28
public:
Nov 29, 2019
Nov 29, 2019
29
30
31
using genre_list = VideoMetadata::genre_list;
using country_list = VideoMetadata::country_list;
using cast_list = VideoMetadata::cast_list;
Aug 19, 2006
Aug 19, 2006
32
33
public:
Nov 10, 2019
Nov 10, 2019
34
35
36
37
38
VideoMetadataImp(QString filename, QString sortFilename,
QString hash, QString trailer,
QString coverfile, QString screenshot, QString banner,
QString fanart, const QString &title, QString sortTitle,
const QString &subtitle, QString sortSubtitle,
Nov 15, 2020
Nov 15, 2020
39
QString tagline, int year, const QDate releasedate,
Nov 10, 2019
Nov 10, 2019
40
41
42
43
QString inetref, int collectionref, QString homepage,
QString director, QString studio,
QString plot, float userrating,
QString rating, int length, int playcount,
Nov 15, 2020
Nov 15, 2020
44
int season, int episode, const QDate insertdate,
Oct 22, 2007
Oct 22, 2007
45
int id, ParentalLevel::Level showlevel, int categoryID,
Aug 12, 2009
Aug 12, 2009
46
int childID, bool browse, bool watched,
Nov 10, 2019
Nov 10, 2019
47
48
49
50
51
QString playcommand, QString category,
genre_list genres,
country_list countries,
cast_list cast,
QString host = "",
Feb 12, 2012
Feb 12, 2012
52
53
bool processed = false,
VideoContentType contenttype = kContentUnknown) :
Nov 10, 2019
Nov 10, 2019
54
55
56
57
58
59
60
61
62
63
64
65
66
m_title(title), m_sortTitle(std::move(sortTitle)), m_subtitle(subtitle),
m_sortSubtitle(std::move(sortSubtitle)), m_tagline(std::move(tagline)),
m_inetref(std::move(inetref)), m_collectionref(collectionref),
m_homepage(std::move(homepage)), m_director(std::move(director)),
m_studio(std::move(studio)), m_plot(std::move(plot)),
m_rating(std::move(rating)), m_playcommand(std::move(playcommand)),
m_category(std::move(category)), m_genres(std::move(genres)),
m_countries(std::move(countries)), m_cast(std::move(cast)),
m_filename(std::move(filename)), m_sortFilename(std::move(sortFilename)),
m_hash(std::move(hash)), m_trailer(std::move(trailer)),
m_coverfile(std::move(coverfile)), m_screenshot(std::move(screenshot)),
m_banner(std::move(banner)), m_fanart(std::move(fanart)),
m_host(std::move(host)), m_categoryID(categoryID), m_childID(childID),
Feb 12, 2012
Feb 12, 2012
67
68
m_year(year), m_releasedate(releasedate), m_length(length), m_playcount(playcount),
m_season(season), m_episode(episode), m_insertdate(insertdate), m_showlevel(showlevel),
May 15, 2010
May 15, 2010
69
m_browse(browse), m_watched(watched), m_id(id),
Feb 12, 2012
Feb 12, 2012
70
71
m_userrating(userrating), m_processed(processed),
m_contenttype(contenttype)
Aug 19, 2006
Aug 19, 2006
72
{
Dec 17, 2018
Dec 17, 2018
73
74
75
76
77
78
79
80
81
82
// Try to glean data if none provided.
if (title.isEmpty() and subtitle.isEmpty()
and season == 0 and episode == 0)
{
m_title = VideoMetadata::FilenameToMeta(m_filename, 1);
m_subtitle = VideoMetadata::FilenameToMeta(m_filename, 4);
m_season = VideoMetadata::FilenameToMeta(m_filename, 2).toInt();
m_episode = VideoMetadata::FilenameToMeta(m_filename, 3).toInt();
}
Mar 9, 2009
Mar 9, 2009
83
VideoCategory::GetCategory().get(m_categoryID, m_category);
Dec 17, 2018
Dec 17, 2018
84
85
ensureSortFields();
Aug 19, 2006
Aug 19, 2006
86
}
Dec 10, 2002
Dec 10, 2002
87
Dec 18, 2015
Dec 18, 2015
88
explicit VideoMetadataImp(MSqlQuery &query)
Aug 19, 2006
Aug 19, 2006
89
90
{
fromDBRow(query);
Dec 17, 2018
Dec 17, 2018
91
ensureSortFields();
Aug 19, 2006
Aug 19, 2006
92
93
}
Aug 30, 2010
Aug 30, 2010
94
VideoMetadataImp(const VideoMetadataImp &other)
Aug 19, 2006
Aug 19, 2006
95
{
Oct 2, 2008
Oct 2, 2008
96
*this = other;
Aug 19, 2006
Aug 19, 2006
97
98
}
Aug 30, 2010
Aug 30, 2010
99
VideoMetadataImp &operator=(const VideoMetadataImp &rhs)
Aug 19, 2006
Aug 19, 2006
100
{
Oct 2, 2008
Oct 2, 2008
101
102
103
if (this != &rhs)
{
m_title = rhs.m_title;
Dec 17, 2018
Dec 17, 2018
104
m_sortTitle = rhs.m_sortTitle;
Aug 4, 2009
Aug 4, 2009
105
m_subtitle = rhs.m_subtitle;
Dec 17, 2018
Dec 17, 2018
106
m_sortSubtitle = rhs.m_sortSubtitle;
May 9, 2010
May 9, 2010
107
m_tagline = rhs.m_tagline;
Oct 2, 2008
Oct 2, 2008
108
m_inetref = rhs.m_inetref;
Feb 12, 2012
Feb 12, 2012
109
m_collectionref = rhs.m_collectionref;
Nov 11, 2009
Nov 11, 2009
110
m_homepage = rhs.m_homepage;
Oct 2, 2008
Oct 2, 2008
111
m_director = rhs.m_director;
Sep 6, 2010
Sep 6, 2010
112
m_studio = rhs.m_studio;
Oct 2, 2008
Oct 2, 2008
113
114
115
116
117
118
119
120
m_plot = rhs.m_plot;
m_rating = rhs.m_rating;
m_playcommand = rhs.m_playcommand;
m_category = rhs.m_category;
m_genres = rhs.m_genres;
m_countries = rhs.m_countries;
m_cast = rhs.m_cast;
m_filename = rhs.m_filename;
Dec 17, 2018
Dec 17, 2018
121
m_sortFilename = rhs.m_sortFilename;
Nov 20, 2009
Nov 20, 2009
122
m_hash = rhs.m_hash;
Dec 23, 2008
Dec 23, 2008
123
m_trailer = rhs.m_trailer;
Oct 2, 2008
Oct 2, 2008
124
m_coverfile = rhs.m_coverfile;
Mar 9, 2009
Mar 9, 2009
125
126
127
m_screenshot = rhs.m_screenshot;
m_banner = rhs.m_banner;
m_fanart = rhs.m_fanart;
Oct 2, 2008
Oct 2, 2008
128
129
130
131
m_categoryID = rhs.m_categoryID;
m_childID = rhs.m_childID;
m_year = rhs.m_year;
Nov 11, 2009
Nov 11, 2009
132
m_releasedate = rhs.m_releasedate;
Oct 2, 2008
Oct 2, 2008
133
m_length = rhs.m_length;
Feb 12, 2012
Feb 12, 2012
134
m_playcount = rhs.m_playcount;
Aug 4, 2009
Aug 4, 2009
135
136
m_season = rhs.m_season;
m_episode = rhs.m_episode;
Aug 14, 2009
Aug 14, 2009
137
m_insertdate = rhs.m_insertdate;
Oct 2, 2008
Oct 2, 2008
138
139
m_showlevel = rhs.m_showlevel;
m_browse = rhs.m_browse;
Aug 12, 2009
Aug 12, 2009
140
m_watched = rhs.m_watched;
Oct 2, 2008
Oct 2, 2008
141
142
m_id = rhs.m_id;
m_userrating = rhs.m_userrating;
Feb 12, 2009
Feb 12, 2009
143
m_host = rhs.m_host;
Jun 5, 2010
Jun 5, 2010
144
m_processed = rhs.m_processed;
Feb 12, 2012
Feb 12, 2012
145
m_contenttype = rhs.m_contenttype;
Oct 2, 2008
Oct 2, 2008
146
147
148
// No DB vars
m_prefix = rhs.m_prefix;
Dec 17, 2018
Dec 17, 2018
149
150
ensureSortFields();
Oct 2, 2008
Oct 2, 2008
151
}
Aug 19, 2006
Aug 19, 2006
152
153
154
155
return *this;
}
Dec 17, 2018
Dec 17, 2018
156
void ensureSortFields(void)
Aug 19, 2006
Aug 19, 2006
157
{
Dec 17, 2018
Dec 17, 2018
158
159
160
161
162
163
164
std::shared_ptr<MythSortHelper>sh = getMythSortHelper();
if (m_sortTitle.isEmpty() and not m_title.isEmpty())
m_sortTitle = sh->doTitle(m_title);
if (m_sortSubtitle.isEmpty() and not m_subtitle.isEmpty())
m_sortSubtitle = sh->doTitle(m_subtitle);
if (m_sortFilename.isEmpty() and not m_filename.isEmpty())
m_sortFilename = sh->doPathname(m_filename);
Aug 19, 2006
Aug 19, 2006
165
166
}
Dec 17, 2018
Dec 17, 2018
167
public:
Mar 9, 2009
Mar 9, 2009
168
169
const QString &GetPrefix() const { return m_prefix; }
void SetPrefix(const QString &prefix) { m_prefix = prefix; }
Aug 19, 2006
Aug 19, 2006
170
171
const QString &getTitle() const { return m_title; }
Dec 17, 2018
Dec 17, 2018
172
173
const QString &getSortTitle() const { return m_sortTitle; }
void SetTitle(const QString& title, const QString& sortTitle = "")
Aug 19, 2006
Aug 19, 2006
174
175
{
m_title = title;
Dec 17, 2018
Dec 17, 2018
176
177
m_sortTitle = sortTitle;
ensureSortFields();
Aug 19, 2006
Aug 19, 2006
178
179
}
Aug 4, 2009
Aug 4, 2009
180
const QString &getSubtitle() const { return m_subtitle; }
Dec 17, 2018
Dec 17, 2018
181
182
183
184
185
186
const QString &getSortSubtitle() const { return m_sortSubtitle; }
void SetSubtitle(const QString &subtitle, const QString &sortSubtitle = "") {
m_subtitle = subtitle;
m_sortSubtitle = sortSubtitle;
ensureSortFields();
}
Aug 4, 2009
Aug 4, 2009
187
May 9, 2010
May 9, 2010
188
189
190
const QString &GetTagline() const { return m_tagline; }
void SetTagline(const QString &tagline) { m_tagline = tagline; }
Mar 9, 2009
Mar 9, 2009
191
192
const QString &GetInetRef() const { return m_inetref; }
void SetInetRef(const QString &inetRef) { m_inetref = inetRef; }
Aug 19, 2006
Aug 19, 2006
193
Feb 12, 2012
Feb 12, 2012
194
195
196
int GetCollectionRef() const { return m_collectionref; }
void SetCollectionRef(int collectionref) { m_collectionref = collectionref; }
Nov 11, 2009
Nov 11, 2009
197
198
199
const QString &GetHomepage() const { return m_homepage; }
void SetHomepage(const QString &homepage) { m_homepage = homepage; }
Aug 19, 2006
Aug 19, 2006
200
const QString &getDirector() const { return m_director; }
Mar 9, 2009
Mar 9, 2009
201
void SetDirector(const QString &director) { m_director = director; }
Aug 19, 2006
Aug 19, 2006
202
Sep 6, 2010
Sep 6, 2010
203
204
205
const QString &getStudio() const { return m_studio; }
void SetStudio(const QString &studio) { m_studio = studio; }
Aug 19, 2006
Aug 19, 2006
206
const QString &getPlot() const { return m_plot; }
Mar 9, 2009
Mar 9, 2009
207
void SetPlot(const QString &plot) { m_plot = plot; }
Aug 19, 2006
Aug 19, 2006
208
Mar 9, 2009
Mar 9, 2009
209
210
const QString &GetRating() const { return m_rating; }
void SetRating(const QString &rating) { m_rating = rating; }
Aug 19, 2006
Aug 19, 2006
211
212
const QString &getPlayCommand() const { return m_playcommand; }
Mar 9, 2009
Mar 9, 2009
213
void SetPlayCommand(const QString &playCommand)
Aug 19, 2006
Aug 19, 2006
214
215
216
217
{
m_playcommand = playCommand;
}
Mar 9, 2009
Mar 9, 2009
218
219
const QString &GetCategory() const { return m_category; }
// void SetCategory(const QString &category) { m_category = category; }
Aug 19, 2006
Aug 19, 2006
220
221
const genre_list &getGenres() const { return m_genres; }
Mar 9, 2009
Mar 9, 2009
222
void SetGenres(const genre_list &genres) { m_genres = genres; }
Aug 19, 2006
Aug 19, 2006
223
Mar 9, 2009
Mar 9, 2009
224
225
const country_list &GetCountries() const { return m_countries; }
void SetCountries(const country_list &countries)
Aug 19, 2006
Aug 19, 2006
226
227
228
229
{
m_countries = countries;
}
Feb 11, 2008
Feb 11, 2008
230
231
232
const cast_list &GetCast() const { return m_cast; }
void SetCast(const cast_list &cast) { m_cast = cast; }
Mar 9, 2009
Mar 9, 2009
233
234
const QString &GetHost() const { return m_host; }
void SetHost(const QString &host) { m_host = host; }
Feb 12, 2009
Feb 12, 2009
235
Aug 19, 2006
Aug 19, 2006
236
const QString &getFilename() const { return m_filename; }
Dec 17, 2018
Dec 17, 2018
237
238
239
240
241
242
243
244
245
const QString &getSortFilename() const { return m_sortFilename; }
void SetFilename(const QString &filename, const QString &sortFilename = "")
{
m_filename = filename;
m_sortFilename = sortFilename;
ensureSortFields();
}
bool sortBefore(const VideoMetadataImp *rhs) const;
Aug 19, 2006
Aug 19, 2006
246
Nov 20, 2009
Nov 20, 2009
247
248
249
const QString &GetHash() const { return m_hash; }
void SetHash(const QString &hash) { m_hash = hash; }
Dec 23, 2008
Dec 23, 2008
250
251
252
const QString &GetTrailer() const { return m_trailer; }
void SetTrailer(const QString &trailer) { m_trailer = trailer; }
Mar 9, 2009
Mar 9, 2009
253
254
const QString &GetCoverFile() const { return m_coverfile; }
void SetCoverFile(const QString &coverFile) { m_coverfile = coverFile; }
Aug 19, 2006
Aug 19, 2006
255
Mar 9, 2009
Mar 9, 2009
256
257
258
259
260
261
262
263
264
265
const QString &GetScreenshot() const { return m_screenshot; }
void SetScreenshot(const QString &screenshot) { m_screenshot = screenshot; }
const QString &GetBanner() const { return m_banner; }
void SetBanner(const QString &banner) { m_banner = banner; }
const QString &GetFanart() const { return m_fanart; }
void SetFanart(const QString &fanart) { m_fanart = fanart; }
int GetCategoryID() const
Aug 19, 2006
Aug 19, 2006
266
267
268
{
return m_categoryID;
}
Mar 9, 2009
Mar 9, 2009
269
void SetCategoryID(int id);
Aug 19, 2006
Aug 19, 2006
270
Mar 9, 2009
Mar 9, 2009
271
272
int GetChildID() const { return m_childID; }
void SetChildID(int childID) { m_childID = childID; }
Aug 19, 2006
Aug 19, 2006
273
274
int getYear() const { return m_year; }
Mar 9, 2009
Mar 9, 2009
275
void SetYear(int year) { m_year = year; }
Aug 19, 2006
Aug 19, 2006
276
Nov 11, 2009
Nov 11, 2009
277
QDate getReleaseDate() const { return m_releasedate; }
May 15, 2010
May 15, 2010
278
void SetReleaseDate(QDate releasedate) { m_releasedate = releasedate; }
Nov 11, 2009
Nov 11, 2009
279
Jan 25, 2021
Jan 25, 2021
280
281
std::chrono::minutes GetLength() const { return m_length; }
void SetLength(std::chrono::minutes length) { m_length = length; }
Aug 19, 2006
Aug 19, 2006
282
Feb 12, 2012
Feb 12, 2012
283
284
285
unsigned int GetPlayCount() const { return m_playcount; }
void SetPlayCount(int playcount) { m_playcount = playcount; }
Aug 4, 2009
Aug 4, 2009
286
287
288
289
290
291
int GetSeason() const { return m_season; }
void SetSeason(int season) { m_season = season; }
int GetEpisode() const { return m_episode; }
void SetEpisode(int episode) { m_episode = episode; }
Aug 14, 2009
Aug 14, 2009
292
293
294
QDate GetInsertdate() const { return m_insertdate;}
void SetInsertdate(QDate date) { m_insertdate = date;}
Mar 9, 2009
Mar 9, 2009
295
296
ParentalLevel::Level GetShowLevel() const { return m_showlevel; }
void SetShowLevel(ParentalLevel::Level showLevel)
Oct 22, 2007
Oct 22, 2007
297
298
299
{
m_showlevel = ParentalLevel(showLevel).GetLevel();
}
Aug 19, 2006
Aug 19, 2006
300
Mar 9, 2009
Mar 9, 2009
301
302
bool GetBrowse() const { return m_browse; }
void SetBrowse(bool browse) { m_browse = browse; }
Aug 19, 2006
Aug 19, 2006
303
Aug 12, 2009
Aug 12, 2009
304
305
306
bool GetWatched() const { return m_watched; }
void SetWatched(bool watched) { m_watched = watched; }
Mar 9, 2009
Mar 9, 2009
307
308
unsigned int GetID() const { return m_id; }
void SetID(int id) { m_id = id; }
Aug 19, 2006
Aug 19, 2006
309
Mar 9, 2009
Mar 9, 2009
310
311
float GetUserRating() const { return m_userrating; }
void SetUserRating(float userRating) { m_userrating = userRating; }
Aug 19, 2006
Aug 19, 2006
312
Jun 5, 2010
Jun 5, 2010
313
314
315
bool GetProcessed() const { return m_processed; }
void SetProcessed(bool processed) { m_processed = processed; }
Feb 12, 2012
Feb 12, 2012
316
317
318
VideoContentType GetContentType() const { return m_contenttype; }
void SetContentType(VideoContentType contenttype) { m_contenttype = contenttype; }
Aug 19, 2006
Aug 19, 2006
319
320
////////////////////////////////
Mar 9, 2009
Mar 9, 2009
321
322
323
void SaveToDatabase();
void UpdateDatabase();
bool DeleteFromDatabase();
Aug 19, 2006
Aug 19, 2006
324
Jul 1, 2011
Jul 1, 2011
325
bool DeleteFile();
Aug 19, 2006
Aug 19, 2006
326
Dec 8, 2007
Dec 8, 2007
327
328
void Reset();
Mar 9, 2009
Mar 9, 2009
329
330
bool IsHostSet() const;
Aug 20, 2013
Aug 20, 2013
331
void GetImageMap(InfoMap &imageMap) const;
Sep 11, 2021
Sep 11, 2021
332
QString GetImage(const QString &name) const;
Aug 20, 2013
Aug 20, 2013
333
Aug 19, 2006
Aug 19, 2006
334
335
336
337
private:
void fillCountries();
void updateCountries();
void fillGenres();
Feb 11, 2008
Feb 11, 2008
338
void fillCast();
Aug 19, 2006
Aug 19, 2006
339
void updateGenres();
Feb 11, 2008
Feb 11, 2008
340
void updateCast();
Aug 19, 2006
Aug 19, 2006
341
342
343
344
345
bool removeDir(const QString &dirName);
void fromDBRow(MSqlQuery &query);
void saveToDatabase();
private:
Nov 10, 2019
Nov 10, 2019
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
QString m_title;
QString m_sortTitle;
QString m_subtitle;
QString m_sortSubtitle;
QString m_tagline;
QString m_inetref;
int m_collectionref {0};
QString m_homepage;
QString m_director;
QString m_studio;
QString m_plot;
QString m_rating;
QString m_playcommand;
QString m_category;
genre_list m_genres;
country_list m_countries;
cast_list m_cast;
QString m_filename;
QString m_sortFilename;
QString m_hash;
QString m_trailer;
QString m_coverfile;
QString m_screenshot;
QString m_banner;
QString m_fanart;
QString m_host;
int m_categoryID {0};
int m_childID {-1};
int m_year {VIDEO_YEAR_DEFAULT};
QDate m_releasedate;
Jan 25, 2021
Jan 25, 2021
377
std::chrono::minutes m_length {0min};
Nov 10, 2019
Nov 10, 2019
378
379
380
381
382
383
384
385
386
387
388
int m_playcount {0};
int m_season {0};
int m_episode {0};
QDate m_insertdate;
ParentalLevel::Level m_showlevel {ParentalLevel::plNone};
bool m_browse {true};
bool m_watched {false};
unsigned int m_id {0}; // videometadata.intid
float m_userrating {0.0};
bool m_processed {false};
VideoContentType m_contenttype {kContentUnknown};
Aug 19, 2006
Aug 19, 2006
389
390
// not in DB
Nov 10, 2019
Nov 10, 2019
391
QString m_prefix;
Aug 19, 2006
Aug 19, 2006
392
393
394
395
396
};
/////////////////////////////
/////////
/////////////////////////////
Dec 17, 2018
Dec 17, 2018
397
398
399
400
401
/** \fn VideoMetadataImp::sortBefore(const VideoMetadataImp *)
* \brief Returns true if the object should appear before the argument.
*/
bool VideoMetadataImp::sortBefore(const VideoMetadataImp *rhs) const
{
May 27, 2022
May 27, 2022
402
403
404
405
406
407
int cmp = StringUtil::naturalCompare(m_sortTitle, rhs->m_sortTitle);
if (cmp == 0)
cmp = StringUtil::naturalCompare(m_sortFilename, rhs->m_sortFilename);
if (cmp == 0)
cmp = ternary_compare(m_id, rhs->m_id);
return cmp < 0;
Dec 17, 2018
Dec 17, 2018
408
409
}
Aug 30, 2010
Aug 30, 2010
410
bool VideoMetadataImp::removeDir(const QString &dirName)
Dec 10, 2002
Dec 10, 2002
411
{
Oct 4, 2005
Oct 4, 2005
412
QDir d(dirName);
Dec 18, 2015
Dec 18, 2015
413
Feb 16, 2013
Feb 16, 2013
414
d.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
Mar 25, 2008
Mar 25, 2008
415
QFileInfoList contents = d.entryInfoList();
Mar 19, 2019
Mar 19, 2019
416
if (contents.empty())
Dec 24, 2004
Dec 24, 2004
417
{
Oct 4, 2005
Oct 4, 2005
418
return d.rmdir(dirName);
Dec 24, 2004
Dec 24, 2004
419
}
Oct 4, 2005
Oct 4, 2005
420
Feb 15, 2024
Feb 15, 2024
421
for (const auto& entry : std::as_const(contents))
Sep 2, 2003
Sep 2, 2003
422
{
Jan 7, 2020
Jan 7, 2020
423
if (entry.isDir())
Sep 2, 2003
Sep 2, 2003
424
{
Jan 7, 2020
Jan 7, 2020
425
QString fileName = entry.fileName();
Oct 4, 2005
Oct 4, 2005
426
427
if (!removeDir(fileName))
return false;
Sep 2, 2003
Sep 2, 2003
428
429
430
}
else
{
Jan 7, 2020
Jan 7, 2020
431
if (!QFile(entry.fileName()).remove())
Oct 4, 2005
Oct 4, 2005
432
return false;
Sep 2, 2003
Sep 2, 2003
433
434
}
}
Oct 4, 2005
Oct 4, 2005
435
return d.rmdir(dirName);
Dec 10, 2002
Dec 10, 2002
436
437
}
Aug 19, 2006
Aug 19, 2006
438
/// Deletes the file associated with a metadata entry
Jul 1, 2011
Jul 1, 2011
439
bool VideoMetadataImp::DeleteFile()
Mar 2, 2004
Mar 2, 2004
440
{
Oct 4, 2005
Oct 4, 2005
441
bool isremoved = false;
Aug 13, 2009
Aug 13, 2009
442
443
if (!m_host.isEmpty())
Oct 4, 2005
Oct 4, 2005
444
{
Dec 27, 2009
Dec 27, 2009
445
QString url = generate_file_url("Videos", m_host, m_filename);
Aug 13, 2009
Aug 13, 2009
446
isremoved = RemoteFile::DeleteFile(url);
Oct 4, 2005
Oct 4, 2005
447
448
449
}
else
{
Aug 13, 2009
Aug 13, 2009
450
451
452
453
454
455
456
457
458
QFileInfo fi(m_filename);
if (fi.isDir())
{
isremoved = removeDir(m_filename);
}
else
{
isremoved = QFile::remove(m_filename);
}
Oct 4, 2005
Oct 4, 2005
459
}
Feb 24, 2005
Feb 24, 2005
460
Aug 19, 2006
Aug 19, 2006
461
if (!isremoved)
Aug 9, 2004
Aug 9, 2004
462
{
Jul 3, 2011
Jul 3, 2011
463
464
LOG(VB_GENERAL, LOG_DEBUG, QString("Could not delete file: %1")
.arg(m_filename));
Aug 9, 2004
Aug 9, 2004
465
}
Aug 19, 2006
Aug 19, 2006
466
Aug 9, 2004
Aug 9, 2004
467
return isremoved;
Mar 2, 2004
Mar 2, 2004
468
469
}
Aug 30, 2010
Aug 30, 2010
470
void VideoMetadataImp::Reset()
Dec 8, 2007
Dec 8, 2007
471
{
Dec 17, 2018
Dec 17, 2018
472
473
VideoMetadataImp tmp(m_filename, QString(),
VideoMetadata::VideoFileHash(m_filename, m_host), VIDEO_TRAILER_DEFAULT,
Nov 20, 2009
Nov 20, 2009
474
VIDEO_COVERFILE_DEFAULT, VIDEO_SCREENSHOT_DEFAULT, VIDEO_BANNER_DEFAULT,
Dec 17, 2018
Dec 17, 2018
475
476
VIDEO_FANART_DEFAULT, QString(), QString(), QString(), QString(),
QString(), VIDEO_YEAR_DEFAULT,
Feb 20, 2012
Feb 20, 2012
477
QDate(), VIDEO_INETREF_DEFAULT, -1, QString(), VIDEO_DIRECTOR_DEFAULT,
Sep 6, 2010
Sep 6, 2010
478
QString(), VIDEO_PLOT_DEFAULT, 0.0,
Feb 12, 2012
Feb 12, 2012
479
VIDEO_RATING_DEFAULT, 0, 0,
Dec 17, 2018
Dec 17, 2018
480
0, 0, QDate(), m_id,
Aug 12, 2009
Aug 12, 2009
481
ParentalLevel::plLowest, 0, -1, true, false, "", "",
Aug 30, 2010
Aug 30, 2010
482
483
VideoMetadata::genre_list(), VideoMetadata::country_list(),
VideoMetadata::cast_list(), m_host, false);
Dec 8, 2007
Dec 8, 2007
484
485
486
487
488
tmp.m_prefix = m_prefix;
*this = tmp;
}
Aug 30, 2010
Aug 30, 2010
489
bool VideoMetadataImp::IsHostSet() const
Mar 9, 2009
Mar 9, 2009
490
{
Mar 9, 2009
Mar 9, 2009
491
return !m_host.isEmpty();
Mar 9, 2009
Mar 9, 2009
492
493
}
Aug 30, 2010
Aug 30, 2010
494
void VideoMetadataImp::fillGenres()
Mar 2, 2004
Mar 2, 2004
495
{
Aug 19, 2006
Aug 19, 2006
496
497
498
499
500
501
m_genres.clear();
VideoGenreMap &vgm = VideoGenreMap::getGenreMap();
VideoGenreMap::entry genres;
if (vgm.get(m_id, genres))
{
VideoGenre &vg = VideoGenre::getGenre();
Jan 7, 2020
Jan 7, 2020
502
for (long value : genres.values)
Aug 9, 2004
Aug 9, 2004
503
{
Aug 19, 2006
Aug 19, 2006
504
505
// Just add empty string for no-name genres
QString name;
Jan 7, 2020
Jan 7, 2020
506
vg.get(value, name);
May 13, 2023
May 13, 2023
507
m_genres.emplace_back(value, name);
Aug 9, 2004
Aug 9, 2004
508
509
}
}
Mar 2, 2004
Mar 2, 2004
510
511
}
Aug 30, 2010
Aug 30, 2010
512
void VideoMetadataImp::fillCountries()
Mar 2, 2004
Mar 2, 2004
513
{
Aug 19, 2006
Aug 19, 2006
514
515
516
517
518
519
m_countries.clear();
VideoCountryMap &vcm = VideoCountryMap::getCountryMap();
VideoCountryMap::entry countries;
if (vcm.get(m_id, countries))
{
VideoCountry &vc = VideoCountry::getCountry();
Jan 7, 2020
Jan 7, 2020
520
for (long value : countries.values)
Aug 9, 2004
Aug 9, 2004
521
{
Aug 19, 2006
Aug 19, 2006
522
523
// Just add empty string for no-name countries
QString name;
Jan 7, 2020
Jan 7, 2020
524
vc.get(value, name);
May 13, 2023
May 13, 2023
525
m_countries.emplace_back(value, name);
Aug 9, 2004
Aug 9, 2004
526
527
}
}
Aug 19, 2006
Aug 19, 2006
528
}
Mar 2, 2004
Mar 2, 2004
529
Aug 30, 2010
Aug 30, 2010
530
void VideoMetadataImp::fillCast()
Feb 11, 2008
Feb 11, 2008
531
532
533
534
535
536
{
m_cast.clear();
VideoCastMap &vcm = VideoCastMap::getCastMap();
VideoCastMap::entry cast;
if (vcm.get(m_id, cast))
{
Mar 9, 2009
Mar 9, 2009
537
VideoCast &vc = VideoCast::GetCast();
Jan 7, 2020
Jan 7, 2020
538
for (long value : cast.values)
Feb 11, 2008
Feb 11, 2008
539
540
541
{
// Just add empty string for no-name cast
QString name;
Jan 7, 2020
Jan 7, 2020
542
vc.get(value, name);
May 13, 2023
May 13, 2023
543
m_cast.emplace_back(value, name);
Feb 11, 2008
Feb 11, 2008
544
545
546
547
}
}
}
Aug 19, 2006
Aug 19, 2006
548
/// Sets metadata from a DB row
Dec 17, 2018
Dec 17, 2018
549
550
551
///
/// Query string in VideoMetadataListManager::loadAllFromDatabase
///
Aug 30, 2010
Aug 30, 2010
552
void VideoMetadataImp::fromDBRow(MSqlQuery &query)
Aug 19, 2006
Aug 19, 2006
553
{
Mar 25, 2008
Mar 25, 2008
554
555
m_title = query.value(0).toString();
m_director = query.value(1).toString();
Sep 6, 2010
Sep 6, 2010
556
557
558
559
560
561
m_studio = query.value(2).toString();
m_plot = query.value(3).toString();
m_rating = query.value(4).toString();
m_year = query.value(5).toInt();
m_releasedate = query.value(6).toDate();
m_userrating = (float)query.value(7).toDouble();
Oct 2, 2020
Oct 2, 2020
562
if (std::isnan(m_userrating) || m_userrating < 0)
Aug 19, 2006
Aug 19, 2006
563
m_userrating = 0.0;
Mar 26, 2019
Mar 26, 2019
564
565
if (m_userrating > 10.0F)
m_userrating = 10.0F;
Jan 25, 2021
Jan 25, 2021
566
m_length = std::chrono::minutes(query.value(8).toInt());
Feb 12, 2012
Feb 12, 2012
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
m_playcount = query.value(9).toInt();
m_filename = query.value(10).toString();
m_hash = query.value(11).toString();
m_showlevel = ParentalLevel(query.value(12).toInt()).GetLevel();
m_coverfile = query.value(13).toString();
m_inetref = query.value(14).toString();
m_collectionref = query.value(15).toUInt();
m_homepage = query.value(16).toString();
m_childID = query.value(17).toUInt();
m_browse = query.value(18).toBool();
m_watched = query.value(19).toBool();
m_playcommand = query.value(20).toString();
m_categoryID = query.value(21).toInt();
m_id = query.value(22).toInt();
m_trailer = query.value(23).toString();
m_screenshot = query.value(24).toString();
m_banner = query.value(25).toString();
m_fanart = query.value(26).toString();
m_subtitle = query.value(27).toString();
m_tagline = query.value(28).toString();
m_season = query.value(29).toInt();
m_episode = query.value(30).toInt();
m_host = query.value(31).toString();
m_insertdate = query.value(32).toDate();
m_processed = query.value(33).toBool();
m_contenttype = ContentTypeFromString(query.value(34).toString());
Aug 19, 2006
Aug 19, 2006
594
Dec 17, 2018
Dec 17, 2018
595
596
ensureSortFields();
Mar 9, 2009
Mar 9, 2009
597
VideoCategory::GetCategory().get(m_categoryID, m_category);
Aug 19, 2006
Aug 19, 2006
598
599
600
601
602
603
// Genres
fillGenres();
//Countries
fillCountries();
Feb 11, 2008
Feb 11, 2008
604
605
606
// Cast
fillCast();
Mar 2, 2004
Mar 2, 2004
607
608
}
Aug 30, 2010
Aug 30, 2010
609
void VideoMetadataImp::saveToDatabase()
Dec 10, 2002
Dec 10, 2002
610
{
Sep 23, 2008
Sep 23, 2008
611
if (m_title.isEmpty())
Aug 30, 2010
Aug 30, 2010
612
m_title = VideoMetadata::FilenameToMeta(m_filename, 1);
Nov 20, 2009
Nov 20, 2009
613
if (m_hash.isEmpty())
Aug 30, 2010
Aug 30, 2010
614
m_hash = VideoMetadata::VideoFileHash(m_filename, m_host);
Aug 4, 2009
Aug 4, 2009
615
if (m_subtitle.isEmpty())
Aug 30, 2010
Aug 30, 2010
616
m_subtitle = VideoMetadata::FilenameToMeta(m_filename, 4);
Sep 23, 2008
Sep 23, 2008
617
if (m_director.isEmpty())
Aug 19, 2006
Aug 19, 2006
618
m_director = VIDEO_DIRECTOR_UNKNOWN;
Sep 23, 2008
Sep 23, 2008
619
if (m_plot.isEmpty())
Aug 19, 2006
Aug 19, 2006
620
m_plot = VIDEO_PLOT_DEFAULT;
Sep 23, 2008
Sep 23, 2008
621
if (m_rating.isEmpty())
Aug 19, 2006
Aug 19, 2006
622
m_rating = VIDEO_RATING_DEFAULT;
Dec 17, 2018
Dec 17, 2018
623
ensureSortFields();
Aug 20, 2013
Aug 20, 2013
624
625
626
627
628
629
630
631
632
InfoMap metadataMap;
GetImageMap(metadataMap);
QString coverfile = metadataMap["coverfile"];
QString screenshot = metadataMap["screenshotfile"];
QString bannerfile = metadataMap["bannerfile"];
QString fanartfile = metadataMap["fanartfile"];
if (coverfile.isEmpty() || !RemoteFile::Exists(coverfile))
Aug 19, 2006
Aug 19, 2006
633
m_coverfile = VIDEO_COVERFILE_DEFAULT;
Aug 20, 2013
Aug 20, 2013
634
if (screenshot.isEmpty() || !RemoteFile::Exists(screenshot))
Mar 9, 2009
Mar 9, 2009
635
m_screenshot = VIDEO_SCREENSHOT_DEFAULT;
Aug 20, 2013
Aug 20, 2013
636
if (bannerfile.isEmpty() || !RemoteFile::Exists(bannerfile))
Mar 9, 2009
Mar 9, 2009
637
m_banner = VIDEO_BANNER_DEFAULT;
Aug 20, 2013
Aug 20, 2013
638
if (fanartfile.isEmpty() || !RemoteFile::Exists(fanartfile))
Mar 9, 2009
Mar 9, 2009
639
m_fanart = VIDEO_FANART_DEFAULT;
Dec 23, 2008
Dec 23, 2008
640
641
if (m_trailer.isEmpty())
m_trailer = VIDEO_TRAILER_DEFAULT;
Sep 23, 2008
Sep 23, 2008
642
if (m_inetref.isEmpty())
Aug 19, 2006
Aug 19, 2006
643
m_inetref = VIDEO_INETREF_DEFAULT;
Oct 2, 2020
Oct 2, 2020
644
if (std::isnan(m_userrating))
Aug 19, 2006
Aug 19, 2006
645
m_userrating = 0.0;
Mar 26, 2019
Mar 26, 2019
646
if (m_userrating < -10.0F || m_userrating > 10.0F)
Aug 19, 2006
Aug 19, 2006
647
m_userrating = 0.0;
Nov 11, 2009
Nov 11, 2009
648
649
if (m_releasedate.toString().isEmpty())
m_releasedate = QDate::fromString("0000-00-00", "YYYY-MM-DD");
Feb 12, 2012
Feb 12, 2012
650
651
652
653
654
655
656
if (m_contenttype == kContentUnknown)
{
if (m_season > 0 || m_episode > 0)
m_contenttype = kContentTelevision;
else
m_contenttype = kContentMovie;
}
Aug 19, 2006
Aug 19, 2006
657
658
bool inserting = m_id == 0;
Dec 10, 2002
Dec 10, 2002
659
Feb 23, 2005
Feb 23, 2005
660
MSqlQuery query(MSqlQuery::InitCon());
Dec 10, 2002
Dec 10, 2002
661
Aug 19, 2006
Aug 19, 2006
662
if (inserting)
Dec 10, 2002
Dec 10, 2002
663
{
Sep 12, 2018
Sep 12, 2018
664
m_browse = true;
Jan 27, 2005
Jan 27, 2005
665
Sep 12, 2018
Sep 12, 2018
666
m_watched = false;
Aug 12, 2009
Aug 12, 2009
667
Sep 6, 2010
Sep 6, 2010
668
query.prepare("INSERT INTO videometadata (title,subtitle,tagline,director,studio,plot,"
Nov 20, 2009
Nov 20, 2009
669
"rating,year,userrating,length,season,episode,filename,hash,"
Nov 11, 2009
Nov 11, 2009
670
"showlevel,coverfile,inetref,homepage,browse,watched,trailer,"
Feb 12, 2012
Feb 12, 2012
671
"screenshot,banner,fanart,host,processed,contenttype) VALUES (:TITLE, :SUBTITLE, "
Sep 6, 2010
Sep 6, 2010
672
":TAGLINE, :DIRECTOR, :STUDIO, :PLOT, :RATING, :YEAR, :USERRATING, "
Nov 20, 2009
Nov 20, 2009
673
674
":LENGTH, :SEASON, :EPISODE, :FILENAME, :HASH, :SHOWLEVEL, "
":COVERFILE, :INETREF, :HOMEPAGE, :BROWSE, :WATCHED, "
Feb 12, 2012
Feb 12, 2012
675
":TRAILER, :SCREENSHOT, :BANNER, :FANART, :HOST, :PROCESSED, :CONTENTTYPE)");
Jul 23, 2005
Jul 23, 2005
676
}
Aug 19, 2006
Aug 19, 2006
677
else
Dec 10, 2002
Dec 10, 2002
678
{
Aug 4, 2009
Aug 4, 2009
679
query.prepare("UPDATE videometadata SET title = :TITLE, subtitle = :SUBTITLE, "
Sep 6, 2010
Sep 6, 2010
680
681
682
"tagline = :TAGLINE, director = :DIRECTOR, studio = :STUDIO, "
"plot = :PLOT, rating= :RATING, year = :YEAR, "
"releasedate = :RELEASEDATE, userrating = :USERRATING, "
Feb 12, 2012
Feb 12, 2012
683
684
"length = :LENGTH, playcount = :PLAYCOUNT, season = :SEASON, "
"episode = :EPISODE, filename = :FILENAME, hash = :HASH, trailer = :TRAILER, "
Aug 19, 2006
Aug 19, 2006
685
"showlevel = :SHOWLEVEL, coverfile = :COVERFILE, "
Mar 9, 2009
Mar 9, 2009
686
"screenshot = :SCREENSHOT, banner = :BANNER, fanart = :FANART, "
Feb 12, 2012
Feb 12, 2012
687
688
689
690
"inetref = :INETREF, collectionref = :COLLECTION, homepage = :HOMEPAGE, "
"browse = :BROWSE, watched = :WATCHED, host = :HOST, playcommand = :PLAYCOMMAND, "
"childid = :CHILDID, category = :CATEGORY, processed = :PROCESSED, "
"contenttype = :CONTENTTYPE WHERE intid = :INTID");
Aug 19, 2006
Aug 19, 2006
691
Apr 3, 2008
Apr 3, 2008
692
query.bindValue(":PLAYCOMMAND", m_playcommand);
Aug 19, 2006
Aug 19, 2006
693
694
695
query.bindValue(":CHILDID", m_childID);
query.bindValue(":CATEGORY", m_categoryID);
query.bindValue(":INTID", m_id);
Aug 27, 2004
Aug 27, 2004
696
697
}
Nov 5, 2021
Nov 5, 2021
698
699
query.bindValueNoNull(":TITLE", m_title);
query.bindValueNoNull(":SUBTITLE", m_subtitle);
May 9, 2010
May 9, 2010
700
query.bindValue(":TAGLINE", m_tagline);
Nov 5, 2021
Nov 5, 2021
701
query.bindValueNoNull(":DIRECTOR", m_director);
Sep 6, 2010
Sep 6, 2010
702
query.bindValue(":STUDIO", m_studio);
Apr 3, 2008
Apr 3, 2008
703
query.bindValue(":PLOT", m_plot);
Nov 5, 2021
Nov 5, 2021
704
query.bindValueNoNull(":RATING", m_rating);
Aug 19, 2006
Aug 19, 2006
705
query.bindValue(":YEAR", m_year);
Nov 11, 2009
Nov 11, 2009
706
query.bindValue(":RELEASEDATE", m_releasedate);
Aug 19, 2006
Aug 19, 2006
707
query.bindValue(":USERRATING", m_userrating);
Jan 25, 2021
Jan 25, 2021
708
query.bindValue(":LENGTH", static_cast<qint64>(m_length.count()));
Feb 12, 2012
Feb 12, 2012
709
query.bindValue(":PLAYCOUNT", m_playcount);
Aug 4, 2009
Aug 4, 2009
710
711
query.bindValue(":SEASON", m_season);
query.bindValue(":EPISODE", m_episode);
Apr 3, 2008
Apr 3, 2008
712
query.bindValue(":FILENAME", m_filename);
Nov 20, 2009
Nov 20, 2009
713
query.bindValue(":HASH", m_hash);
Nov 5, 2021
Nov 5, 2021
714
query.bindValueNoNull(":TRAILER", m_trailer);
Aug 19, 2006
Aug 19, 2006
715
query.bindValue(":SHOWLEVEL", m_showlevel);
Nov 5, 2021
Nov 5, 2021
716
717
718
719
720
query.bindValueNoNull(":COVERFILE", m_coverfile);
query.bindValueNoNull(":SCREENSHOT", m_screenshot);
query.bindValueNoNull(":BANNER", m_banner);
query.bindValueNoNull(":FANART", m_fanart);
query.bindValueNoNull(":INETREF", m_inetref);
Feb 12, 2012
Feb 12, 2012
721
query.bindValue(":COLLECTION", m_collectionref);
Nov 5, 2021
Nov 5, 2021
722
query.bindValueNoNull(":HOMEPAGE", m_homepage);
Aug 19, 2006
Aug 19, 2006
723
query.bindValue(":BROWSE", m_browse);
Aug 12, 2009
Aug 12, 2009
724
query.bindValue(":WATCHED", m_watched);
Feb 12, 2009
Feb 12, 2009
725
query.bindValue(":HOST", m_host);
Jun 5, 2010
Jun 5, 2010
726
query.bindValue(":PROCESSED", m_processed);
Feb 12, 2012
Feb 12, 2012
727
query.bindValue(":CONTENTTYPE", ContentTypeToString(m_contenttype));
Dec 10, 2002
Dec 10, 2002
728
Aug 19, 2006
Aug 19, 2006
729
if (!query.exec() || !query.isActive())
Oct 27, 2003
Oct 27, 2003
730
{
Aug 28, 2008
Aug 28, 2008
731
MythDB::DBError("video metadata update", query);
Aug 19, 2004
Aug 19, 2004
732
733
734
return;
}
Aug 19, 2006
Aug 19, 2006
735
if (inserting)
Aug 19, 2004
Aug 19, 2004
736
{
Aug 19, 2006
Aug 19, 2006
737
738
// Must make sure we have 'id' filled before we call updateGenres or
// updateCountries
Aug 19, 2004
Aug 19, 2004
739
Jul 17, 2009
Jul 17, 2009
740
if (!query.exec("SELECT LAST_INSERT_ID()") || !query.next())
Aug 19, 2006
Aug 19, 2006
741
{
Aug 28, 2008
Aug 28, 2008
742
MythDB::DBError("metadata id get", query);
Aug 19, 2006
Aug 19, 2006
743
744
return;
}
Aug 19, 2004
Aug 19, 2004
745
Aug 19, 2006
Aug 19, 2006
746
747
748
749
m_id = query.value(0).toUInt();
if (0 == m_id)
{
Jul 3, 2011
Jul 3, 2011
750
751
752
LOG(VB_GENERAL, LOG_ERR,
QString("%1: The id of the last inserted row to "
"videometadata seems to be 0. This is odd.")
Aug 19, 2006
Aug 19, 2006
753
754
755
.arg(__FILE__));
return;
}
Aug 19, 2004
Aug 19, 2004
756
}
May 27, 2003
May 27, 2003
757
Feb 23, 2005
Feb 23, 2005
758
759
updateGenres();
updateCountries();
Feb 11, 2008
Feb 11, 2008
760
updateCast();
May 27, 2003
May 27, 2003
761
762
}
Aug 30, 2010
Aug 30, 2010
763
void VideoMetadataImp::SaveToDatabase()
Jul 12, 2003
Jul 12, 2003
764
{
Aug 19, 2006
Aug 19, 2006
765
saveToDatabase();
Sep 9, 2004
Sep 9, 2004
766
767
}
Aug 30, 2010
Aug 30, 2010
768
void VideoMetadataImp::UpdateDatabase()
Sep 9, 2004
Sep 9, 2004
769
{
Aug 19, 2006
Aug 19, 2006
770
771
saveToDatabase();
}
Feb 7, 2004
Feb 7, 2004
772
Aug 30, 2010
Aug 30, 2010
773
bool VideoMetadataImp::DeleteFromDatabase()
Mar 9, 2009
Mar 9, 2009
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
{
VideoGenreMap::getGenreMap().remove(m_id);
VideoCountryMap::getCountryMap().remove(m_id);
VideoCastMap::getCastMap().remove(m_id);
MSqlQuery query(MSqlQuery::InitCon());
query.prepare("DELETE FROM videometadata WHERE intid = :ID");
query.bindValue(":ID", m_id);
if (!query.exec())
{
MythDB::DBError("delete from videometadata", query);
}
query.prepare("DELETE FROM filemarkup WHERE filename = :FILENAME");
query.bindValue(":FILENAME", m_filename);
if (!query.exec())
{
MythDB::DBError("delete from filemarkup", query);
}
return true;
}
Aug 30, 2010
Aug 30, 2010
797
void VideoMetadataImp::SetCategoryID(int id)
Aug 19, 2006
Aug 19, 2006
798
799
800
801
802
803
804
805
806
{
if (id == 0)
{
m_category = "";
m_categoryID = id;
}
else
{
if (m_categoryID != id)
Sep 9, 2004
Sep 9, 2004
807
{
Aug 19, 2006
Aug 19, 2006
808
QString cat;
Mar 9, 2009
Mar 9, 2009
809
if (VideoCategory::GetCategory().get(id, cat))
Sep 9, 2004
Sep 9, 2004
810
{
Aug 19, 2006
Aug 19, 2006
811
812
m_category = cat;
m_categoryID = id;
Sep 9, 2004
Sep 9, 2004
813
}
Aug 19, 2006
Aug 19, 2006
814
else
Sep 9, 2004
Sep 9, 2004
815
{
Jul 3, 2011
Jul 3, 2011
816
LOG(VB_GENERAL, LOG_ERR, "Unknown category id");
Sep 9, 2004
Sep 9, 2004
817
818
819
}
}
}
Jul 12, 2003
Jul 12, 2003
820
821
}
Aug 30, 2010
Aug 30, 2010
822
void VideoMetadataImp::updateGenres()
May 27, 2003
May 27, 2003
823
{
Aug 19, 2006
Aug 19, 2006
824
VideoGenreMap::getGenreMap().remove(m_id);
Mar 2, 2004
Mar 2, 2004
825
Aug 19, 2006
Aug 19, 2006
826
// ensure that all genres we have are in the DB
Dec 2, 2019
Dec 2, 2019
827
auto genre = m_genres.begin();
Aug 23, 2006
Aug 23, 2006
828
while (genre != m_genres.end())
Sep 2, 2003
Sep 2, 2003
829
{
Mar 19, 2019
Mar 19, 2019
830
if (!genre->second.trimmed().isEmpty())
Aug 23, 2006
Aug 23, 2006
831
832
833
834
835
836
837
838
839
{
genre->first = VideoGenre::getGenre().add(genre->second);
VideoGenreMap::getGenreMap().add(m_id, genre->first);
++genre;
}
else
{
genre = m_genres.erase(genre);
}
Sep 2, 2003
Sep 2, 2003
840
}
Mar 2, 2004
Mar 2, 2004
841
842
}
Aug 30, 2010
Aug 30, 2010
843
void VideoMetadataImp::updateCountries()
Aug 19, 2006
Aug 19, 2006
844
845
846
{
// remove countries for this video
VideoCountryMap::getCountryMap().remove(m_id);
Oct 4, 2005
Oct 4, 2005
847
Dec 2, 2019
Dec 2, 2019
848
auto country = m_countries.begin();
Aug 23, 2006
Aug 23, 2006
849
while (country != m_countries.end())
Aug 19, 2006
Aug 19, 2006
850
{
Mar 19, 2019
Mar 19, 2019
851
if (!country->second.trimmed().isEmpty())
Aug 23, 2006
Aug 23, 2006
852
853
854
855
856
857
858
859
860
{
country->first = VideoCountry::getCountry().add(country->second);
VideoCountryMap::getCountryMap().add(m_id, country->first);
++country;
}
else
{
country = m_countries.erase(country);
}
Aug 19, 2006
Aug 19, 2006
861
862
}
}
Oct 4, 2005
Oct 4, 2005
863
Aug 30, 2010
Aug 30, 2010
864
void VideoMetadataImp::updateCast()
Feb 11, 2008
Feb 11, 2008
865
866
867
868
{
VideoCastMap::getCastMap().remove(m_id);
// ensure that all cast we have are in the DB
Dec 2, 2019
Dec 2, 2019
869
auto cast = m_cast.begin();
Feb 11, 2008
Feb 11, 2008
870
871
while (cast != m_cast.end())
{
Mar 19, 2019
Mar 19, 2019
872
if (!cast->second.trimmed().isEmpty())
Feb 11, 2008
Feb 11, 2008
873
{
Mar 9, 2009
Mar 9, 2009
874
cast->first = VideoCast::GetCast().add(cast->second);
Feb 11, 2008
Feb 11, 2008
875
876
877
878
879
880
881
882
883
884
VideoCastMap::getCastMap().add(m_id, cast->first);
++cast;
}
else
{
cast = m_cast.erase(cast);
}
}
}
Aug 20, 2013
Aug 20, 2013
885
886
887
888
void VideoMetadataImp::GetImageMap(InfoMap &imageMap) const
{
QString coverfile;
if (IsHostSet()
Sep 11, 2021
Sep 11, 2021
889
&& !GetCoverFile().startsWith(u'/')
Aug 20, 2013
Aug 20, 2013
890
891
892
&& !GetCoverFile().isEmpty()
&& !IsDefaultCoverFile(GetCoverFile()))
{
Sep 11, 2021
Sep 11, 2021
893
coverfile = generate_file_url(QStringLiteral(u"Coverart"), GetHost(),
Aug 20, 2013
Aug 20, 2013
894
895
896
897
898
899
900
GetCoverFile());
}
else
{
coverfile = GetCoverFile();
}
Sep 11, 2021
Sep 11, 2021
901
902
imageMap[QStringLiteral(u"coverfile")] = coverfile;
imageMap[QStringLiteral(u"coverart")] = coverfile;
Aug 20, 2013
Aug 20, 2013
903
904
QString screenshotfile;
Sep 11, 2021
Sep 11, 2021
905
if (IsHostSet() && !GetScreenshot().startsWith(u'/')
Aug 20, 2013
Aug 20, 2013
906
907
&& !GetScreenshot().isEmpty())
{
Sep 11, 2021
Sep 11, 2021
908
screenshotfile = generate_file_url(QStringLiteral(u"Screenshots"),
Aug 20, 2013
Aug 20, 2013
909
910
911
912
913
914
915
GetHost(), GetScreenshot());
}
else
{
screenshotfile = GetScreenshot();
}
Sep 11, 2021
Sep 11, 2021
916
917
imageMap[QStringLiteral(u"screenshotfile")] = screenshotfile;
imageMap[QStringLiteral(u"screenshot")] = screenshotfile;
Aug 20, 2013
Aug 20, 2013
918
919
QString bannerfile;
Sep 11, 2021
Sep 11, 2021
920
if (IsHostSet() && !GetBanner().startsWith(u'/')
Aug 20, 2013
Aug 20, 2013
921
922
&& !GetBanner().isEmpty())
{
Sep 11, 2021
Sep 11, 2021
923
bannerfile = generate_file_url(QStringLiteral(u"Banners"), GetHost(),
Aug 20, 2013
Aug 20, 2013
924
925
926
927
928
929
930
GetBanner());
}
else
{
bannerfile = GetBanner();
}
Sep 11, 2021
Sep 11, 2021
931
932
imageMap[QStringLiteral(u"bannerfile")] = bannerfile;
imageMap[QStringLiteral(u"banner")] = bannerfile;
Aug 20, 2013
Aug 20, 2013
933
934
QString fanartfile;
Sep 11, 2021
Sep 11, 2021
935
if (IsHostSet() && !GetFanart().startsWith('/')
Aug 20, 2013
Aug 20, 2013
936
937
&& !GetFanart().isEmpty())
{
Sep 11, 2021
Sep 11, 2021
938
fanartfile = generate_file_url(QStringLiteral(u"Fanart"), GetHost(),
Aug 20, 2013
Aug 20, 2013
939
940
941
942
943
944
945
GetFanart());
}
else
{
fanartfile = GetFanart();
}
Sep 11, 2021
Sep 11, 2021
946
947
imageMap[QStringLiteral(u"fanartfile")] = fanartfile;
imageMap[QStringLiteral(u"fanart")] = fanartfile;
Aug 20, 2013
Aug 20, 2013
948
949
950
951
QString smartimage = coverfile;
if (!screenshotfile.isEmpty () && (GetSeason() > 0 || GetEpisode() > 0))
smartimage = screenshotfile;
Sep 11, 2021
Sep 11, 2021
952
imageMap[QStringLiteral(u"smartimage")] = smartimage;
Aug 20, 2013
Aug 20, 2013
953
954
}
Sep 11, 2021
Sep 11, 2021
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This should be the equivalent of GetImageMap, only the image names
// are computed one at a time as needed.
QString VideoMetadataImp::GetImage(const QString& name) const
{
if ((name == QStringLiteral(u"coverfile")) ||
(name == QStringLiteral(u"coverart")))
{
QString coverfile = GetCoverFile();
if (IsHostSet()
&& !coverfile.startsWith(u'/')
&& !coverfile.isEmpty()
&& !IsDefaultCoverFile(coverfile))
return generate_file_url(QStringLiteral(u"Coverart"), GetHost(),
coverfile);
return coverfile;
}
if ((name == QStringLiteral(u"screenshotfile")) ||
(name == QStringLiteral(u"screenshot")))
{
QString screenshot = GetScreenshot();
if (IsHostSet() && !screenshot.startsWith(u'/')
&& !screenshot.isEmpty())
return generate_file_url(QStringLiteral(u"Screenshots"),
GetHost(), screenshot);
return screenshot;
}
if ((name == QStringLiteral(u"bannerfile")) ||
(name == QStringLiteral(u"banner")))
{
QString bannerfile = GetBanner();
if (IsHostSet() && !bannerfile.startsWith(u'/')
&& !bannerfile.isEmpty())
return generate_file_url(QStringLiteral(u"Banners"), GetHost(),
bannerfile);
return bannerfile;
}
if ((name == QStringLiteral(u"fanartfile")) ||
(name == QStringLiteral(u"fanart")))
{
QString fanartfile = GetFanart();
if (IsHostSet() && !fanartfile.startsWith('/')
&& !fanartfile.isEmpty())
return generate_file_url(QStringLiteral(u"Fanart"), GetHost(),