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  static bool runGrabberTest(const QString &grabberpath);
52  static bool MovieGrabberWorks();
53  static bool TelevisionGrabberWorks();
54 
55  protected:
56 
57  void run() override; // MThread
58 
59  static QString getMXMLPath(const QString& filename);
60  static QString getNFOPath(const QString& filename);
61 
62  private:
63  // Video handling
64  static MetadataLookupList handleMovie(MetadataLookup* lookup);
65  static MetadataLookupList handleTelevision(MetadataLookup* lookup);
66  static MetadataLookupList handleVideoUndetermined(MetadataLookup* lookup);
67  static MetadataLookupList handleRecordingGeneric(MetadataLookup* lookup);
68 
69  static MetadataLookupList handleGame(MetadataLookup* lookup);
70 
71  static unsigned int findExactMatchCount(MetadataLookupList list,
72  const QString &originaltitle,
73  bool withArt) ;
74  static MetadataLookup* findBestMatch(MetadataLookupList list,
75  const QString &originaltitle) ;
76  static MetadataLookupList runGrabber(const QString& cmd,
77  const QStringList& args,
78  MetadataLookup* lookup,
79  bool passseas = true);
80  static MetadataLookupList readMXML(const QString& MXMLpath,
81  MetadataLookup* lookup,
82  bool passseas = true);
83  static MetadataLookupList readNFO(const QString& NFOpath,
84  MetadataLookup* lookup);
85 
86  QObject *m_parent {nullptr};
88  QMutex m_mutex;
89 };
90 
91 #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