MythTV  master
metadatacommon.h
Go to the documentation of this file.
1 #ifndef METADATACOMMON_H_
2 #define METADATACOMMON_H_
3 
4 #include <QList>
5 #include <QPair>
6 #include <QMultiMap>
7 #include <QString>
8 #include <QStringList>
9 #include <QDateTime>
10 #include <QDate>
11 #include <QDomElement>
12 #include <QEvent>
13 
14 #include "mythtypes.h"
15 #include "mythmetaexp.h"
16 #include "metadataimagehelper.h"
17 #include "referencecounterlist.h"
18 #include "metadatagrabber.h"
19 
20 class ProgramInfo;
21 
22 enum LookupStep {
26 };
27 
28 struct PersonInfo
29 {
30  QString name;
31  QString role;
32  QString thumbnail;
33  QString url;
34 };
35 
36 // What type of grabber script to use
42 };
43 
44 // Determines the lookup fallback strategy
45 enum LookupType {
52 };
53 
54 // Actual type of content
62 };
63 
64 enum PeopleType {
77 };
78 
79 typedef QMap< VideoArtworkType, ArtworkInfo > DownloadMap;
80 
81 typedef QMultiMap< PeopleType, PersonInfo > PeopleMap;
82 
83 class META_PUBLIC MetadataLookup : public QObject, public ReferenceCounter
84 {
85  public:
86  MetadataLookup(void) : ReferenceCounter("MetadataLookup") {}
87  ~MetadataLookup() = default;
88 
91  LookupType subtype,
92  QVariant data,
93  LookupStep step,
94  bool automatic,
95  bool handleimages,
96  bool allowoverwrites,
97  bool allowgeneric,
98  bool preferdvdorder,
99  const QString &host,
100  const QString &filename,
101  const QString &title,
102  const QString &network,
103  const QString &status,
104  const QStringList &categories,
105  const float userrating,
106  uint ratingcount,
107  const QString &language,
108  const QString &subtitle,
109  const QString &tagline,
110  const QString &description,
111  uint season,
112  uint episode,
113  const uint chanid,
114  const QString &channum,
115  const QString &chansign,
116  const QString &channame,
117  const QString &chanplaybackfilters,
118  const QString &recgroup,
119  const QString &playgroup,
120  const QString &seriesid,
121  const QString &programid,
122  const QString &storagegroup,
123  const QDateTime &startts,
124  const QDateTime &endts,
125  const QDateTime &recstartts,
126  const QDateTime &recendts,
127  const uint programflags,
128  const uint audioproperties,
129  const uint videoproperties,
130  const uint subtitletype,
131  const QString &certification,
132  const QStringList &countries,
133  const float popularity,
134  const uint budget,
135  const uint revenue,
136  const QString &album,
137  uint tracknum,
138  const QString &system,
139  const uint year,
140  const QDate &releasedate,
141  const QDateTime &lastupdated,
142  const uint runtime,
143  const uint runtimesecs,
144  const QString &inetref,
145  const QString &collectionref,
146  const QString &tmsref,
147  const QString &imdb,
148  const PeopleMap& people,
149  const QStringList &studios,
150  const QString &homepage,
151  const QString &trailerURL,
152  const ArtworkMap& artwork,
153  DownloadMap downloads);
154 
155  //ProgramInfo Constructor
158  LookupType subtype,
159  QVariant data,
160  LookupStep step,
161  bool automatic,
162  bool handleimages,
163  bool allowoverwrites,
164  bool allowgeneric,
165  bool preferdvdorder,
166  const QString &host,
167  const QString &filename,
168  const QString &title,
169  const QStringList &categories,
170  const float userrating,
171  const QString &subtitle,
172  const QString &description,
173  uint chanid,
174  const QString &channum,
175  const QString &chansign,
176  const QString &channame,
177  const QString &chanplaybackfilters,
178  const QString &recgroup,
179  const QString &playgroup,
180  const QString &seriesid,
181  const QString &programid,
182  const QString &storagegroup,
183  const QDateTime &startts,
184  const QDateTime &endts,
185  const QDateTime &recstartts,
186  const QDateTime &recendts,
187  uint programflags,
188  uint audioproperties,
189  uint videoproperties,
190  uint subtitletype,
191  const uint year,
192  const QDate &releasedate,
193  const QDateTime &lastupdated,
194  const uint runtime,
195  const uint runtimesecs);
196 
197  // XBMC NFO Constructor
200  LookupType subtype,
201  QVariant data,
202  LookupStep step,
203  bool automatic,
204  bool handleimages,
205  bool allowoverwrites,
206  bool allowgeneric,
207  bool preferdvdorder,
208  const QString &host,
209  const QString &filename,
210  const QString &title,
211  const QStringList &categories,
212  const float userrating,
213  const QString &subtitle,
214  const QString &tagline,
215  const QString &description,
216  uint season,
217  uint episode,
218  const QString &certification,
219  const uint year,
220  const QDate releasedate,
221  const uint runtime,
222  const uint runtimesecs,
223  const QString &inetref,
224  const PeopleMap& people,
225  const QString &trailerURL,
226  const ArtworkMap& artwork,
227  DownloadMap downloads);
228 
229  void toMap(InfoMap &map);
230 
231  // SETS (Only a limited number needed)
232 
233  // Must set a type, data, and step.
234  void SetType(MetadataType type) { m_type = type; };
235  // For some lookup, it helps to know the subtype (TV vs. Movie)
236  void SetSubtype(LookupType subtype) { m_subtype = subtype; };
237  // Reference value- when the event comes back, need to associate with an item.
238  void SetData(QVariant data) { m_data = data; };
239  // Steps: SEARCH, GETDATA
240  void SetStep(LookupStep step) { m_step = step; };
241  // Don't prompt the user, just make an educated decision.
242  void SetAutomatic(bool autom) { m_automatic = autom; };
243 
244  // Sets for image download handling
245  void SetHandleImages(bool handle) { m_handleimages = handle; };
246  void SetAllowOverwrites(bool allow) { m_allowoverwrites = allow; };
247  void SetAllowGeneric(bool allow) { m_allowgeneric = allow; };
248  void SetHost(const QString &host) { m_host = host; };
249  void SetDownloads(ArtworkMap map) { m_downloads = map; };
250 
251  // General Sets
252  void SetTitle(const QString &title)
253  {
254  m_title = title;
255  QString manRecSuffix = QString(" (%1)").arg(QObject::tr("Manual Record"));
256  m_base_title = title; // m_title with " (Manual Record)" stripped.
257  m_base_title.replace(manRecSuffix,"");
258  };
259  void SetFilename(const QString &filename) { m_filename = filename; };
260 
261  // General Sets - Video
262  void SetSubtitle(const QString &subtitle) { m_subtitle = subtitle; };
263  void SetSeason(uint season) { m_season = season; };
264  void SetEpisode(uint episode) { m_episode = episode; };
265  void SetInetref(const QString &inetref) { m_inetref = inetref; };
266  void SetCollectionref(const QString &collectionref)
267  { m_collectionref = collectionref; };
268  void SetTMSref(const QString &tmsref) { m_tmsref = tmsref; };
269  void SetIsCollection(bool collection) { m_iscollection = collection; };
270  void SetPreferDVDOrdering(bool preferdvdorder)
271  { m_dvdorder = preferdvdorder; };
272 
273  // General Sets - Music
274  void SetAlbum(const QString &album) { m_album = album; };
275  void SetTrack(uint track) { m_tracknum = track; };
276 
277  // General Sets - Games
278  void SetSystem(const QString &system) { m_system = system; };
279 
280  // GETS
281 
282  MetadataType GetType() const { return m_type; };
283  LookupType GetSubtype() const { return m_subtype; };
284  QVariant GetData() const { return m_data; };
285  LookupStep GetStep() const { return m_step; };
286  bool GetAutomatic() const { return m_automatic; };
287 
288  // Image Handling Gets
289  bool GetHandleImages() const { return m_handleimages; };
290  bool GetAllowOverwrites() const { return m_allowoverwrites; };
291  bool GetAllowGeneric() const { return m_allowgeneric; };
292 
293  // General
294  QString GetFilename() const { return m_filename; };
295  QString GetTitle() const { return m_title; };
296  QString GetBaseTitle() const { return m_base_title; };
297  QStringList GetCategories() const { return m_categories; };
298  float GetUserRating() const { return m_userrating; };
299  uint GetRatingCount() const { return m_ratingcount; };
300  QString GetLanguage() const { return m_language; };
301  QString GetHost() const { return m_host; };
302 
303  // General - Video & ProgramInfo
304  QString GetNetwork() const { return m_network; };
305  QString GetStatus() const { return m_status; };
306  QString GetSubtitle() const { return m_subtitle; };
307  QString GetTagline() const { return m_tagline; };
308  QString GetDescription() const { return m_description; };
309  bool GetPreferDVDOrdering() const { return m_dvdorder; };
310  uint GetSeason() const { return m_season; };
311  uint GetEpisode() const { return m_episode; };
312  uint GetChanId() const { return m_chanid; };
313  QString GetChanNum() const { return m_channum; };
314  QString GetChanSign() const { return m_chansign; };
315  QString GetChanName() const { return m_channame; };
316  QString GetChanPlaybackFilters() const { return m_chanplaybackfilters; };
317  QString GetRecGroup() const { return m_recgroup; };
318  QString GetPlayGroup() const { return m_playgroup; };
319  QString GetSeriesId() const { return m_seriesid; };
320  QString GetProgramId() const { return m_programid; };
321  QString GetStorageGroup() const { return m_storagegroup; };
322  QDateTime GetStartTS() const { return m_startts; };
323  QDateTime GetEndTS() const { return m_endts; };
324  QDateTime GetRecStartTS() const { return m_recstartts; };
325  QDateTime GetRecEndTS() const { return m_recendts; };
326  uint GetProgramFlags() const { return m_programflags; };
327  uint GetAudioProperties() const { return m_audioproperties; };
328  uint GetVideoProperties() const { return m_videoproperties; };
329  uint GetSubtitleType() const { return m_subtitletype; };
330 
331  QString GetCertification() const { return m_certification; };
332  QStringList GetCountries() const { return m_countries; };
333  float GetPopularity() const { return m_popularity; };
334  uint GetBudget() const { return m_budget; };
335  uint GetRevenue() const { return m_revenue; };
336 
337  // General - Music
338  QString GetAlbumTitle() const { return m_album; };
339  uint GetTrackNumber() const { return m_tracknum; };
340 
341  // General - Game
342  QString GetSystem() const { return m_system; };
343 
344  // Times
345  uint GetYear() const { return m_year; };
346  QDate GetReleaseDate() const { return m_releasedate; };
347  QDateTime GetLastUpdated() const { return m_lastupdated; };
348  uint GetRuntime() const { return m_runtime; };
349  uint GetRuntimeSeconds() const { return m_runtimesecs; };
350 
351  // Inetref
352  QString GetInetref() const { return m_inetref; };
353  QString GetCollectionref() const { return m_collectionref; };
354  QString GetIMDB() const { return m_imdb; };
355  QString GetTMSref() const { return m_tmsref; };
356  bool GetIsCollection() const { return m_iscollection; };
357 
358  // People
359  QList<PersonInfo> GetPeople(PeopleType type) const;
360  QStringList GetStudios() const { return m_studios; };
361 
362  // Web references
363  QString GetHomepage() const { return m_homepage; };
364  QString GetTrailerURL() const { return m_trailerURL; };
365 
366  // Artwork
368  DownloadMap GetDownloads() const { return m_downloads; };
369 
370  private:
371  // General
374  QVariant m_data;
376  bool m_automatic {false};
377  bool m_handleimages {false};
378  bool m_allowoverwrites {false};
379  bool m_allowgeneric {false};
380  bool m_dvdorder {false};
381  QString m_host;
382 
383  QString m_filename;
384  QString m_title;
385  QString m_base_title; // m_title with " (Manual Record)" stripped.
386  QString m_network;
387  QString m_status;
388  const QStringList m_categories;
389  float m_userrating {0.0};
390  uint m_ratingcount {0};
391  const QString m_language;
392 
393  // General - Video & ProgramInfo
394  QString m_subtitle;
395  const QString m_tagline;
396  const QString m_description;
397  uint m_season {0};
398  uint m_episode {0};
399  uint m_chanid {0};
400  const QString m_channum;
401  const QString m_chansign;
402  const QString m_channame;
403  const QString m_chanplaybackfilters;
404  const QString m_recgroup;
405  const QString m_playgroup;
406  const QString m_seriesid;
407  const QString m_programid;
408  const QString m_storagegroup;
409  const QDateTime m_startts;
410  const QDateTime m_endts;
411  const QDateTime m_recstartts;
412  const QDateTime m_recendts;
413  uint m_programflags {0};
414  uint m_audioproperties {0};
415  uint m_videoproperties {0};
416  uint m_subtitletype {0};
417 
418  const QString m_certification;
419  const QStringList m_countries;
420  float m_popularity {0};
421  uint m_budget {0};
422  uint m_revenue {0};
423 
424  // General - Music
425  QString m_album;
426  uint m_tracknum {0};
427 
428  // General - Game
429  QString m_system;
430 
431  // Times
432  uint m_year {0};
433  const QDate m_releasedate;
434  const QDateTime m_lastupdated;
435  uint m_runtime {0};
436  uint m_runtimesecs {0};
437 
438  // Inetref
439  QString m_inetref;
441  QString m_tmsref;
442  QString m_imdb;
443  bool m_iscollection {false};
444 
445  // People - Video
447  const QStringList m_studios;
448 
449  // Web references
450  const QString m_homepage;
451  const QString m_trailerURL;
452 
453  // Artwork
456 };
457 
459 
461 META_PUBLIC QDomDocument CreateMetadataXML(MetadataLookup *lookup);
462 META_PUBLIC QDomDocument CreateMetadataXML(ProgramInfo *pginfo);
463 
465  QDomElement placetoadd,
466  QDomDocument docroot);
467 
469  QDomElement placetoadd,
470  QDomDocument docroot);
472  QDomElement placetoadd,
473  QDomDocument docroot);
475  QDomElement placetoadd,
476  QDomDocument docroot);
478  QDomElement placetoadd,
479  QDomDocument docroot);
480 
482 
483 META_PUBLIC MetadataLookup *ParseMetadataItem(const QDomElement &item,
484  MetadataLookup *lookup,
485  bool passseas = true);
486 META_PUBLIC MetadataLookup *ParseMetadataMovieNFO(const QDomElement &item,
487  MetadataLookup *lookup);
488 META_PUBLIC PeopleMap ParsePeople(const QDomElement& people);
489 META_PUBLIC ArtworkMap ParseArtwork(const QDomElement& artwork);
490 
491 META_PUBLIC int editDistance(const QString &s, const QString &t);
492 META_PUBLIC QString nearestName(const QString &actual,
493  const QStringList &candidates);
494 
495 META_PUBLIC QDateTime RFC822TimeToQDateTime(const QString &t);
496 
499 
500 #endif // METADATACOMMON_H_
QStringList GetCategories() const
void SetTitle(const QString &title)
void SetHandleImages(bool handle)
QString GetNetwork() const
META_PUBLIC QDomDocument CreateMetadataXML(MetadataLookupList list)
QString GetChanPlaybackFilters() const
QString GetTrailerURL() const
QString url
void SetSubtitle(const QString &subtitle)
void SetAutomatic(bool autom)
QString GetStatus() const
QString GetSeriesId() const
void SetFilename(const QString &filename)
QString GetIMDB() const
const QString m_storagegroup
uint GetYear() const
MetadataType
const QDate m_releasedate
QString m_base_title
META_PUBLIC int editDistance(const QString &s, const QString &t)
General purpose reference counter.
void SetInetref(const QString &inetref)
void SetData(QVariant data)
bool GetIsCollection() const
QString GetDescription() const
void SetAllowOverwrites(bool allow)
VideoArtworkType
QString GetSystem() const
const QString m_recgroup
QString GetTMSref() const
const QString m_homepage
QString GetChanNum() const
const QString m_language
unsigned int uint
Definition: compat.h:140
uint GetAudioProperties() const
META_PUBLIC void CreateMetadataXMLItem(MetadataLookup *lookup, QDomElement placetoadd, QDomDocument docroot)
QString GetPlayGroup() const
const QString m_chanplaybackfilters
Q_DECLARE_METATYPE(GrabberScript *)
QString name
void SetPreferDVDOrdering(bool preferdvdorder)
uint GetRuntimeSeconds() const
META_PUBLIC MetadataLookup * ParseMetadataMovieNFO(const QDomElement &item, MetadataLookup *lookup)
uint GetTrackNumber() const
QString GetAlbumTitle() const
bool GetAutomatic() const
QString GetSubtitle() const
QStringList GetStudios() const
MetadataType GetType() const
float GetUserRating() const
uint GetSeason() const
QString GetTitle() const
void SetStep(LookupStep step)
const QString m_chansign
META_PUBLIC void AddStudios(MetadataLookup *lookup, QDomElement placetoadd, QDomDocument docroot)
const QStringList m_countries
uint GetEpisode() const
uint GetVideoProperties() const
Holds information on recordings and videos.
Definition: programinfo.h:66
void SetTMSref(const QString &tmsref)
QString GetTagline() const
META_PUBLIC QString nearestName(const QString &actual, const QStringList &candidates)
uint GetRevenue() const
void SetSystem(const QString &system)
LookupStep
const QString m_trailerURL
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
uint GetSubtitleType() const
#define META_PUBLIC
Definition: mythmetaexp.h:9
void SetAllowGeneric(bool allow)
QString GetProgramId() const
QStringList GetCountries() const
META_PUBLIC ArtworkMap ParseArtwork(const QDomElement &artwork)
unsigned char t
Definition: ParseText.cpp:329
META_PUBLIC void AddCertifications(MetadataLookup *lookup, QDomElement placetoadd, QDomDocument docroot)
const QDateTime m_recstartts
float GetPopularity() const
bool GetAllowGeneric() const
QString GetLanguage() const
bool GetAllowOverwrites() const
META_PUBLIC void AddCategories(MetadataLookup *lookup, QDomElement placetoadd, QDomDocument docroot)
const QDateTime m_endts
const QString m_certification
const QString m_description
void SetDownloads(ArtworkMap map)
QString GetInetref() const
bool GetPreferDVDOrdering() const
QString role
LookupType GetSubtype() const
void SetSeason(uint season)
const QString m_channame
void SetCollectionref(const QString &collectionref)
const QDateTime m_recendts
const QString m_channum
QVariant GetData() const
uint GetRatingCount() const
META_PUBLIC void AddCountries(MetadataLookup *lookup, QDomElement placetoadd, QDomDocument docroot)
LookupStep GetStep() const
uint GetChanId() const
QList< ArtworkInfo > ArtworkList
QString thumbnail
QDate GetReleaseDate() const
QMap< VideoArtworkType, ArtworkInfo > DownloadMap
void SetHost(const QString &host)
const ArtworkMap m_artwork
QString GetCollectionref() const
const PeopleMap m_people
const QString m_playgroup
QString GetHomepage() const
void SetSubtype(LookupType subtype)
void SetAlbum(const QString &album)
RefCountedList< MetadataLookup > MetadataLookupList
QDateTime GetLastUpdated() const
const QStringList m_studios
bool GetHandleImages() const
const QString m_tagline
uint GetRuntime() const
void SetType(MetadataType type)
void SetIsCollection(bool collection)
QMultiMap< PeopleType, PersonInfo > PeopleMap
DownloadMap GetDownloads() const
VideoContentType
const QString m_seriesid
uint GetProgramFlags() const
void SetEpisode(uint episode)
QString m_collectionref
QString GetChanSign() const
QDateTime GetRecStartTS() const
QDateTime GetRecEndTS() const
QDateTime GetStartTS() const
QString GetHost() const
QMultiMap< VideoArtworkType, ArtworkInfo > ArtworkMap
META_PUBLIC MetadataLookup * ParseMetadataItem(const QDomElement &item, MetadataLookup *lookup, bool passseas=true)
LookupType
PeopleType
const QDateTime m_lastupdated
META_PUBLIC MetadataLookup * LookupFromProgramInfo(ProgramInfo *pginfo)
const QStringList m_categories
QString GetRecGroup() const
QDateTime GetEndTS() const
void SetTrack(uint track)
META_PUBLIC QDateTime RFC822TimeToQDateTime(const QString &t)
META_PUBLIC PeopleMap ParsePeople(const QDomElement &people)
QString GetFilename() const
const QDateTime m_startts
DownloadMap m_downloads
QString GetCertification() const
ArtworkMap GetArtwork(const QString &inetref, uint season, bool strict)
QString GetChanName() const
const QString m_programid
QString GetStorageGroup() const
QString GetBaseTitle() const
uint GetBudget() const