Go to the documentation of this file.
2 #include <QCoreApplication>
18 #define LOC QString("NetContent: ")
24 const bool search,
const bool tree,
25 const QString& description,
const QString& commandline,
48 QMutexLocker locker(&
m_lock);
58 LOG(VB_GENERAL, LOG_ERR,
LOC +
59 QString(
"Internet Content Source %1 cannot run, file missing.")
64 LOG(VB_GENERAL, LOG_INFO,
LOC +
65 QString(
"Internet Content Source %1 completed download, "
66 "beginning processing...").arg(
m_title));
68 QByteArray result = getTree.
ReadAll();
71 domDoc.setContent(result,
true);
72 QDomElement root = domDoc.documentElement();
73 QDomElement channel = root.firstChildElement(
"channel");
77 while (!channel.isNull())
80 channel = channel.nextSiblingElement(
"channel");
83 LOG(VB_GENERAL, LOG_INFO,
LOC +
84 QString(
"Internet Content Source %1 completed processing, "
85 "marking as updated.").arg(
m_title));
89 LOG(VB_GENERAL, LOG_ERR,
LOC +
90 QString(
"Internet Content Source %1 crashed while grabbing tree.")
100 const QString &pathThumb, QDomElement& domElem,
103 QMutexLocker locker(&
m_lock);
109 QDomElement fileitem = domElem.firstChildElement(
"item");
110 while (!fileitem.isNull())
113 fileitem = fileitem.nextSiblingElement(
"item");
116 while (!articles.isEmpty())
119 pathThumb, articles.takeFirst(),
type);
123 QDomElement diritem = domElem.firstChildElement(
"directory");
124 while (!diritem.isNull())
126 QDomElement subfolder = diritem;
127 QString dirname = diritem.attribute(
"name");
128 QString dirthumb = diritem.attribute(
"thumbnail");
129 dirname.replace(
"/",
"|");
135 pathToUse = QString(
"%1/%2").arg(path, dirname);
142 diritem = diritem.nextSiblingElement(
"directory");
181 QMutexLocker locker(&
m_lock);
225 "netsite.updateFreq", 24h);
232 LOG(VB_GENERAL, LOG_INFO,
LOC +
233 QString(
"Internet Content Source %1 Updating...")
261 const QString &pagenum)
265 LOG(VB_GENERAL, LOG_DEBUG,
"Search::executeSearch");
273 const QString& cmd = script;
277 if (!pagenum.isEmpty())
279 args.append(QString(
"-p"));
280 args.append(pagenum);
284 const QString& term = query;
287 LOG(VB_GENERAL, LOG_INFO,
LOC +
288 QString(
"Internet Search Query: %1 %2").arg(cmd,
args.join(
" ")));
306 QDomNodeList entries =
m_document.elementsByTagName(
"channel");
308 if (entries.count() == 0)
316 QDomNode itemNode = entries.item(0);
318 QDomNode Node = itemNode.namedItem(QString(
"numresults"));
325 QDomNodeList count =
m_document.elementsByTagName(
"item");
327 if (count.count() == 0)
333 Node = itemNode.namedItem(QString(
"returned"));
340 QDomNodeList items =
m_document.elementsByTagName(
"item");
342 if (items.count() == 0)
348 Node = itemNode.namedItem(QString(
"startindex"));
351 m_numIndex = Node.toElement().text().toUInt();
356 Node = itemNode.namedItem(QString(
"nextpagetoken"));
364 Node = itemNode.namedItem(QString(
"prevpagetoken"));
377 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Internet Search Timeout");
395 LOG(VB_GENERAL, LOG_INFO,
LOC +
396 "Internet Search Successfully Completed");
bool needsUpdate(GrabberScript *script, std::chrono::hours updateFreq)
const ArticleType & GetType() const
MythSystemLegacy * m_searchProcess
void finishedSearch(Search *item)
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
#define GENERIC_EXIT_OK
Exited with no error.
bool insertTreeArticleInDB(const QString &feedtitle, const QString &path, const QString &paththumb, ResultItem *item, ArticleType type)
void Term(bool force=false)
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
std::chrono::hours m_updateFreq
ResultItem::resultList m_videoList
GrabberScript(const QString &title, const QString &image, ArticleType type, const QString &author, bool search, bool tree, const QString &description, const QString &commandline, double version)
const QString & GetTitle() const
void parseDBTree(const QString &feedtitle, const QString &path, const QString &pathThumb, QDomElement &domElem, ArticleType type)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
void SetData(QByteArray data)
GrabberDownloadThread(QObject *parent)
GrabberScript::scriptList findAllDBTreeGrabbers()
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
bool markTreeUpdated(GrabberScript *script, const QDateTime &curTime)
void SetCommand(const QString &command, uint flags)
Resets an existing MythSystemLegacy object to a new command.
static QString ShellEscape(const QString &in)
std::enable_if_t< std::chrono::__is_duration< T >::value, T > GetDurSetting(const QString &key, T defaultval=T::zero())
uint Wait(std::chrono::seconds timeout=0s)
#define GENERIC_EXIT_CMD_NOT_FOUND
Command not found.
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
GrabberDownloadThread * gdt
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
#define GENERIC_EXIT_TIMEOUT
Process timed out.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
@ kMSRunShell
run process through shell
@ kMSRunBackground
run child in the background
~GrabberManager() override
~GrabberScript() override
bool clearTreeItems(const QString &feedcommand)
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
static ResultItem * ParseItem(const QDomElement &item)
void searchTimedOut(Search *item)
~GrabberDownloadThread() override
void slotProcessSearchExit(void)
This is a wrapper around QThread that does several additional things.
bool isRunning(void) const
QList< ResultItem * > resultList
QList< GrabberScript * > m_scripts
static ResultItem::resultList parseRSS(const QDomDocument &domDoc)
void Run(std::chrono::seconds timeout=0s)
Runs a command inside the /bin/sh shell. Returns immediately.
void executeSearch(const QString &script, const QString &query, const QString &pagenum="")
@ kMSStdOut
allow access to stdout