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 "libmythbase/mthread.h"
10 
11 class META_PUBLIC MetadataLookupEvent : public QEvent
12 {
13  public:
14  explicit MetadataLookupEvent(const MetadataLookupList& lul) : QEvent(kEventType),
15  m_lookupList(lul) {}
16  ~MetadataLookupEvent() override = default;
17 
19 
20  static const Type kEventType;
21 };
22 
23 class META_PUBLIC MetadataLookupFailure : public QEvent
24 {
25  public:
26  explicit MetadataLookupFailure(const MetadataLookupList& lul) : QEvent(kEventType),
27  m_lookupList(lul) {}
28  ~MetadataLookupFailure() override = default;
29 
31 
32  static const Type kEventType;
33 };
34 
36 {
37  public:
38 
39  explicit MetadataDownload(QObject *parent)
40  : MThread("MetadataDownload"), m_parent(parent) {}
41  ~MetadataDownload() override;
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 */
MetadataDownload::MetadataDownload
MetadataDownload(QObject *parent)
Definition: metadatadownload.h:39
MetadataDownload::m_lookupList
MetadataLookupList m_lookupList
Definition: metadatadownload.h:87
build_compdb.args
args
Definition: build_compdb.py:11
MetadataLookupEvent::m_lookupList
MetadataLookupList m_lookupList
Definition: metadatadownload.h:18
MetadataDownload
Definition: metadatadownload.h:35
MetadataLookup
Definition: metadatacommon.h:87
MetadataLookupFailure
Definition: metadatadownload.h:23
MetadataLookupFailure::MetadataLookupFailure
MetadataLookupFailure(const MetadataLookupList &lul)
Definition: metadatadownload.h:26
RefCountedList< MetadataLookup >
MetadataLookupFailure::m_lookupList
MetadataLookupList m_lookupList
Definition: metadatadownload.h:30
MThread::run
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:315
MetadataLookupFailure::kEventType
static const Type kEventType
Definition: metadatadownload.h:32
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:48
mthread.h
MetadataLookupEvent::MetadataLookupEvent
MetadataLookupEvent(const MetadataLookupList &lul)
Definition: metadatadownload.h:14
MetadataDownload::m_mutex
QMutex m_mutex
Definition: metadatadownload.h:88
MetadataLookupEvent::kEventType
static const Type kEventType
Definition: metadatadownload.h:20
build_compdb.filename
filename
Definition: build_compdb.py:21
MetadataLookupEvent
Definition: metadatadownload.h:11
META_PUBLIC
#define META_PUBLIC
Definition: mythmetaexp.h:9
metadatacommon.h