MythTV  master
metadatadownload.h
Go to the documentation of this file.
1 #ifndef METADATADOWNLOAD_H
2 #define METADATADOWNLOAD_H
3 
4 #include <QStringList>
5 #include <QMutex>
6 #include <QEvent>
7 
8 #include "metadatacommon.h"
9 #include "mthread.h"
10 
11 class META_PUBLIC MetadataLookupEvent : public QEvent
12 {
13  public:
14  explicit MetadataLookupEvent(MetadataLookupList lul) : QEvent(kEventType),
15  m_lookupList(lul) {}
16  ~MetadataLookupEvent() = default;
17 
19 
20  static Type kEventType;
21 };
22 
23 class META_PUBLIC MetadataLookupFailure : public QEvent
24 {
25  public:
26  explicit MetadataLookupFailure(MetadataLookupList lul) : QEvent(kEventType),
27  m_lookupList(lul) {}
28  ~MetadataLookupFailure() = default;
29 
31 
32  static Type kEventType;
33 };
34 
36 {
37  public:
38 
39  explicit MetadataDownload(QObject *parent)
40  : MThread("MetadataDownload"), m_parent(parent) {}
42 
43  void addLookup(MetadataLookup *lookup);
44  void prependLookup(MetadataLookup *lookup);
45  void cancel();
46 
47  static QString GetMovieGrabber();
48  static QString GetTelevisionGrabber();
49  static QString GetGameGrabber();
50 
51  bool runGrabberTest(const QString &grabberpath);
52  bool MovieGrabberWorks();
53  bool TelevisionGrabberWorks();
54 
55  protected:
56 
57  void run() override; // MThread
58 
59  QString getMXMLPath(const QString& filename);
60  QString getNFOPath(const QString& filename);
61 
62  private:
63  // Video handling
64  MetadataLookupList handleMovie(MetadataLookup* lookup);
65  MetadataLookupList handleTelevision(MetadataLookup* lookup);
66  MetadataLookupList handleVideoUndetermined(MetadataLookup* lookup);
67  MetadataLookupList handleRecordingGeneric(MetadataLookup* lookup);
68 
69  MetadataLookupList handleGame(MetadataLookup* lookup);
70 
71  unsigned int findExactMatchCount(MetadataLookupList list,
72  const QString &originaltitle,
73  bool withArt) const;
74  MetadataLookup* findBestMatch(MetadataLookupList list,
75  const QString &originaltitle) const;
76  MetadataLookupList runGrabber(const QString& cmd, const QStringList& args,
77  MetadataLookup* lookup,
78  bool passseas = true);
79  MetadataLookupList readMXML(const QString& MXMLpath,
80  MetadataLookup* lookup,
81  bool passseas = true);
82  MetadataLookupList readNFO(const QString& NFOpath, MetadataLookup* lookup);
83 
84  QObject *m_parent {nullptr};
86  QMutex m_mutex;
87 };
88 
89 #endif /* METADATADOWNLOAD_H */
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
virtual void run(void)
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: mthread.cpp:318
MetadataDownload(QObject *parent)
MetadataLookupList m_lookupList
#define META_PUBLIC
Definition: mythmetaexp.h:9
MetadataLookupList m_lookupList
MetadataLookupFailure(MetadataLookupList lul)
MetadataLookupEvent(MetadataLookupList lul)
MetadataLookupList m_lookupList