mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-16 15:41:13 +02:00
2023-04-27 Fred Gleason <fredg@paravelsystems.com>
* Removed a 'RDFeed::generateReport()' methods. * Added a 'DownloadRss()' method to the WebAPI. * Added a 'RDXsltEngine' class. * Added a 'Generate Front Report' item to the right-click menu in the 'Podcast Feeds' list in the 'Rivendell Feed List' dialog in rdadmin(1). * Added a 'Generate Back Report' item to the right-click menu in the 'Podcast Feeds' list in the 'Rivendell Feed List' dialog in rdadmin(1). Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
@@ -40,8 +40,8 @@
|
||||
|
||||
#include "rdxport.h"
|
||||
|
||||
size_t __PostRss_Readfunction_Callback(char *buffer,size_t size,size_t nitems,
|
||||
void *userdata)
|
||||
size_t __PostRss_UploadFunction_Callback(char *buffer,size_t size,
|
||||
size_t nitems,void *userdata)
|
||||
{
|
||||
Xport *xport=(Xport *)userdata;
|
||||
|
||||
@@ -57,6 +57,17 @@ size_t __PostRss_Readfunction_Callback(char *buffer,size_t size,size_t nitems,
|
||||
}
|
||||
|
||||
|
||||
size_t __PostRss_DownloadFunction_Callback(char *buffer,size_t size,
|
||||
size_t nitems,void *userdata)
|
||||
{
|
||||
Xport *xport=(Xport *)userdata;
|
||||
|
||||
(xport->xport_curl_data)+=QByteArray(buffer,size*nitems);
|
||||
|
||||
return size*nitems;
|
||||
}
|
||||
|
||||
|
||||
void Xport::SavePodcast()
|
||||
{
|
||||
int cast_id=0;
|
||||
@@ -401,7 +412,7 @@ bool Xport::PostRssElemental(RDFeed *feed,const QDateTime &now,QString *err_msg)
|
||||
//
|
||||
curl_easy_setopt(curl,CURLOPT_URL,feed->feedUrl().toUtf8().constData());
|
||||
curl_easy_setopt(curl,CURLOPT_UPLOAD,1);
|
||||
curl_easy_setopt(curl,CURLOPT_READFUNCTION, __PostRss_Readfunction_Callback);
|
||||
curl_easy_setopt(curl,CURLOPT_READFUNCTION, __PostRss_UploadFunction_Callback);
|
||||
curl_easy_setopt(curl,CURLOPT_READDATA,this);
|
||||
|
||||
curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT);
|
||||
@@ -436,6 +447,117 @@ bool Xport::PostRssElemental(RDFeed *feed,const QDateTime &now,QString *err_msg)
|
||||
}
|
||||
|
||||
|
||||
void Xport::DownloadRss()
|
||||
{
|
||||
CURL *curl=NULL;
|
||||
CURLcode curl_err;
|
||||
char errstr[CURL_ERROR_SIZE];
|
||||
int feed_id=0;
|
||||
QString keyname;
|
||||
QString destpath;
|
||||
QString err_msg;
|
||||
RDFeed *feed=NULL;
|
||||
QString msg="OK";
|
||||
|
||||
QDateTime now=QDateTime::currentDateTime();
|
||||
|
||||
if(!xport_post->getValue("ID",&feed_id)) {
|
||||
XmlExit("Missing ID",400,"podcasts.cpp",LINE_NUMBER);
|
||||
}
|
||||
feed=new RDFeed(feed_id,rda->config(),this);
|
||||
if(!feed->exists()) {
|
||||
XmlExit("No such feed",404,"podcasts.cpp",LINE_NUMBER);
|
||||
}
|
||||
keyname=feed->keyName();
|
||||
|
||||
if(((!rda->user()->editPodcast())||
|
||||
(!rda->user()->feedAuthorized(keyname)))&&
|
||||
(!rda->user()->adminConfig())) {
|
||||
delete feed;
|
||||
XmlExit("No such feed",404,"podcasts.cpp",LINE_NUMBER);
|
||||
}
|
||||
|
||||
if((curl=curl_easy_init())==NULL) {
|
||||
XmlExit("unable to get CURL handle",500,"podcasts.cpp",LINE_NUMBER);
|
||||
}
|
||||
// xport_curl_data=feed->rssXml(err_msg,now).toUtf8();
|
||||
// xport_curl_data_ptr=0;
|
||||
|
||||
//
|
||||
// Authentication Parameters
|
||||
//
|
||||
if((QUrl(feed->feedUrl()).scheme().toLower()=="sftp")&&
|
||||
(!rda->station()->sshIdentityFile().isEmpty())&&feed->purgeUseIdFile()) {
|
||||
//
|
||||
// Enable host key verification
|
||||
//
|
||||
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYHOST,0);
|
||||
|
||||
curl_easy_setopt(curl,CURLOPT_USERNAME,
|
||||
feed->purgeUsername().toUtf8().constData());
|
||||
curl_easy_setopt(curl,CURLOPT_SSH_PRIVATE_KEYFILE,
|
||||
rda->station()->sshIdentityFile().toUtf8().constData());
|
||||
curl_easy_setopt(curl,CURLOPT_KEYPASSWD,
|
||||
feed->purgePassword().toUtf8().constData());
|
||||
rda->syslog(LOG_DEBUG,"using ssh key at \"%s\"",
|
||||
rda->station()->sshIdentityFile().toUtf8().constData());
|
||||
}
|
||||
else {
|
||||
//
|
||||
// Disable host key verification
|
||||
//
|
||||
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYHOST,0);
|
||||
|
||||
curl_easy_setopt(curl,CURLOPT_USERNAME,
|
||||
feed->purgeUsername().toUtf8().constData());
|
||||
curl_easy_setopt(curl,CURLOPT_PASSWORD,
|
||||
feed->purgePassword().toUtf8().constData());
|
||||
}
|
||||
|
||||
//
|
||||
// Transfer Parameters
|
||||
//
|
||||
curl_easy_setopt(curl,CURLOPT_URL,feed->feedUrl().toUtf8().constData());
|
||||
curl_easy_setopt(curl,CURLOPT_UPLOAD,0);
|
||||
xport_curl_data.clear();
|
||||
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,
|
||||
__PostRss_DownloadFunction_Callback);
|
||||
curl_easy_setopt(curl,CURLOPT_WRITEDATA,this);
|
||||
|
||||
curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT);
|
||||
curl_easy_setopt(curl,CURLOPT_NOPROGRESS,1);
|
||||
curl_easy_setopt(curl,CURLOPT_USERAGENT,
|
||||
rda->config()->userAgent().toUtf8().constData());
|
||||
curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errstr);
|
||||
|
||||
//
|
||||
// Execute it
|
||||
//
|
||||
switch((curl_err=curl_easy_perform(curl))) {
|
||||
case CURLE_OK:
|
||||
case CURLE_PARTIAL_FILE:
|
||||
feed->setLastBuildDateTime(now);
|
||||
rda->syslog(LOG_DEBUG,
|
||||
"posted RSS XML to \"%s\"",
|
||||
feed->feedUrl().toUtf8().constData());
|
||||
break;
|
||||
|
||||
default:
|
||||
rda->syslog(LOG_ERR,"RSS XML upload failed: curl error %d [%s]",
|
||||
curl_err,curl_easy_strerror(curl_err));
|
||||
err_msg+=errstr;
|
||||
break;
|
||||
}
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
printf("Content-type: application/rss+xml; charset: UTF-8\n");
|
||||
printf("Status: 200\n\n");
|
||||
printf("%s",xport_curl_data.constData());
|
||||
|
||||
Exit(0);
|
||||
}
|
||||
|
||||
|
||||
void Xport::PostRss()
|
||||
{
|
||||
int feed_id=0;
|
||||
@@ -622,7 +744,7 @@ void Xport::PostImage()
|
||||
//
|
||||
curl_easy_setopt(curl,CURLOPT_URL,desturl.toUtf8().constData());
|
||||
curl_easy_setopt(curl,CURLOPT_UPLOAD,1);
|
||||
curl_easy_setopt(curl,CURLOPT_READFUNCTION, __PostRss_Readfunction_Callback);
|
||||
curl_easy_setopt(curl,CURLOPT_READFUNCTION, __PostRss_UploadFunction_Callback);
|
||||
curl_easy_setopt(curl,CURLOPT_READDATA,this);
|
||||
curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT);
|
||||
curl_easy_setopt(curl,CURLOPT_NOPROGRESS,1);
|
||||
|
@@ -353,6 +353,11 @@ void Xport::ripcConnectedData(bool state)
|
||||
RemovePodcast();
|
||||
break;
|
||||
|
||||
case RDXPORT_COMMAND_DOWNLOAD_RSS:
|
||||
rda->syslog(LOG_DEBUG,"processing RDXPORT_COMMAND_DOWNLOAD_RSS");
|
||||
DownloadRss();
|
||||
break;
|
||||
|
||||
case RDXPORT_COMMAND_POST_RSS:
|
||||
rda->syslog(LOG_DEBUG,"processing RDXPORT_COMMAND_POST_RSS");
|
||||
PostRss();
|
||||
|
@@ -89,6 +89,7 @@ class Xport : public QObject
|
||||
void PostPodcast();
|
||||
void RemovePodcast();
|
||||
bool PostRssElemental(RDFeed *feed,const QDateTime &now,QString *err_msg);
|
||||
void DownloadRss();
|
||||
void PostRss();
|
||||
void RemoveRss();
|
||||
void PostImage();
|
||||
@@ -110,8 +111,11 @@ class Xport : public QObject
|
||||
QHostAddress xport_remote_address;
|
||||
QByteArray xport_curl_data;
|
||||
int xport_curl_data_ptr;
|
||||
friend size_t __PostRss_Readfunction_Callback(char *buffer,size_t size,
|
||||
size_t nitems,void *userdata);
|
||||
friend size_t __PostRss_UploadFunction_Callback(char *buffer,size_t size,
|
||||
size_t nitems,void *userdata);
|
||||
friend size_t __PostRss_DownloadFunction_Callback(char *buffer,size_t size,
|
||||
size_t nitems,
|
||||
void *userdata);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
##
|
||||
## Automake.am for rivendell/web/tests
|
||||
##
|
||||
## (C) Copyright 2010-2020 Fred Gleason <fredg@paravelsystems.com>
|
||||
## (C) Copyright 2010-2023 Fred Gleason <fredg@paravelsystems.com>
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License version 2 as
|
||||
@@ -32,6 +32,7 @@ install-exec-am:
|
||||
cp delete_audio.html $(DESTDIR)@libexecdir@
|
||||
cp deletelog.html $(DESTDIR)@libexecdir@
|
||||
cp deletepodcast.html $(DESTDIR)@libexecdir@
|
||||
cp downloadrss.html $(DESTDIR)@libexecdir@
|
||||
cp editcart.html $(DESTDIR)@libexecdir@
|
||||
cp editcut.js $(DESTDIR)@libexecdir@
|
||||
cp editcut.html $(DESTDIR)@libexecdir@
|
||||
@@ -81,6 +82,7 @@ uninstall-local:
|
||||
rm -f $(DESTDIR)@libexecdir@/delete_audio.html
|
||||
rm -f $(DESTDIR)@libexecdir@/deletelog.html
|
||||
rm -f $(DESTDIR)@libexecdir@/deletepodcast.html
|
||||
rm -f $(DESTDIR)@libexecdir@/downloadrss.html
|
||||
rm -f $(DESTDIR)@libexecdir@/editcart.html
|
||||
rm -f $(DESTDIR)@libexecdir@/editcart.js
|
||||
rm -f $(DESTDIR)@libexecdir@/editcut.html
|
||||
@@ -130,6 +132,7 @@ EXTRA_DIST = addcart.html\
|
||||
delete_audio.html\
|
||||
deletelog.html\
|
||||
deletepodcast.html\
|
||||
downloadrss.html\
|
||||
editcart.html\
|
||||
editcart.js\
|
||||
editcut.html\
|
||||
|
33
web/tests/downloadrss.html
Normal file
33
web/tests/downloadrss.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Rivendell DOWNLOADRSS Service Test Harness</title>
|
||||
<body>
|
||||
<form action="/rd-bin/rdxport.cgi" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="COMMAND" value="46">
|
||||
<table cellpadding="0" cellspacing="2" border="0">
|
||||
<tr>
|
||||
<td align="right">LOGIN NAME:</td>
|
||||
<td><input type="text" name="LOGIN_NAME" size="20" maxlength="255"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">PASSWORD:</td>
|
||||
<td><input type="password" name="PASSWORD" size="20" maxlength="32"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">TICKET:</td>
|
||||
<td><input type="text" name="TICKET" size="40" maxlength="40"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">ID:</td>
|
||||
<td><input type="text" name="ID" size="12" maxlength="12"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="right"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="right"><input type="submit" value="OK"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user