MythTV  master
metadatafactory.h
Go to the documentation of this file.
1 #ifndef METADATAFACTORY_H_
2 #define METADATAFACTORY_H_
3 
4 // Needed to perform a lookup
5 #include "metadatacommon.h"
7 #include "metadatadownload.h"
8 
9 // Needed to perform scans
10 #include "videoscan.h"
11 
12 // Symbol visibility
13 #include "mythmetaexp.h"
14 
15 class VideoMetadata;
16 class RecordingRule;
17 
19 {
20  public:
22  : QEvent(kEventType), m_results(res) {}
23  ~MetadataFactoryMultiResult() = default;
24 
26 
27  static Type kEventType;
28 };
29 
31 {
32  public:
34  : QEvent(kEventType), m_result(res)
35  {
36  if (m_result)
37  {
38  m_result->IncrRef();
39  }
40  }
42  {
43  if (m_result)
44  {
45  m_result->DecrRef();
46  m_result = nullptr;
47  }
48  }
49 
50  MetadataLookup *m_result {nullptr};
51 
52  static Type kEventType;
53 };
54 
55 class META_PUBLIC MetadataFactoryNoResult : public QEvent
56 {
57  public:
59  : QEvent(kEventType), m_result(res)
60  {
61  if (m_result)
62  {
63  m_result->IncrRef();
64  }
65  }
67  {
68  if (m_result)
69  {
70  m_result->DecrRef();
71  m_result = nullptr;
72  }
73  }
74 
75  MetadataLookup *m_result {nullptr};
76 
77  static Type kEventType;
78 };
79 
81 {
82  public:
83  MetadataFactoryVideoChanges(QList<int> adds, QList<int> movs,
84  QList<int>dels) : QEvent(kEventType),
85  m_additions(adds), m_moved(movs),
86  m_deleted(dels) {}
87  ~MetadataFactoryVideoChanges() = default;
88 
89  QList<int> m_additions; // newly added intids
90  QList<int> m_moved; // intids moved to new filename
91  QList<int> m_deleted; // orphaned/deleted intids
92 
93  static Type kEventType;
94 };
95 
96 class META_PUBLIC MetadataFactory : public QObject
97 {
98 
99  public:
100 
101  explicit MetadataFactory(QObject *parent);
102  ~MetadataFactory();
103 
104  void Lookup(ProgramInfo *pginfo, bool automatic = true,
105  bool getimages = true, bool allowgeneric = false);
106  void Lookup(VideoMetadata *metadata, bool automatic = true,
107  bool getimages = true, bool allowgeneric = false);
108  void Lookup(RecordingRule *recrule, bool automatic = true,
109  bool getimages = true, bool allowgeneric = false);
110  void Lookup(MetadataLookup *lookup);
111 
112  MetadataLookupList SynchronousLookup(const QString& title,
113  const QString& subtitle,
114  const QString& inetref,
115  int season,
116  int episode,
117  const QString& grabber,
118  bool allowgeneric = false);
119  MetadataLookupList SynchronousLookup(MetadataLookup *lookup);
120 
121  void VideoScan();
122  void VideoScan(const QStringList& hosts);
123 
124  bool IsRunning() { return m_lookupthread->isRunning() ||
125  m_imagedownload->isRunning() ||
126  m_videoscanner->isRunning(); };
127 
128  static bool VideoGrabbersFunctional();
129 
130  private:
131 
132  void customEvent(QEvent *levent) override; // QObject
133 
134  void OnMultiResult(const MetadataLookupList& list);
135  void OnSingleResult(MetadataLookup *lookup);
136  void OnNoResult(MetadataLookup *lookup);
137  void OnImageResult(MetadataLookup *lookup);
138 
139  void OnVideoResult(MetadataLookup *lookup);
140 
141  MetadataDownload *m_lookupthread {nullptr};
142  MetadataImageDownload *m_imagedownload {nullptr};
143 
144  VideoScannerThread *m_videoscanner {nullptr};
145  VideoMetadataListManager *m_mlm {nullptr};
146  bool m_scanning {false};
147 
148  // Variables used in synchronous mode
150  bool m_sync {false};
151 };
152 
157 META_PUBLIC LookupType GuessLookupType(const QString& inetref);
158 
159 #endif
MetadataFactoryNoResult(MetadataLookup *res)
MetadataLookupList m_results
Holds information on recordings and videos.
Definition: programinfo.h:66
MetadataFactoryMultiResult(MetadataLookupList res)
MetadataFactorySingleResult(MetadataLookup *res)
MetadataFactoryVideoChanges(QList< int > adds, QList< int > movs, QList< int >dels)
#define META_PUBLIC
Definition: mythmetaexp.h:9
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:32
META_PUBLIC LookupType GuessLookupType(ProgramInfo *pginfo)
MetadataLookupList m_returnList
LookupType