MythTV  master
metadatafactory.cpp
Go to the documentation of this file.
1 
2 #include "metadatafactory.h"
3 
4 // C++
5 #include <algorithm>
6 #include <unistd.h> // for sleep()
7 
8 // QT
9 #include <QApplication>
10 #include <QList>
11 #include <QUrl>
12 
13 // mythtv
14 #include "libmyth/mythcontext.h"
15 #include "libmyth/programinfo.h"
16 #include "libmyth/remoteutil.h"
17 #include "libmythbase/compat.h"
20 
21 // libmythmetadata
22 #include "videoutils.h"
23 
24 // Needed to perform a lookup
25 #include "metadatadownload.h"
26 #include "metadataimagedownload.h"
27 
28 // Needed for video scanning
30 #include "globals.h"
31 
32 // Input for a lookup
33 #include "videometadata.h"
34 
35 
37  (QEvent::Type) QEvent::registerEventType();
38 
40 {
41  if (m_result)
42  {
43  m_result->DecrRef();
44  m_result = nullptr;
45  }
46 }
47 
49  (QEvent::Type) QEvent::registerEventType();
50 
52 {
53  if (m_result)
54  {
55  m_result->DecrRef();
56  m_result = nullptr;
57  }
58 }
59 
61  (QEvent::Type) QEvent::registerEventType();
62 
63 // Force this class to have a vtable so that dynamic_cast works.
64 // NOLINTNEXTLINE(modernize-use-equals-default)
66 {
67 }
68 
70  (QEvent::Type) QEvent::registerEventType();
71 
72 // Force this class to have a vtable so that dynamic_cast works.
73 // NOLINTNEXTLINE(modernize-use-equals-default)
75 {
76 }
77 
79  QObject(parent)
80 {
81  m_lookupthread = new MetadataDownload(this);
84 
86 }
87 
89 {
90  if (m_lookupthread)
91  {
93  delete m_lookupthread;
94  m_lookupthread = nullptr;
95  }
96 
97  if (m_imagedownload)
98  {
100  delete m_imagedownload;
101  m_imagedownload = nullptr;
102  }
103 
105  delete m_videoscanner;
106 
107  delete m_mlm;
108  m_mlm = nullptr;
109 }
110 
111 void MetadataFactory::Lookup(RecordingRule *recrule, bool automatic,
112  bool getimages, bool allowgeneric)
113 {
114  if (!recrule)
115  return;
116 
117  auto *lookup = new MetadataLookup();
118 
119  lookup->SetStep(kLookupSearch);
120  lookup->SetType(kMetadataRecording);
121  lookup->SetSubtype(GuessLookupType(recrule));
122  lookup->SetData(QVariant::fromValue(recrule));
123  lookup->SetAutomatic(automatic);
124  lookup->SetHandleImages(getimages);
125  lookup->SetAllowGeneric(allowgeneric);
126  lookup->SetHost(gCoreContext->GetMasterHostName());
127  lookup->SetTitle(recrule->m_title);
128  lookup->SetSubtitle(recrule->m_subtitle);
129  lookup->SetInetref(recrule->m_inetref);
130  lookup->SetSeason(recrule->m_season);
131  lookup->SetEpisode(recrule->m_episode);
132 
133  if (m_lookupthread->isRunning())
134  m_lookupthread->prependLookup(lookup);
135  else
136  m_lookupthread->addLookup(lookup);
137 }
138 
139 void MetadataFactory::Lookup(ProgramInfo *pginfo, bool automatic,
140  bool getimages, bool allowgeneric)
141 {
142  if (!pginfo)
143  return;
144 
145  auto *lookup = new MetadataLookup();
146 
147  lookup->SetStep(kLookupSearch);
148  lookup->SetType(kMetadataRecording);
149  lookup->SetSubtype(GuessLookupType(pginfo));
150  lookup->SetData(QVariant::fromValue(pginfo));
151  lookup->SetAutomatic(automatic);
152  lookup->SetHandleImages(getimages);
153  lookup->SetAllowGeneric(allowgeneric);
154  lookup->SetHost(gCoreContext->GetMasterHostName());
155  lookup->SetTitle(pginfo->GetTitle());
156  lookup->SetSubtitle(pginfo->GetSubtitle());
157  lookup->SetSeason(pginfo->GetSeason());
158  lookup->SetEpisode(pginfo->GetEpisode());
159  lookup->SetInetref(pginfo->GetInetRef());
160 
161  if (m_lookupthread->isRunning())
162  m_lookupthread->prependLookup(lookup);
163  else
164  m_lookupthread->addLookup(lookup);
165 }
166 
167 void MetadataFactory::Lookup(VideoMetadata *metadata, bool automatic,
168  bool getimages, bool allowgeneric)
169 {
170  if (!metadata)
171  return;
172 
173  auto *lookup = new MetadataLookup();
174 
175  lookup->SetStep(kLookupSearch);
176  lookup->SetType(kMetadataVideo);
177  lookup->SetSubtype(GuessLookupType(metadata));
178  lookup->SetData(QVariant::fromValue(metadata));
179  lookup->SetAutomatic(automatic);
180  lookup->SetHandleImages(getimages);
181  lookup->SetAllowGeneric(allowgeneric);
182  lookup->SetHost(metadata->GetHost());
183  lookup->SetTitle(metadata->GetTitle());
184  lookup->SetSubtitle(metadata->GetSubtitle());
185  lookup->SetSeason(metadata->GetSeason());
186  lookup->SetEpisode(metadata->GetEpisode());
187  lookup->SetInetref(metadata->GetInetRef());
188  lookup->SetFilename(generate_file_url("Videos", metadata->GetHost(),
189  metadata->GetFilename()));
190 
191  if (m_lookupthread->isRunning())
192  m_lookupthread->prependLookup(lookup);
193  else
194  m_lookupthread->addLookup(lookup);
195 }
196 
198 {
199  if (!lookup)
200  return;
201 
202  if (m_lookupthread->isRunning())
203  m_lookupthread->prependLookup(lookup);
204  else
205  m_lookupthread->addLookup(lookup);
206 }
207 
209  const QString& subtitle,
210  const QString& inetref,
211  int season,
212  int episode,
213  const QString& grabber,
214  bool allowgeneric)
215 {
216  auto *lookup = new MetadataLookup();
217 
218  lookup->SetStep(kLookupSearch);
219  lookup->SetType(kMetadataRecording);
220  lookup->SetAutomatic(false);
221  lookup->SetHandleImages(false);
222  lookup->SetAllowGeneric(allowgeneric);
223  lookup->SetTitle(title);
224  lookup->SetSubtitle(subtitle);
225  lookup->SetSeason(season);
226  lookup->SetEpisode(episode);
227  lookup->SetInetref(inetref);
228  if (grabber.toLower() == "movie")
229  lookup->SetSubtype(kProbableMovie);
230  else if (grabber.toLower() == "tv" ||
231  grabber.toLower() == "television")
232  lookup->SetSubtype(kProbableTelevision);
233  else
234  lookup->SetSubtype(GuessLookupType(lookup));
235 
236  return SynchronousLookup(lookup);
237 }
238 
240 {
241  if (!lookup)
242  return {};
243 
244  m_sync = true;
245 
246  if (m_lookupthread->isRunning())
247  m_lookupthread->prependLookup(lookup);
248  else
249  m_lookupthread->addLookup(lookup);
250 
251  while (m_returnList.isEmpty() && m_sync)
252  {
253  sleep(1);
254  QCoreApplication::processEvents();
255  }
256 
257  m_sync = false;
258 
259  return m_returnList;
260 }
261 
263 {
266 }
267 
269 {
270  if (IsRunning())
271  return;
272 
273  QStringList hosts;
274  if (!RemoteGetActiveBackends(&hosts))
275  {
276  LOG(VB_GENERAL, LOG_WARNING, "Could not retrieve list of "
277  "available backends.");
278  return;
279  }
280 
281  VideoScan(hosts);
282 }
283 
284 void MetadataFactory::VideoScan(const QStringList& hosts)
285 {
286  if (IsRunning())
287  return;
288 
289  m_scanning = true;
290 
291  m_videoscanner->SetHosts(hosts);
294 }
295 
297 {
298  if (list.isEmpty())
299  return;
300 
301  if (parent())
302  QCoreApplication::postEvent(parent(),
303  new MetadataFactoryMultiResult(list));
304 }
305 
307 {
308  if (!lookup)
309  return;
310 
311  if (lookup->GetHandleImages())
312  {
313  DownloadMap map;
314 
315  ArtworkList coverartlist = lookup->GetArtwork(kArtworkCoverart);
316  if (!coverartlist.empty())
317  {
318  ArtworkInfo info;
319  info.url = coverartlist.takeFirst().url;
320  map.insert(kArtworkCoverart, info);
321  }
322 
323  ArtworkList fanartlist = lookup->GetArtwork(kArtworkFanart);
324  if (!fanartlist.empty())
325  {
326  ArtworkInfo info;
327  int index = 0;
328  int season = lookup->GetIsCollection() ? 0 : (int)lookup->GetSeason();
329  if (season > 0 && season <= fanartlist.count())
330  index = season - 1;
331  info.url = fanartlist.takeAt(index).url;
332  map.insert(kArtworkFanart, info);
333  }
334 
335  ArtworkList bannerlist = lookup->GetArtwork(kArtworkBanner);
336  if (!bannerlist.empty())
337  {
338  ArtworkInfo info;
339  info.url = bannerlist.takeFirst().url;
340  map.insert(kArtworkBanner, info);
341  }
342 
343  if (lookup->GetType() != kMetadataRecording)
344  {
345  ArtworkList screenshotlist = lookup->GetArtwork(kArtworkScreenshot);
346  if (!screenshotlist.empty())
347  {
348  ArtworkInfo info;
349  info.url = screenshotlist.takeFirst().url;
350  map.insert(kArtworkScreenshot, info);
351  }
352  }
353  lookup->SetDownloads(map);
354  lookup->IncrRef();
355  m_imagedownload->addDownloads(lookup);
356  }
357  else
358  {
359  if (m_scanning)
360  OnVideoResult(lookup);
361  else if (parent())
362  QCoreApplication::postEvent(parent(),
363  new MetadataFactorySingleResult(lookup));
364  }
365 }
366 
368 {
369  if (!lookup)
370  return;
371 
372  if (parent())
373  QCoreApplication::postEvent(parent(),
374  new MetadataFactoryNoResult(lookup));
375 }
376 
378 {
379  if (!lookup)
380  return;
381 
382  if (parent())
383  QCoreApplication::postEvent(parent(),
384  new MetadataFactorySingleResult(lookup));
385 }
386 
388 {
389  if (!lookup)
390  return;
391 
392  auto *metadata = lookup->GetData().value<VideoMetadata *>();
393 
394  if (!metadata)
395  return;
396 
397  metadata->SetTitle(lookup->GetTitle());
398  metadata->SetSubtitle(lookup->GetSubtitle());
399 
400  if (metadata->GetTagline().isEmpty())
401  metadata->SetTagline(lookup->GetTagline());
402  if (metadata->GetYear() == VIDEO_YEAR_DEFAULT || metadata->GetYear() == 0)
403  metadata->SetYear(lookup->GetYear());
404  if (metadata->GetReleaseDate() == QDate())
405  metadata->SetReleaseDate(lookup->GetReleaseDate());
406  if (metadata->GetDirector() == VIDEO_DIRECTOR_UNKNOWN ||
407  metadata->GetDirector().isEmpty())
408  {
409  QList<PersonInfo> director = lookup->GetPeople(kPersonDirector);
410  if (director.count() > 0)
411  metadata->SetDirector(director.takeFirst().name);
412  }
413  if (metadata->GetStudio().isEmpty())
414  {
415  QStringList studios = lookup->GetStudios();
416  if (studios.count() > 0)
417  metadata->SetStudio(studios.takeFirst());
418  }
419  if (metadata->GetPlot() == VIDEO_PLOT_DEFAULT ||
420  metadata->GetPlot().isEmpty())
421  metadata->SetPlot(lookup->GetDescription());
422  if (metadata->GetUserRating() == 0)
423  metadata->SetUserRating(lookup->GetUserRating());
424  if (metadata->GetRating() == VIDEO_RATING_DEFAULT)
425  metadata->SetRating(lookup->GetCertification());
426  if (metadata->GetLength() == 0min)
427  metadata->SetLength(lookup->GetRuntime());
428  if (metadata->GetSeason() == 0)
429  metadata->SetSeason(lookup->GetSeason());
430  if (metadata->GetEpisode() == 0)
431  metadata->SetEpisode(lookup->GetEpisode());
432  if (metadata->GetHomepage().isEmpty())
433  metadata->SetHomepage(lookup->GetHomepage());
434 
435  metadata->SetInetRef(lookup->GetInetref());
436 
437 // m_d->AutomaticParentalAdjustment(metadata);
438 
439  // Cast
440  QList<PersonInfo> actors = lookup->GetPeople(kPersonActor);
441  QList<PersonInfo> gueststars = lookup->GetPeople(kPersonGuestStar);
442 
443  for (const auto& actor : qAsConst(gueststars))
444  actors.append(actor);
445 
447  QStringList cl;
448 
449  for (const auto& actor : qAsConst(actors))
450  cl.append(actor.name);
451 
452  for (const auto& name : qAsConst(cl))
453  {
454  QString cn = name.trimmed();
455  if (!cn.isEmpty())
456  {
457  cast.push_back(VideoMetadata::cast_list::
458  value_type(-1, cn));
459  }
460  }
461 
462  metadata->SetCast(cast);
463 
464  // Genres
465  VideoMetadata::genre_list video_genres;
466  QStringList genres = lookup->GetCategories();
467 
468  for (const auto& str : qAsConst(genres))
469  {
470  QString genre_name = str.trimmed();
471  if (!genre_name.isEmpty())
472  {
473  video_genres.push_back(
474  VideoMetadata::genre_list::value_type(-1, genre_name));
475  }
476  }
477 
478  metadata->SetGenres(video_genres);
479 
480  // Countries
481  VideoMetadata::country_list video_countries;
482  QStringList countries = lookup->GetCountries();
483 
484  for (const auto& str : qAsConst(countries))
485  {
486  QString country_name = str.trimmed();
487  if (!country_name.isEmpty())
488  {
489  video_countries.push_back(
490  VideoMetadata::country_list::value_type(-1,
491  country_name));
492  }
493  }
494 
495  metadata->SetCountries(video_countries);
496 
497  DownloadMap map = lookup->GetDownloads();
498 
499  QUrl coverurl(map.value(kArtworkCoverart).url);
500  if (!coverurl.path().isEmpty())
501  metadata->SetCoverFile(coverurl.path().remove(0,1));
502 
503  QUrl fanarturl(map.value(kArtworkFanart).url);
504  if (!fanarturl.path().isEmpty())
505  metadata->SetFanart(fanarturl.path().remove(0,1));
506 
507  QUrl bannerurl(map.value(kArtworkBanner).url);
508  if (!bannerurl.path().isEmpty())
509  metadata->SetBanner(bannerurl.path().remove(0,1));
510 
511  QUrl sshoturl(map.value(kArtworkScreenshot).url);
512  if (!sshoturl.path().isEmpty())
513  metadata->SetScreenshot(sshoturl.path().remove(0,1));
514 
515  metadata->SetProcessed(true);
516  metadata->UpdateDatabase();
517 
518  if (gCoreContext->HasGUI() && parent())
519  {
520  QCoreApplication::postEvent(parent(),
521  new MetadataFactorySingleResult(lookup));
522  }
523 }
524 
525 void MetadataFactory::customEvent(QEvent *levent)
526 {
527  if (levent->type() == MetadataLookupEvent::kEventType)
528  {
529  auto *lue = dynamic_cast<MetadataLookupEvent *>(levent);
530  if (lue == nullptr)
531  return;
532 
533  MetadataLookupList lul = lue->m_lookupList;
534  if (lul.isEmpty())
535  return;
536 
537  if (m_sync)
538  {
539  m_returnList = lul;
540  }
541  else if (lul.count() == 1)
542  {
543  OnSingleResult(lul[0]);
544  }
545  else
546  {
547  OnMultiResult(lul);
548  }
549  }
550  else if (levent->type() == MetadataLookupFailure::kEventType)
551  {
552  auto *luf = dynamic_cast<MetadataLookupFailure *>(levent);
553  if (luf == nullptr)
554  return;
555 
556  MetadataLookupList lul = luf->m_lookupList;
557  if (lul.isEmpty())
558  return;
559 
560  if (m_sync)
561  {
563  m_sync = false;
564  }
565  if (!lul.empty())
566  {
567  OnNoResult(lul[0]);
568  }
569  }
570  else if (levent->type() == ImageDLEvent::kEventType)
571  {
572  auto *ide = dynamic_cast<ImageDLEvent *>(levent);
573  if (ide == nullptr)
574  return;
575 
576  MetadataLookup *lookup = ide->m_item;
577  if (!lookup)
578  return;
579 
580  if (m_scanning)
581  OnVideoResult(lookup);
582  else
583  OnImageResult(lookup);
584  }
585  else if (levent->type() == ImageDLFailureEvent::kEventType)
586  {
587  auto *ide = dynamic_cast<ImageDLFailureEvent *>(levent);
588  if (ide == nullptr)
589  return;
590 
591  MetadataLookup *lookup = ide->m_item;
592  if (!lookup)
593  return;
594 
595  // propagate event on image download failure
596  if (parent())
597  QCoreApplication::postEvent(parent(),
598  new ImageDLFailureEvent(lookup));
599  }
600  else if (levent->type() == VideoScanChanges::kEventType)
601  {
602  auto *vsc = dynamic_cast<VideoScanChanges *>(levent);
603  if (!vsc)
604  return;
605 
606  QList<int> additions = vsc->m_additions;
607  QList<int> moves = vsc->m_moved;
608  QList<int> deletions = vsc->m_deleted;
609 
610  if (!m_scanning)
611  {
612  LOG(VB_GENERAL, LOG_INFO,
613  QString("Video Scan Complete: a(%1) m(%2) d(%3)")
614  .arg(additions.count()).arg(moves.count())
615  .arg(deletions.count()));
616 
617  if (parent())
618  {
619  QCoreApplication::postEvent(parent(),
620  new MetadataFactoryVideoChanges(additions, moves,
621  deletions));
622  }
623  }
624  else
625  {
626  LOG(VB_GENERAL, LOG_INFO,
627  QString("Video Scan Complete: a(%1) m(%2) d(%3)")
628  .arg(additions.count()).arg(moves.count())
629  .arg(deletions.count()));
630 
633  m_mlm->setList(ml);
634 
635  for (int id : qAsConst(additions))
636  {
637  VideoMetadata *metadata = m_mlm->byID(id).get();
638 
639  if (metadata)
640  Lookup(metadata, true, true);
641  }
642  }
644  }
645 }
646 
647 // These functions exist to determine if we have enough
648 // information to conclusively call something a Show vs. Movie
649 
651 {
652  LookupType ret = GuessLookupType(pginfo->GetInetRef());
653 
654  if (ret != kUnknownVideo)
655  return ret;
656 
657  ProgramInfo::CategoryType catType = pginfo->GetCategoryType();
658  if (catType == ProgramInfo::kCategoryNone)
659  catType = pginfo->QueryCategoryType();
660 
661  if ((!pginfo->GetSubtitle().isEmpty() || pginfo->GetEpisode() > 0) &&
662  (catType == ProgramInfo::kCategorySeries ||
663  catType == ProgramInfo::kCategoryTVShow))
664  ret = kProbableTelevision; // NOLINT(bugprone-branch-clone)
665  else if (catType == ProgramInfo::kCategoryMovie)
666  ret = kProbableMovie;
667  else if (pginfo->GetSeason() > 0 || pginfo->GetEpisode() > 0 ||
668  !pginfo->GetSubtitle().isEmpty())
669  ret = kProbableTelevision;
670  else
671  {
672  // Before committing to something being a movie, we
673  // want to check its rule. If the rule has a season
674  // or episode number, but the recording doesn't,
675  // and the rec doesn't have a subtitle, this is a
676  // generic recording. If neither the rule nor the
677  // recording have an inetref, season, episode, or
678  // subtitle, it's *probably* a movie. If it's some
679  // weird combination of both, we've got to try everything.
680  auto *rule = new RecordingRule();
681  rule->m_recordID = pginfo->GetRecordingRuleID();
682  rule->Load();
683  int ruleepisode = rule->m_episode;
684  delete rule;
685 
686  if (ruleepisode == 0 && pginfo->GetEpisode() == 0 &&
687  pginfo->GetSubtitle().isEmpty())
688  ret = kProbableMovie;
689  else if (ruleepisode > 0 && pginfo->GetSubtitle().isEmpty())
691  else
692  ret = kUnknownVideo;
693  }
694 
695  return ret;
696 }
697 
699 {
700  LookupType ret = GuessLookupType(lookup->GetInetref());
701 
702  if (ret != kUnknownVideo)
703  return ret;
704 
705  if (lookup->GetSeason() > 0 || lookup->GetEpisode() > 0 ||
706  !lookup->GetSubtitle().isEmpty())
707  ret = kProbableTelevision;
708  else
709  ret = kProbableMovie;
710 
711  return ret;
712 }
713 
715 {
716  LookupType ret = GuessLookupType(metadata->GetInetRef());
717 
718  if (ret != kUnknownVideo)
719  return ret;
720 
721  if (metadata->GetSeason() > 0 || metadata->GetEpisode() > 0 ||
722  !metadata->GetSubtitle().isEmpty())
723  ret = kProbableTelevision;
724  else
725  ret = kProbableMovie;
726 
727  return ret;
728 }
729 
731 {
732  LookupType ret = GuessLookupType(recrule->m_inetref);
733 
734  if (ret != kUnknownVideo)
735  return ret;
736 
737  if (recrule->m_season > 0 || recrule->m_episode > 0 ||
738  !recrule->m_subtitle.isEmpty())
739  ret = kProbableTelevision;
740  else
741  ret = kProbableMovie;
742 
743  return ret;
744 }
745 
746 LookupType GuessLookupType(const QString &inetref)
747 {
748  if (inetref.isEmpty() || inetref == "00000000" ||
749  inetref == MetaGrabberScript::CleanedInetref(inetref))
750  {
751  // can't determine subtype from inetref
752  return kUnknownVideo;
753  }
754 
755  // inetref is defined, see if we have a pre-defined grabber
756  MetaGrabberScript grabber =
758 
759  if (!grabber.IsValid())
760  {
761  return kUnknownVideo;
762  }
763 
764  switch (grabber.GetType())
765  {
766  case kGrabberMovie:
767  return kProbableMovie;
768  case kGrabberTelevision:
769  return kProbableTelevision;
770  default:
771  return kUnknownVideo;
772  }
773 }
MetadataFactory::OnSingleResult
void OnSingleResult(MetadataLookup *lookup)
Definition: metadatafactory.cpp:306
MetadataFactory::Lookup
void Lookup(ProgramInfo *pginfo, bool automatic=true, bool getimages=true, bool allowgeneric=false)
Definition: metadatafactory.cpp:139
MetadataFactoryVideoChanges::~MetadataFactoryVideoChanges
~MetadataFactoryVideoChanges() override
Definition: metadatafactory.cpp:74
MetadataFactory::m_mlm
VideoMetadataListManager * m_mlm
Definition: metadatafactory.h:134
generate_file_url
QString generate_file_url(const QString &storage_group, const QString &host, const QString &path)
Definition: videoutils.h:65
VideoMetadata
Definition: videometadata.h:24
MetadataFactory::OnMultiResult
void OnMultiResult(const MetadataLookupList &list)
Definition: metadatafactory.cpp:296
MetaGrabberScript
Definition: metadatagrabber.h:29
MThread::start
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
Definition: mthread.cpp:286
MythCoreContext::GetMasterHostName
QString GetMasterHostName(void)
Definition: mythcorecontext.cpp:811
kGrabberTelevision
@ kGrabberTelevision
Definition: metadatagrabber.h:23
MetadataFactoryNoResult::m_result
MetadataLookup * m_result
Definition: metadatafactory.h:63
ReferenceCounter::DecrRef
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
Definition: referencecounter.cpp:125
RecordingRule::m_inetref
QString m_inetref
Definition: recordingrule.h:85
MetadataImageDownload
Definition: metadataimagedownload.h:87
kMetadataRecording
@ kMetadataRecording
Definition: metadatacommon.h:44
videometadata.h
VideoMetadata::GetHost
const QString & GetHost() const
Definition: videometadata.cpp:1837
MetadataLookup::GetTitle
QString GetTitle() const
Definition: metadatacommon.h:299
VideoMetadataListManager
Definition: videometadatalistmanager.h:10
kMetadataVideo
@ kMetadataVideo
Definition: metadatacommon.h:43
MThread::wait
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
Definition: mthread.cpp:303
MetadataFactory::customEvent
void customEvent(QEvent *levent) override
Definition: metadatafactory.cpp:525
MetadataFactory::m_sync
bool m_sync
Definition: metadatafactory.h:139
MetadataImageDownload::cancel
void cancel()
Definition: metadataimagedownload.cpp:64
ArtworkList
QList< ArtworkInfo > ArtworkList
Definition: metadataimagehelper.h:30
MetadataFactory::m_scanning
bool m_scanning
Definition: metadatafactory.h:135
MetadataDownload::prependLookup
void prependLookup(MetadataLookup *lookup)
prependLookup: Add lookup to top of the queue MetadataDownload::m_lookupList takes ownership of the g...
Definition: metadatadownload.cpp:54
ImageDLFailureEvent::kEventType
static Type kEventType
Definition: metadataimagedownload.h:67
kProbableTelevision
@ kProbableTelevision
Definition: metadatacommon.h:51
RecordingRule::m_title
QString m_title
Definition: recordingrule.h:75
VideoMetadata::country_list
std::vector< country_entry > country_list
Definition: videometadata.h:33
RecordingRule
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:28
MetadataFactory::SynchronousLookup
MetadataLookupList SynchronousLookup(const QString &title, const QString &subtitle, const QString &inetref, int season, int episode, const QString &grabber, bool allowgeneric=false)
Definition: metadatafactory.cpp:208
VideoScanChanges::kEventType
static Type kEventType
Definition: videoscan.h:57
GuessLookupType
LookupType GuessLookupType(ProgramInfo *pginfo)
Definition: metadatafactory.cpp:650
ImageDLEvent
Definition: metadataimagedownload.h:18
MetadataDownload
Definition: metadatadownload.h:35
MetadataFactoryNoResult::kEventType
static Type kEventType
Definition: metadatafactory.h:65
MetadataLookup::GetArtwork
ArtworkList GetArtwork(VideoArtworkType type) const
Definition: metadatacommon.cpp:330
MetaGrabberScript::IsValid
bool IsValid(void) const
Definition: metadatagrabber.h:55
VideoMetadata::GetSeason
int GetSeason() const
Definition: videometadata.cpp:1707
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
VideoMetadata::genre_list
std::vector< genre_entry > genre_list
Definition: videometadata.h:32
MetadataFactoryMultiResult::kEventType
static Type kEventType
Definition: metadatafactory.h:29
MetadataLookup::GetCertification
QString GetCertification() const
Definition: metadatacommon.h:335
VideoMetadataListManager::setList
void setList(metadata_list &list)
Definition: videometadatalistmanager.cpp:159
MetadataFactorySingleResult::~MetadataFactorySingleResult
~MetadataFactorySingleResult() override
Definition: metadatafactory.cpp:51
MetadataLookup::SetDownloads
void SetDownloads(DownloadMap map)
Definition: metadatacommon.h:253
RecordingRule::m_season
uint m_season
Definition: recordingrule.h:92
remoteutil.h
VideoScannerThread::ResetCounts
void ResetCounts()
Definition: videoscan.h:75
kPersonGuestStar
@ kPersonGuestStar
Definition: metadatacommon.h:81
MetadataFactoryNoResult
Definition: metadatafactory.h:50
VideoMetadata::GetSubtitle
const QString & GetSubtitle() const
Definition: videometadata.cpp:1562
kLookupSearch
@ kLookupSearch
Definition: metadatacommon.h:28
VideoMetadataListManager::loadAllFromDatabase
static void loadAllFromDatabase(metadata_list &items, const QString &sql="")
Load videometadata database into memory.
Definition: videometadatalistmanager.cpp:128
kGrabberMovie
@ kGrabberMovie
Definition: metadatagrabber.h:22
MetadataLookup
Definition: metadatacommon.h:87
ProgramInfo::kCategoryMovie
@ kCategoryMovie
Definition: programinfo.h:76
MetadataFactoryNoResult::~MetadataFactoryNoResult
~MetadataFactoryNoResult() override
Definition: metadatafactory.cpp:39
MetadataLookupFailure::kEventType
static Type kEventType
Definition: metadatadownload.h:32
ProgramInfo::GetInetRef
QString GetInetRef(void) const
Definition: programinfo.h:437
VideoScannerThread
Definition: videoscan.h:60
MetaGrabberScript::CleanedInetref
static QString CleanedInetref(const QString &inetref)
Definition: metadatagrabber.cpp:250
MetadataLookup::GetDownloads
DownloadMap GetDownloads() const
Definition: metadatacommon.h:372
RecordingRule::m_episode
uint m_episode
Definition: recordingrule.h:93
VideoMetadata::GetFilename
const QString & GetFilename() const
Definition: videometadata.cpp:1817
VideoMetadata::GetInetRef
const QString & GetInetRef() const
Definition: videometadata.cpp:1607
programinfo.h
ProgramInfo::kCategoryTVShow
@ kCategoryTVShow
Definition: programinfo.h:77
mythlogging.h
MetadataLookup::GetEpisode
uint GetEpisode() const
Definition: metadatacommon.h:315
MetadataLookup::GetDescription
QString GetDescription() const
Definition: metadatacommon.h:312
kPersonActor
@ kPersonActor
Definition: metadatacommon.h:70
GetVideoDirs
QStringList GetVideoDirs()
Definition: videoutils.cpp:121
MetadataLookupFailure
Definition: metadatadownload.h:23
metadatadownload.h
ArtworkInfo
Definition: metadataimagehelper.h:21
metadataimagedownload.h
ImageDLFailureEvent
Definition: metadataimagedownload.h:44
globals.h
RefCountedList< MetadataLookup >
MetadataLookup::GetData
QVariant GetData() const
Definition: metadatacommon.h:288
MetaGrabberScript::GetType
static MetaGrabberScript GetType(const QString &type)
Definition: metadatagrabber.cpp:155
ProgramInfo::GetTitle
QString GetTitle(void) const
Definition: programinfo.h:361
compat.h
MetadataFactorySingleResult::kEventType
static Type kEventType
Definition: metadatafactory.h:47
VideoScannerThread::SetDirs
void SetDirs(QStringList dirs)
Definition: videoscan.cpp:101
MetadataFactoryVideoChanges
Definition: metadatafactory.h:68
kPersonDirector
@ kPersonDirector
Definition: metadatacommon.h:72
MetadataLookup::GetType
MetadataType GetType() const
Definition: metadatacommon.h:286
VIDEO_PLOT_DEFAULT
const QString VIDEO_PLOT_DEFAULT
Definition: globals.cpp:32
kArtworkFanart
@ kArtworkFanart
Definition: metadataimagehelper.h:12
MetadataLookup::GetSubtitle
QString GetSubtitle() const
Definition: metadatacommon.h:310
MetadataFactory::IsRunning
bool IsRunning()
Definition: metadatafactory.h:113
RecordingRule::m_subtitle
QString m_subtitle
Definition: recordingrule.h:77
MetadataFactory::VideoScan
void VideoScan()
Definition: metadatafactory.cpp:268
MetadataLookup::GetCountries
QStringList GetCountries() const
Definition: metadatacommon.h:336
MetadataFactoryMultiResult::~MetadataFactoryMultiResult
~MetadataFactoryMultiResult() override
Definition: metadatafactory.cpp:65
ProgramInfo::QueryCategoryType
CategoryType QueryCategoryType(void) const
Queries recordedprogram to get the category_type of the recording.
Definition: programinfo.cpp:3032
MetadataLookup::GetPeople
QList< PersonInfo > GetPeople(PeopleType type) const
Definition: metadatacommon.cpp:314
MetadataDownload::addLookup
void addLookup(MetadataLookup *lookup)
addLookup: Add lookup to bottom of the queue MetadataDownload::m_lookupList takes ownership of the gi...
Definition: metadatadownload.cpp:39
MetadataLookup::GetYear
uint GetYear() const
Definition: metadatacommon.h:349
MetadataLookup::GetHandleImages
bool GetHandleImages() const
Definition: metadatacommon.h:293
MetadataLookup::GetUserRating
float GetUserRating() const
Definition: metadatacommon.h:302
VideoMetadata::GetEpisode
int GetEpisode() const
Definition: videometadata.cpp:1717
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:59
kProbableGenericTelevision
@ kProbableGenericTelevision
Definition: metadatacommon.h:52
MetadataFactoryMultiResult
Definition: metadatafactory.h:20
ProgramInfo::CategoryType
CategoryType
Definition: programinfo.h:76
videometadatalistmanager.h
MetadataLookup::GetSeason
uint GetSeason() const
Definition: metadatacommon.h:314
kUnknownVideo
@ kUnknownVideo
Definition: metadatacommon.h:54
MetadataFactory::VideoGrabbersFunctional
static bool VideoGrabbersFunctional()
Definition: metadatafactory.cpp:262
MetadataFactory::OnVideoResult
void OnVideoResult(MetadataLookup *lookup)
Definition: metadatafactory.cpp:387
MetadataLookup::GetCategories
QStringList GetCategories() const
Definition: metadatacommon.h:301
MetadataFactory::m_imagedownload
MetadataImageDownload * m_imagedownload
Definition: metadatafactory.h:131
MetadataFactory::m_returnList
MetadataLookupList m_returnList
Definition: metadatafactory.h:138
MetadataLookup::GetRuntime
std::chrono::minutes GetRuntime() const
Definition: metadatacommon.h:352
ProgramInfo::GetEpisode
uint GetEpisode(void) const
Definition: programinfo.h:367
MetadataFactorySingleResult
Definition: metadatafactory.h:32
MetaGrabberScript::FromInetref
static MetaGrabberScript FromInetref(const QString &inetref, bool absolute=false)
Definition: metadatagrabber.cpp:229
ProgramInfo
Holds information on recordings and videos.
Definition: programinfo.h:67
MetadataLookupEvent::kEventType
static Type kEventType
Definition: metadatadownload.h:20
MetadataFactory::m_videoscanner
VideoScannerThread * m_videoscanner
Definition: metadatafactory.h:133
MetadataDownload::MovieGrabberWorks
static bool MovieGrabberWorks()
Definition: metadatadownload.cpp:436
MetadataFactory::~MetadataFactory
~MetadataFactory() override
Definition: metadatafactory.cpp:88
ProgramInfo::GetSeason
uint GetSeason(void) const
Definition: programinfo.h:366
MetadataLookup::GetTagline
QString GetTagline() const
Definition: metadatacommon.h:311
VideoMetadata::cast_list
std::vector< cast_entry > cast_list
Definition: videometadata.h:34
MetadataLookup::GetInetref
QString GetInetref() const
Definition: metadatacommon.h:356
VIDEO_RATING_DEFAULT
const QString VIDEO_RATING_DEFAULT
Definition: globals.cpp:30
MetadataLookup::GetStudios
QStringList GetStudios() const
Definition: metadatacommon.h:364
MetadataFactory::OnImageResult
void OnImageResult(MetadataLookup *lookup)
Definition: metadatafactory.cpp:377
VideoMetadata::SetTitle
void SetTitle(const QString &title, const QString &sortTitle="")
Definition: videometadata.cpp:1557
LookupType
LookupType
Definition: metadatacommon.h:50
MetadataFactory::m_lookupthread
MetadataDownload * m_lookupthread
Definition: metadatafactory.h:130
mythcontext.h
metadatafactory.h
MThread::isRunning
bool isRunning(void) const
Definition: mthread.cpp:266
kArtworkBanner
@ kArtworkBanner
Definition: metadataimagehelper.h:13
VIDEO_YEAR_DEFAULT
@ VIDEO_YEAR_DEFAULT
Definition: videometadata.h:18
VideoScanChanges
Definition: videoscan.h:44
VideoMetadata::GetTitle
const QString & GetTitle() const
Definition: videometadata.cpp:1547
VideoMetadataListManager::metadata_list
std::list< VideoMetadataPtr > metadata_list
Definition: videometadatalistmanager.h:14
DownloadMap
QMap< VideoArtworkType, ArtworkInfo > DownloadMap
Definition: metadatacommon.h:84
ProgramInfo::kCategoryNone
@ kCategoryNone
Definition: programinfo.h:76
MetadataLookup::GetIsCollection
bool GetIsCollection() const
Definition: metadatacommon.h:360
MetadataLookup::GetReleaseDate
QDate GetReleaseDate() const
Definition: metadatacommon.h:350
ProgramInfo::kCategorySeries
@ kCategorySeries
Definition: programinfo.h:76
MythCoreContext::HasGUI
bool HasGUI(void) const
Definition: mythcorecontext.cpp:1748
VideoScannerThread::SetHosts
void SetHosts(const QStringList &hosts)
Definition: videoscan.cpp:94
kArtworkScreenshot
@ kArtworkScreenshot
Definition: metadataimagehelper.h:14
ProgramInfo::GetRecordingRuleID
uint GetRecordingRuleID(void) const
Definition: programinfo.h:449
MetadataLookup::GetHomepage
QString GetHomepage() const
Definition: metadatacommon.h:367
recordingrule.h
MetadataFactorySingleResult::m_result
MetadataLookup * m_result
Definition: metadatafactory.h:45
ReferenceCounter::IncrRef
virtual int IncrRef(void)
Increments reference count.
Definition: referencecounter.cpp:101
kProbableMovie
@ kProbableMovie
Definition: metadatacommon.h:53
ProgramInfo::GetCategoryType
CategoryType GetCategoryType(void) const
Definition: programinfo.h:438
MetadataLookupEvent
Definition: metadatadownload.h:11
META_PUBLIC
#define META_PUBLIC
Definition: mythmetaexp.h:9
kArtworkCoverart
@ kArtworkCoverart
Definition: metadataimagehelper.h:11
MetadataFactory::MetadataFactory
MetadataFactory(QObject *parent)
Definition: metadatafactory.cpp:78
MetadataDownload::TelevisionGrabberWorks
static bool TelevisionGrabberWorks()
Definition: metadatadownload.cpp:448
videoutils.h
RemoteGetActiveBackends
bool RemoteGetActiveBackends(QStringList *list)
return list of backends currently connected to the master
Definition: remoteutil.cpp:570
MetadataLookupList
RefCountedList< MetadataLookup > MetadataLookupList
Definition: metadatacommon.h:462
VideoScanChanges::m_additions
QList< int > m_additions
Definition: videoscan.h:53
MetadataFactoryVideoChanges::kEventType
static Type kEventType
Definition: metadatafactory.h:82
ImageDLEvent::kEventType
static Type kEventType
Definition: metadataimagedownload.h:41
simple_ref_ptr::get
T * get() const
Definition: quicksp.h:73
ArtworkInfo::url
QString url
Definition: metadataimagehelper.h:25
MetadataDownload::cancel
void cancel()
Definition: metadatadownload.cpp:65
MetadataFactory::OnNoResult
void OnNoResult(MetadataLookup *lookup)
Definition: metadatafactory.cpp:367
MetadataImageDownload::addDownloads
void addDownloads(MetadataLookup *lookup)
addLookup: Add lookup to bottom of the queue MetadataDownload::m_downloadList takes ownership of the ...
Definition: metadataimagedownload.cpp:54
ProgramInfo::GetSubtitle
QString GetSubtitle(void) const
Definition: programinfo.h:363
VideoMetadataListManager::byID
VideoMetadataPtr byID(unsigned int db_id) const
Definition: videometadatalistmanager.cpp:177
VIDEO_DIRECTOR_UNKNOWN
const QString VIDEO_DIRECTOR_UNKNOWN
Definition: globals.cpp:9