Skip to content

Commit

Permalink
Improve detection of invalid metadata grabbers.
Browse files Browse the repository at this point in the history
1) Update GetGrabber to log a message about an invalid grabber.

2) Callers of GetGrabber now check whether a returned grabber is valid
before using it.
  • Loading branch information
linuxdude42 committed Nov 29, 2023
1 parent 43e6e00 commit 7b75e1d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions mythtv/libs/libmythmetadata/metadatadownload.cpp
Expand Up @@ -565,6 +565,8 @@ MetadataLookupList MetadataDownload::handleGame(MetadataLookup *lookup)
MetadataLookupList list;
MetaGrabberScript grabber =
MetaGrabberScript::GetGrabber(kGrabberGame, lookup);
if (!grabber.IsValid())
return {};

// If the inetref is populated, even in kLookupSearch mode,
// become a kLookupData grab and use that.
Expand Down Expand Up @@ -608,6 +610,8 @@ MetadataLookupList MetadataDownload::handleMovie(MetadataLookup *lookup)

MetaGrabberScript grabber =
MetaGrabberScript::GetGrabber(kGrabberMovie, lookup);
if (!grabber.IsValid())
return {};

// initial search mode
if (!lookup->GetInetref().isEmpty() && lookup->GetInetref() != "00000000" &&
Expand Down Expand Up @@ -648,6 +652,8 @@ MetadataLookupList MetadataDownload::handleTelevision(MetadataLookup *lookup)

MetaGrabberScript grabber =
MetaGrabberScript::GetGrabber(kGrabberTelevision, lookup);
if (!grabber.IsValid())
return {};
bool searchcollection = false;

// initial search mode
Expand Down
11 changes: 10 additions & 1 deletion mythtv/libs/libmythmetadata/metadatagrabber.cpp
Expand Up @@ -145,7 +145,16 @@ MetaGrabberScript MetaGrabberScript::GetGrabber(GrabberType defaultType,
// fall through
}

return GetType(defaultType);
auto grabber = GetType(defaultType);
if (!grabber.m_valid)
{
QString name = grabberTypes[defaultType].m_setting;
if (name.isEmpty())
name = QString("Type %1").arg(defaultType);
LOG(VB_GENERAL, LOG_INFO,
QString("Grabber '%1' is not configured. Do you need to set PYTHONPATH?").arg(name));
}
return grabber;
}

MetaGrabberScript MetaGrabberScript::GetType(const QString &type)
Expand Down

0 comments on commit 7b75e1d

Please sign in to comment.