MetadataLookupList MetadataDownload::handleTelevision(MetadataLookup* lookup) { MetadataLookupList list; QString cmd = GetTelevisionGrabber(); QStringList args; args.append(QString("-l")); // Language Flag args.append(gCoreContext->GetLanguage()); // UI Language // If the inetref is populated, even in kLookupSearch mode, // become a kLookupData grab and use that. if (lookup->GetStep() == kLookupSearch && (!lookup->GetInetref().isEmpty() && lookup->GetInetref() != "00000000")) lookup->SetStep(kLookupData); if (lookup->GetStep() == kLookupSearch) { args.append(QString("-M")); if (lookup->GetInetref().isEmpty() || lookup->GetInetref() == "00000000") { QString title = lookup->GetTitle(); args.append(title); } else { QString inetref = lookup->GetInetref(); args.append(inetref); } } else if (lookup->GetStep() == kLookupData) { args.append(QString("-D")); args.append(lookup->GetInetref()); args.append(QString::number(lookup->GetSeason())); args.append(QString::number(lookup->GetEpisode())); } else if (lookup->GetStep() == kLookupCollection) { args.append(QString("-C")); args.append(lookup->GetCollectionref()); } list = runGrabber(cmd, args, lookup); // Collection Fallback // If the lookup allows generic metadata, and the specific // season and episode are not available, try for series metadata. if (list.isEmpty() && lookup->GetAllowGeneric() && lookup->GetStep() == kLookupData) { lookup->SetStep(kLookupCollection); list = handleTelevision(lookup); } return list; }
void MetadataFactory::OnMultiResult(MetadataLookupList list) { if (list.isEmpty()) return; if (parent()) QCoreApplication::postEvent(parent(), new MetadataFactoryMultiResult(list)); }
void MetadataFactory::customEvent(QEvent *levent) { if (levent->type() == MetadataLookupEvent::kEventType) { MetadataLookupEvent *lue = (MetadataLookupEvent *)levent; MetadataLookupList lul = lue->lookupList; if (lul.isEmpty()) return; if (m_sync) { m_returnList = lul; } else if (lul.count() == 1) { OnSingleResult(lul.takeFirst()); } else { OnMultiResult(lul); } } else if (levent->type() == MetadataLookupFailure::kEventType) { MetadataLookupFailure *luf = (MetadataLookupFailure *)levent; MetadataLookupList lul = luf->lookupList; if (lul.isEmpty()) return; if (m_sync) { m_returnList = MetadataLookupList(); m_sync = false; } if (lul.size()) { OnNoResult(lul.takeFirst()); } } else if (levent->type() == ImageDLEvent::kEventType) { ImageDLEvent *ide = (ImageDLEvent *)levent; MetadataLookup *lookup = ide->item; if (!lookup) return; if (m_scanning) OnVideoResult(lookup); else OnImageResult(lookup); } else if (levent->type() == VideoScanChanges::kEventType) { VideoScanChanges *vsc = (VideoScanChanges *)levent; if (!vsc) return; QList<int> additions = vsc->additions; QList<int> moves = vsc->moved; QList<int> deletions = vsc->deleted; if (!m_scanning) { LOG(VB_GENERAL, LOG_INFO, QString("Video Scan Complete: a(%1) m(%2) d(%3)") .arg(additions.count()).arg(moves.count()) .arg(deletions.count())); if (m_parent) QCoreApplication::postEvent(m_parent, new MetadataFactoryVideoChanges(additions, moves, deletions)); } else { LOG(VB_GENERAL, LOG_INFO, QString("Video Scan Complete: a(%1) m(%2) d(%3)") .arg(additions.count()).arg(moves.count()) .arg(deletions.count())); VideoMetadataListManager::metadata_list ml; VideoMetadataListManager::loadAllFromDatabase(ml); m_mlm->setList(ml); for (QList<int>::const_iterator it = additions.begin(); it != additions.end(); ++it) { VideoMetadata *metadata = m_mlm->byID(*it).get(); if (metadata); Lookup(metadata, true, true); } } m_videoscanner->ResetCounts(); } }
void EditMetadataDialog::customEvent(QEvent *levent) { if (levent->type() == DialogCompletionEvent::kEventType) { DialogCompletionEvent *dce = (DialogCompletionEvent*)(levent); const QString resultid = dce->GetId(); if (resultid == CEID_COVERARTFILE) SetCoverArt(dce->GetResultText()); else if (resultid == CEID_BANNERFILE) SetBanner(dce->GetResultText()); else if (resultid == CEID_FANARTFILE) SetFanart(dce->GetResultText()); else if (resultid == CEID_SCREENSHOTFILE) SetScreenshot(dce->GetResultText()); else if (resultid == CEID_TRAILERFILE) SetTrailer(dce->GetResultText()); else if (resultid == CEID_NEWCATEGORY) AddCategory(dce->GetResultText()); } else if (levent->type() == MetadataLookupEvent::kEventType) { MetadataLookupEvent *lue = (MetadataLookupEvent *)levent; MetadataLookupList lul = lue->lookupList; if (lul.isEmpty()) return; // There should really only be one result here. // If not, USER ERROR! if (lul.count() == 1) { OnArtworkSearchDone(lul[0]); } else { if (m_busyPopup) { m_busyPopup->Close(); m_busyPopup = NULL; } } } else if (levent->type() == MetadataLookupFailure::kEventType) { MetadataLookupFailure *luf = (MetadataLookupFailure *)levent; MetadataLookupList lul = luf->lookupList; if (m_busyPopup) { m_busyPopup->Close(); m_busyPopup = NULL; } if (lul.size()) { MetadataLookup *lookup = lul[0]; LOG(VB_GENERAL, LOG_INFO, QString("No results found for %1 %2 %3").arg(lookup->GetTitle()) .arg(lookup->GetSeason()).arg(lookup->GetEpisode())); } } else if (levent->type() == ImageDLEvent::kEventType) { ImageDLEvent *ide = (ImageDLEvent *)levent; MetadataLookup *lookup = ide->item; if (!lookup) return; handleDownloadedImages(lookup); } else if (levent->type() == ImageDLFailureEvent::kEventType) { MythErrorNotification n(tr("Failed to retrieve image"), tr("Metadata Editor"), tr("Check logs")); GetNotificationCenter()->Queue(n); } }
void GameUI::customEvent(QEvent *event) { if (event->type() == DialogCompletionEvent::kEventType) { DialogCompletionEvent *dce = (DialogCompletionEvent*)(event); QString resultid = dce->GetId(); QString resulttext = dce->GetResultText(); if (resultid == "showMenuPopup") { if (resulttext == tr("Edit Details")) { edit(); } if (resulttext == tr("Scan For Changes")) { doScan(); } else if (resulttext == tr("Show Information")) { showInfo(); } else if (resulttext == tr("Make Favorite") || resulttext == tr("Remove Favorite")) { toggleFavorite(); } else if (resulttext == tr("Retrieve Details")) { gameSearch(); } } else if (resultid == "chooseSystemPopup") { if (!resulttext.isEmpty() && resulttext != tr("Cancel")) { MythGenericTree *node = m_gameUITree->GetCurrentNode(); RomInfo *romInfo = qVariantValue<RomInfo *>(node->GetData()); GameHandler::Launchgame(romInfo, resulttext); } } else if (resultid == "editMetadata") { MythGenericTree *node = m_gameUITree->GetCurrentNode(); RomInfo *oldRomInfo = qVariantValue<RomInfo *>(node->GetData()); delete oldRomInfo; RomInfo *romInfo = qVariantValue<RomInfo *>(dce->GetData()); node->SetData(qVariantFromValue(romInfo)); node->SetText(romInfo->Gamename()); romInfo->SaveToDatabase(); updateChangedNode(node, romInfo); } else if (resultid == "detailsPopup") { // Play button pushed itemClicked(0); } } if (event->type() == MetadataLookupEvent::kEventType) { MetadataLookupEvent *lue = (MetadataLookupEvent *)event; MetadataLookupList lul = lue->lookupList; if (m_busyPopup) { m_busyPopup->Close(); m_busyPopup = NULL; } if (lul.isEmpty()) return; if (lul.count() == 1) { OnGameSearchDone(lul.takeFirst()); } else { MetadataResultsDialog *resultsdialog = new MetadataResultsDialog(m_popupStack, lul); connect(resultsdialog, SIGNAL(haveResult(MetadataLookup*)), SLOT(OnGameSearchListSelection(MetadataLookup*)), Qt::QueuedConnection); if (resultsdialog->Create()) m_popupStack->AddScreen(resultsdialog); } } else if (event->type() == MetadataLookupFailure::kEventType) { MetadataLookupFailure *luf = (MetadataLookupFailure *)event; MetadataLookupList lul = luf->lookupList; if (m_busyPopup) { m_busyPopup->Close(); m_busyPopup = NULL; } if (lul.size()) { MetadataLookup *lookup = lul.takeFirst(); MythGenericTree *node = qVariantValue<MythGenericTree *>(lookup->GetData()); if (node) { RomInfo *metadata = qVariantValue<RomInfo *>(node->GetData()); if (metadata) { } } LOG(VB_GENERAL, LOG_ERR, QString("No results found for %1").arg(lookup->GetTitle())); } } else if (event->type() == ImageDLEvent::kEventType) { ImageDLEvent *ide = (ImageDLEvent *)event; MetadataLookup *lookup = ide->item; if (!lookup) return; handleDownloadedImages(lookup); } }
void MetadataDownload::run() { RunProlog(); MetadataLookup* lookup; while ((lookup = moreWork()) != NULL) { MetadataLookupList list; // Go go gadget Metadata Lookup if (lookup->GetType() == kMetadataVideo) { if (lookup->GetSubtype() == kProbableTelevision) list = handleTelevision(lookup); else if (lookup->GetSubtype() == kProbableMovie) list = handleMovie(lookup); else list = handleVideoUndetermined(lookup); if (!list.size() && lookup->GetSubtype() == kUnknownVideo) { list = handleMovie(lookup); } } else if (lookup->GetType() == kMetadataRecording) { if (lookup->GetSubtype() == kProbableTelevision) { if (lookup->GetSeason() > 0 || lookup->GetEpisode() > 0) list = handleTelevision(lookup); else if (!lookup->GetSubtitle().isEmpty()) list = handleVideoUndetermined(lookup); if (list.isEmpty()) list = handleRecordingGeneric(lookup); } else if (lookup->GetSubtype() == kProbableMovie) { list = handleMovie(lookup); if (lookup->GetInetref().isEmpty()) list.append(handleRecordingGeneric(lookup)); } else { list = handleRecordingGeneric(lookup); if (lookup->GetInetref().isEmpty()) list.append(handleMovie(lookup)); } } else if (lookup->GetType() == kMetadataGame) list = handleGame(lookup); // inform parent we have lookup ready for it if (m_parent && list.count() >= 1) { // If there's only one result, don't bother asking // our parent about it, just add it to the back of // the queue in kLookupData mode. if (list.count() == 1 && list.at(0)->GetStep() == kLookupSearch) { MetadataLookup *newlookup = list.takeFirst(); newlookup->SetStep(kLookupData); prependLookup(newlookup); continue; } // If we're in automatic mode, we need to make // these decisions on our own. Pass to title match. if (list.at(0)->GetAutomatic() && list.count() > 1 && list.at(0)->GetStep() == kLookupSearch) { MetadataLookup *bestLookup = findBestMatch(list, lookup->GetTitle()); if (bestLookup) { MetadataLookup *newlookup = bestLookup; newlookup->SetStep(kLookupData); prependLookup(newlookup); continue; } QCoreApplication::postEvent(m_parent, new MetadataLookupFailure(MetadataLookupList() << lookup)); } LOG(VB_GENERAL, LOG_INFO, QString("Returning Metadata Results: %1 %2 %3") .arg(lookup->GetTitle()).arg(lookup->GetSeason()) .arg(lookup->GetEpisode())); QCoreApplication::postEvent(m_parent, new MetadataLookupEvent(list)); } else { list.append(lookup); QCoreApplication::postEvent(m_parent, new MetadataLookupFailure(list)); } } RunEpilog(); }