mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-19 09:01:18 +02:00
2022-09-06 Fred Gleason <fredg@paravelsystems.com>
* Added an Online Feed Report to rdcastmanager(1). Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
@@ -21,8 +21,6 @@
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "rdapplication.h"
|
||||
@@ -44,6 +42,19 @@
|
||||
#include "rdwavefile.h"
|
||||
#include "rdxport_interface.h"
|
||||
|
||||
int __RDFeed_Debug_Callback(CURL *handle,curl_infotype type,char *data,
|
||||
size_t size,void *userptr)
|
||||
{
|
||||
QStringList *lines=(QStringList *)userptr;
|
||||
|
||||
if(type==CURLINFO_TEXT) {
|
||||
lines->push_back(QString::fromUtf8(QByteArray(data,size)));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
RDFeed::RDFeed(const QString &keyname,RDConfig *config,QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
@@ -826,6 +837,7 @@ bool RDFeed::postPodcast(unsigned cast_id) const
|
||||
curl_formfree(first);
|
||||
return false;
|
||||
}
|
||||
QStringList *err_msgs=SetupCurlLogging(curl);
|
||||
curl_easy_setopt(curl,CURLOPT_WRITEDATA,stdout);
|
||||
curl_easy_setopt(curl,CURLOPT_HTTPPOST,first);
|
||||
curl_easy_setopt(curl,CURLOPT_USERAGENT,
|
||||
@@ -843,6 +855,7 @@ bool RDFeed::postPodcast(unsigned cast_id) const
|
||||
if((curl_err=curl_easy_perform(curl))!=CURLE_OK) {
|
||||
curl_easy_cleanup(curl);
|
||||
curl_formfree(first);
|
||||
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -857,8 +870,10 @@ bool RDFeed::postPodcast(unsigned cast_id) const
|
||||
// Process the results
|
||||
//
|
||||
if((response_code<200)||(response_code>299)) {
|
||||
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
|
||||
return false;
|
||||
}
|
||||
delete err_msgs;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -931,6 +946,7 @@ bool RDFeed::postXml()
|
||||
curl_formfree(first);
|
||||
return false;
|
||||
}
|
||||
QStringList *err_msgs=SetupCurlLogging(curl);
|
||||
curl_easy_setopt(curl,CURLOPT_WRITEDATA,stdout);
|
||||
curl_easy_setopt(curl,CURLOPT_HTTPPOST,first);
|
||||
curl_easy_setopt(curl,CURLOPT_USERAGENT,
|
||||
@@ -948,6 +964,7 @@ bool RDFeed::postXml()
|
||||
if((curl_err=curl_easy_perform(curl))!=CURLE_OK) {
|
||||
curl_easy_cleanup(curl);
|
||||
curl_formfree(first);
|
||||
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -962,8 +979,10 @@ bool RDFeed::postXml()
|
||||
// Process the results
|
||||
//
|
||||
if((response_code<200)||(response_code>299)) {
|
||||
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
|
||||
return false;
|
||||
}
|
||||
delete err_msgs;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1014,6 +1033,7 @@ bool RDFeed::removeRss()
|
||||
curl_formfree(first);
|
||||
return false;
|
||||
}
|
||||
QStringList *err_msgs=SetupCurlLogging(curl);
|
||||
curl_easy_setopt(curl,CURLOPT_WRITEDATA,stdout);
|
||||
curl_easy_setopt(curl,CURLOPT_HTTPPOST,first);
|
||||
curl_easy_setopt(curl,CURLOPT_USERAGENT,
|
||||
@@ -1031,6 +1051,7 @@ bool RDFeed::removeRss()
|
||||
if((curl_err=curl_easy_perform(curl))!=CURLE_OK) {
|
||||
curl_easy_cleanup(curl);
|
||||
curl_formfree(first);
|
||||
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1045,8 +1066,10 @@ bool RDFeed::removeRss()
|
||||
// Process the results
|
||||
//
|
||||
if((response_code<200)||(response_code>299)) {
|
||||
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
|
||||
return false;
|
||||
}
|
||||
delete err_msgs;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1086,6 +1109,7 @@ bool RDFeed::postImage(int img_id) const
|
||||
curl_formfree(first);
|
||||
return false;
|
||||
}
|
||||
QStringList *err_msgs=SetupCurlLogging(curl);
|
||||
curl_easy_setopt(curl,CURLOPT_WRITEDATA,stdout);
|
||||
curl_easy_setopt(curl,CURLOPT_HTTPPOST,first);
|
||||
curl_easy_setopt(curl,CURLOPT_USERAGENT,
|
||||
@@ -1103,6 +1127,7 @@ bool RDFeed::postImage(int img_id) const
|
||||
if((curl_err=curl_easy_perform(curl))!=CURLE_OK) {
|
||||
curl_easy_cleanup(curl);
|
||||
curl_formfree(first);
|
||||
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1117,8 +1142,10 @@ bool RDFeed::postImage(int img_id) const
|
||||
// Process the results
|
||||
//
|
||||
if((response_code<200)||(response_code>299)) {
|
||||
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
|
||||
return false;
|
||||
}
|
||||
delete err_msgs;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1158,6 +1185,7 @@ bool RDFeed::removeImage(int img_id) const
|
||||
curl_formfree(first);
|
||||
return false;
|
||||
}
|
||||
QStringList *err_msgs=SetupCurlLogging(curl);
|
||||
curl_easy_setopt(curl,CURLOPT_WRITEDATA,stdout);
|
||||
curl_easy_setopt(curl,CURLOPT_HTTPPOST,first);
|
||||
curl_easy_setopt(curl,CURLOPT_USERAGENT,
|
||||
@@ -1175,6 +1203,7 @@ bool RDFeed::removeImage(int img_id) const
|
||||
if((curl_err=curl_easy_perform(curl))!=CURLE_OK) {
|
||||
curl_easy_cleanup(curl);
|
||||
curl_formfree(first);
|
||||
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1189,8 +1218,10 @@ bool RDFeed::removeImage(int img_id) const
|
||||
// Process the results
|
||||
//
|
||||
if((response_code<200)||(response_code>299)) {
|
||||
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
|
||||
return false;
|
||||
}
|
||||
delete err_msgs;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1867,6 +1898,7 @@ bool RDFeed::SavePodcast(unsigned cast_id,const QString &src_filename) const
|
||||
curl_formfree(first);
|
||||
return false;
|
||||
}
|
||||
QStringList *err_msgs=SetupCurlLogging(curl);
|
||||
curl_easy_setopt(curl,CURLOPT_WRITEDATA,stdout);
|
||||
curl_easy_setopt(curl,CURLOPT_HTTPPOST,first);
|
||||
curl_easy_setopt(curl,CURLOPT_USERAGENT,
|
||||
@@ -1884,6 +1916,7 @@ bool RDFeed::SavePodcast(unsigned cast_id,const QString &src_filename) const
|
||||
if((curl_err=curl_easy_perform(curl))!=CURLE_OK) {
|
||||
curl_easy_cleanup(curl);
|
||||
curl_formfree(first);
|
||||
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1898,8 +1931,10 @@ bool RDFeed::SavePodcast(unsigned cast_id,const QString &src_filename) const
|
||||
// Process the results
|
||||
//
|
||||
if((response_code<200)||(response_code>299)) {
|
||||
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
|
||||
return false;
|
||||
}
|
||||
delete err_msgs;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2109,6 +2144,34 @@ QString RDFeed::GetTempFilename() const
|
||||
}
|
||||
|
||||
|
||||
QStringList *RDFeed::SetupCurlLogging(CURL *curl) const
|
||||
{
|
||||
QStringList *err_msgs=new QStringList();
|
||||
|
||||
curl_easy_setopt(curl,CURLOPT_DEBUGFUNCTION,__RDFeed_Debug_Callback);
|
||||
curl_easy_setopt(curl,CURLOPT_DEBUGDATA,err_msgs);
|
||||
curl_easy_setopt(curl,CURLOPT_VERBOSE,1);
|
||||
|
||||
return err_msgs;
|
||||
}
|
||||
|
||||
|
||||
void RDFeed::ProcessCurlLogging(const QString &label,
|
||||
QStringList *err_msgs) const
|
||||
{
|
||||
if(err_msgs->size()>0) {
|
||||
rda->syslog(LOG_ERR,"*** %s: extended CURL information begins ***",
|
||||
label.toUtf8().constData());
|
||||
for(int i=0;i<err_msgs->size();i++) {
|
||||
rda->syslog(LOG_ERR,"[%d]: %s",i,err_msgs->at(i).toUtf8().constData());
|
||||
}
|
||||
rda->syslog(LOG_ERR,"*** %s: extended CURL information ends ***",
|
||||
label.toUtf8().constData());
|
||||
}
|
||||
delete err_msgs;
|
||||
}
|
||||
|
||||
|
||||
void RDFeed::SetRow(const QString ¶m,int value) const
|
||||
{
|
||||
RDSqlQuery *q;
|
||||
|
Reference in New Issue
Block a user