Go to the documentation of this file.
2 #include <QCoreApplication>
19 #define LOC QString("NetContent: ")
25 const bool search,
const bool tree,
26 const QString& description,
const QString& commandline,
49 QMutexLocker locker(&
m_lock);
59 LOG(VB_GENERAL, LOG_ERR,
LOC +
60 QString(
"Internet Content Source %1 cannot run, file missing.")
65 LOG(VB_GENERAL, LOG_INFO,
LOC +
66 QString(
"Internet Content Source %1 completed download, "
69 QByteArray result = getTree.
ReadAll();
72 domDoc.setContent(result,
true);
73 QDomElement
root = domDoc.documentElement();
74 QDomElement
channel =
root.firstChildElement(
"channel");
84 LOG(VB_GENERAL, LOG_INFO,
LOC +
85 QString(
"Internet Content Source %1 completed processing, "
90 LOG(VB_GENERAL, LOG_ERR,
LOC +
91 QString(
"Internet Content Source %1 crashed while grabbing tree.")
101 const QString &pathThumb, QDomElement& domElem,
104 QMutexLocker locker(&
m_lock);
110 QDomElement fileitem = domElem.firstChildElement(
"item");
111 while (!fileitem.isNull())
113 articles.append(parse.
ParseItem(fileitem));
114 fileitem = fileitem.nextSiblingElement(
"item");
117 while (!articles.isEmpty())
120 pathThumb, articles.takeFirst(),
type);
124 QDomElement diritem = domElem.firstChildElement(
"directory");
125 while (!diritem.isNull())
127 QDomElement subfolder = diritem;
128 QString dirname = diritem.attribute(
"name");
129 QString dirthumb = diritem.attribute(
"thumbnail");
130 dirname.replace(
"/",
"|");
136 pathToUse = QString(
"%1/%2").arg(path).arg(dirname);
143 diritem = diritem.nextSiblingElement(
"directory");
150 "netsite.updateFreq", 24) * 3600 * 1000);
183 QMutexLocker locker(&
m_lock);
227 "netsite.updateFreq", 24);
234 LOG(VB_GENERAL, LOG_INFO,
LOC +
235 QString(
"Internet Content Source %1 Updating...")
263 const QString &pagenum)
267 LOG(VB_GENERAL, LOG_DEBUG,
"Search::executeSearch");
275 const QString& cmd = script;
279 if (!pagenum.isEmpty())
281 args.append(QString(
"-p"));
282 args.append(pagenum);
286 const QString& term =
query;
289 LOG(VB_GENERAL, LOG_INFO,
LOC +
290 QString(
"Internet Search Query: %1 %2").
arg(cmd).
arg(
args.join(
" ")));
308 QDomNodeList entries =
m_document.elementsByTagName(
"channel");
310 if (entries.count() == 0)
318 QDomNode itemNode = entries.item(0);
320 QDomNode Node = itemNode.namedItem(QString(
"numresults"));
327 QDomNodeList count =
m_document.elementsByTagName(
"item");
329 if (count.count() == 0)
335 Node = itemNode.namedItem(QString(
"returned"));
342 QDomNodeList items =
m_document.elementsByTagName(
"item");
344 if (items.count() == 0)
350 Node = itemNode.namedItem(QString(
"startindex"));
353 m_numIndex = Node.toElement().text().toUInt();
358 Node = itemNode.namedItem(QString(
"nextpagetoken"));
366 Node = itemNode.namedItem(QString(
"prevpagetoken"));
379 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Internet Search Timeout");
397 LOG(VB_GENERAL, LOG_INFO,
LOC +
398 "Internet Search Successfully Completed");
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)
ResultItem::resultList m_videoList
arg(title).arg(filename).arg(doDelete))
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)
void Run(time_t timeout=0)
Runs a command inside the /bin/sh shell. Returns immediately.
GrabberScript::scriptList findAllDBTreeGrabbers()
bool needsUpdate(GrabberScript *script, uint updateFreq)
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.
ResultItem * ParseItem(const QDomElement &item) const
static QString ShellEscape(const QString &in)
#define GENERIC_EXIT_CMD_NOT_FOUND
Command not found.
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
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.
int GetNumSetting(const QString &key, int defaultval=0)
@ kMSRunShell
run process through shell
@ kMSRunBackground
run child in the background
~GrabberManager() override
GrabberDownloadThread * gdt
~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.
void searchTimedOut(Search *item)
~GrabberDownloadThread() override
ResultItem::resultList parseRSS(const QDomDocument &domDoc) const
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
bool wait(unsigned long time=ULONG_MAX)
Wait for the MThread to exit, with a maximum timeout.
void executeSearch(const QString &script, const QString &query, const QString &pagenum="")
MSqlQuery query(MSqlQuery::InitCon())
@ kMSStdOut
allow access to stdout
uint Wait(time_t timeout=0)