Go to the documentation of this file.
6 #include <QMutexLocker>
7 #include <QRegularExpression>
21 #define LOC QString("Metadata Grabber: ")
24 static const QRegularExpression
kRetagRef { R
"(^([a-zA-Z0-9_\-\.]+\.[a-zA-Z0-9]{1,3})[:_](.*))" };
39 "metadata/Movie/tmdb3.py" } },
42 "metadata/Television/ttvdb4.py" } },
44 "mythgame.MetadataGrabber",
45 "metadata/Game/giantbomb.py" } },
65 QString tmptype =
type.toLower();
89 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"Clearing grabber cache");
93 for (
const auto& grabberType : std::as_const(
grabberTypes))
95 QString path = (grabberType.m_path).arg(
GetShareDir());
96 QDir dir = QDir(path);
99 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
100 QString(
"No script directory %1").arg(path));
103 QStringList scripts = dir.entryList(QDir::Executable | QDir::Files);
104 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
105 QString(
"Found %1 scripts in %2").arg(scripts.count()).arg(path));
106 if (scripts.count() == 0)
111 for (
const auto& name : std::as_const(scripts))
113 QString cmd = QDir(path).filePath(name);
123 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"Failed " + name);
134 for (
const auto& item : std::as_const(tmpGrabberList))
137 retGrabberList.append(item);
140 return retGrabberList;
161 auto grabber =
GetType(defaultType);
162 if (!grabber.m_valid)
166 name = QString(
"Type %1").arg(defaultType);
167 LOG(VB_GENERAL, LOG_INFO,
168 QString(
"Grabber '%1' is not configured. Do you need to set PYTHONPATH?").arg(name));
175 QString tmptype =
type.toLower();
197 for (
const auto& item : std::as_const(list))
198 if (item.GetPath().endsWith(cmd))
203 QString fullcmd = QString(
"%1%2").arg(
GetShareDir(), cmd);
220 for (
const auto& item : std::as_const(list))
222 if (item.GetCommand() == tag)
231 for (
const auto& item : std::as_const(list))
233 if (item.Accepts(tag))
247 static QMutex s_reLock;
248 QMutexLocker lock(&s_reLock);
251 if (match.hasMatch())
252 tag = match.captured(1);
267 static QMutex s_reLock;
268 QMutexLocker lock(&s_reLock);
272 if (match.hasMatch())
273 return match.captured(2);
278 m_fullcommand(
std::move(path))
303 QByteArray result = grabber.
ReadAll();
304 if (result.isEmpty())
309 doc.setContent(result,
true);
310 QDomElement root = doc.documentElement();
346 m_name = item.firstChildElement(
"name").text();
347 m_author = item.firstChildElement(
"author").text();
348 m_thumbnail = item.firstChildElement(
"thumbnail").text();
349 m_command = item.firstChildElement(
"command").text();
350 m_description = item.firstChildElement(
"description").text();
351 m_version = item.firstChildElement(
"version").text().toFloat();
352 m_typestring = item.firstChildElement(
"type").text().toLower();
359 QDomElement accepts = item.firstChildElement(
"accepts");
360 if (!accepts.isNull())
362 while (!accepts.isNull())
365 accepts = accepts.nextSiblingElement(
"accepts");
393 LOG(VB_GENERAL, LOG_INFO, QString(
"Running Grabber: %1 %2")
400 QByteArray result = grabber.
ReadAll();
401 if (!result.isEmpty())
404 doc.setContent(result,
true);
405 QDomElement root = doc.documentElement();
406 QDomElement item = root.firstChildElement(
"item");
408 while (!item.isNull())
412 if (!
tmp->GetCollectionref().isEmpty())
414 tmp->SetCollectionref(QString(
"%1_%2")
420 item = item.nextSiblingElement(
"item");
437 metadataMap[
"name"] =
m_name;
442 metadataMap[
"version"] = QString::number(
m_version);
481 [[maybe_unused]]
const QString &title,
482 const QString &subtitle,
516 << QString::number(season)
517 << QString::number(episode);
MythLocale * GetLocale(void) const
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
@ GENERIC_EXIT_OK
Exited with no error.
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
QHash< QString, QString > InfoMap
QString GetCountryCode() const
QString GetShareDir(void)
uint Wait(std::chrono::seconds timeout=0s)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
QString GetLanguage(void)
Returns two character ISO-639 language descriptor for UI language.
@ kMSRunShell
run process through shell
void Run(std::chrono::seconds timeout=0s)
Runs a command inside the /bin/sh shell. Returns immediately.
@ kMSStdOut
allow access to stdout
QString GetSetting(const QString &key, const QString &defaultval="")