mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-26 14:32:04 +02:00
* Dropped the 'RSS_SCHEMAS' table from the database. * Incremented the database version to 325. * Moved RSS template definitions to 'lib/rdfeed.h'. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
192 lines
8.0 KiB
C++
192 lines
8.0 KiB
C++
// rdfeed.h
|
|
//
|
|
// Abstract a Rivendell RSS Feed
|
|
//
|
|
// (C) Copyright 2002-2020 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
|
|
// published by the Free Software Foundation.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public
|
|
// License along with this program; if not, write to the Free Software
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
//
|
|
|
|
#ifndef RDFEED_H
|
|
#define RDFEED_H
|
|
|
|
#include <qobject.h>
|
|
|
|
#include <rdapplication.h>
|
|
#include <rdconfig.h>
|
|
#include <rdsettings.h>
|
|
#include <rdstation.h>
|
|
#include <rduser.h>
|
|
#include <rdweb.h>
|
|
|
|
//
|
|
// RSS-2.0.2 Templates
|
|
//
|
|
#define RSS_2_0_2_NAME "RSS 2.0.2"
|
|
|
|
#define RSS_2_0_2_IMAGE_MIN_SIZE QSize(88,31)
|
|
#define RSS_2_0_2_IMAGE_MAX_SIZE QSize(144,400)
|
|
#define RSS_2_0_2_IMAGE_IN_ITEM false
|
|
|
|
#define RSS_2_0_2_HEADER_XML "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">"
|
|
|
|
#define RSS_2_0_2_CHANNEL_XML "<title>%TITLE%</title>\n<description>%DESCRIPTION%</description>\n<category>%CATEGORY%</category>\n<link>%LINK%</link>\n<language>%LANGUAGE%</language>\n<copyright>%COPYRIGHT%</copyright>\n<lastBuildDate>%BUILD_DATE%</lastBuildDate>\n<pubDate>%PUBLISH_DATE%</pubDate>\n<managingEditor>%EDITOR%</managingEditor>\n<webMaster>%WEBMASTER%</webMaster>\n<generator>%GENERATOR%</generator>\n<image>\n <url>%IMAGE_URL%</url>\n <title>%TITLE%</title>\n <link>%LINK%</link>\n <width>%IMAGE_WIDTH%</width>\n <height>%IMAGE_HEIGHT%</height>\n <description>%IMAGE_DESCRIPTION%</description>\n</image>\n<atom:link href=\"%FEED_URL%\" rel=\"self\" type=\"application/rss+xml\" />"
|
|
|
|
#define RSS_2_0_2_ITEM_XML "<title>%ITEM_TITLE%</title>\n<link>%ITEM_LINK%</link>\n<guid isPermaLink=\"false\">%ITEM_GUID%</guid>\n<description>%ITEM_DESCRIPTION%</description>\n<author>%ITEM_AUTHOR%</author>\n<comments>%ITEM_COMMENTS%</comments>\n<source url=\"%ITEM_SOURCE_URL%\">%ITEM_SOURCE_TEXT%</source>\n<enclosure url=\"%ITEM_AUDIO_URL%\" length=\"%ITEM_AUDIO_LENGTH%\" type=\"audio/mpeg\" />\n<category>%ITEM_CATEGORY%</category>\n<pubDate>%ITEM_PUBLISH_DATE%</pubDate>"
|
|
|
|
|
|
|
|
#define RDFEED_TOTAL_POST_STEPS 4
|
|
|
|
class RDFeed : public QObject
|
|
{
|
|
Q_OBJECT;
|
|
public:
|
|
enum Error {ErrorOk=0,ErrorNoFile=1,ErrorCannotOpenFile=2,
|
|
ErrorUnsupportedType=3,ErrorUploadFailed=4,ErrorGeneral=5};
|
|
enum MediaLinkMode {LinkNone=0,LinkDirect=1,LinkCounted=2};
|
|
enum RssSchema {CustomSchema=0,Rss202Schema=1,LastSchema=2};
|
|
RDFeed(const QString &keyname,RDConfig *config,QObject *parent=0);
|
|
RDFeed(unsigned id,RDConfig *config,QObject *parent=0);
|
|
QString keyName() const;
|
|
unsigned id() const;
|
|
bool exists() const;
|
|
bool isSuperfeed() const;
|
|
void setIsSuperfeed(bool state) const;
|
|
QStringList isSubfeedOf() const;
|
|
bool audienceMetrics() const;
|
|
void setAudienceMetrics(bool state);
|
|
QString channelTitle() const;
|
|
void setChannelTitle(const QString &str) const;
|
|
QString channelDescription() const;
|
|
void setChannelDescription(const QString &str) const;
|
|
QString channelCategory() const;
|
|
void setChannelCategory(const QString &str) const;
|
|
QString channelLink() const;
|
|
void setChannelLink(const QString &str) const;
|
|
QString channelCopyright() const;
|
|
void setChannelCopyright(const QString &str) const;
|
|
QString channelEditor() const;
|
|
void setChannelEditor(const QString &str) const;
|
|
QString channelWebmaster() const;
|
|
void setChannelWebmaster(const QString &str) const;
|
|
QString channelLanguage() const;
|
|
void setChannelLanguage(const QString &str);
|
|
int channelImageId() const;
|
|
void setChannelImageId(int img_id) const;
|
|
int defaultItemImageId() const;
|
|
void setDefaultItemImageId(int img_id) const;
|
|
QString baseUrl(const QString &subfeed_key_name) const;
|
|
QString baseUrl(int subfeed_feed_id) const;
|
|
void setBaseUrl(const QString &str) const;
|
|
QString basePreamble() const;
|
|
void setBasePreamble(const QString &str) const;
|
|
QString purgeUrl() const;
|
|
void setPurgeUrl(const QString &str) const;
|
|
QString purgeUsername() const;
|
|
void setPurgeUsername(const QString &str) const;
|
|
QString purgePassword() const;
|
|
void setPurgePassword(const QString &str) const;
|
|
RssSchema rssSchema() const;
|
|
void setRssSchema(RssSchema schema) const;
|
|
QString headerXml() const;
|
|
void setHeaderXml(const QString &str);
|
|
QString channelXml() const;
|
|
void setChannelXml(const QString &str);
|
|
QString itemXml() const;
|
|
void setItemXml(const QString &str);
|
|
QString feedUrl() const;
|
|
bool castOrder() const;
|
|
void setCastOrder(bool state) const;
|
|
int maxShelfLife() const;
|
|
void setMaxShelfLife(int days);
|
|
QDateTime lastBuildDateTime() const;
|
|
void setLastBuildDateTime(const QDateTime &datetime) const;
|
|
QDateTime originDateTime() const;
|
|
void setOriginDateTime(const QDateTime &datetime) const;
|
|
bool enableAutopost() const;
|
|
void setEnableAutopost(bool state) const;
|
|
bool keepMetadata() const;
|
|
void setKeepMetadata(bool state);
|
|
RDSettings::Format uploadFormat() const;
|
|
void setUploadFormat(RDSettings::Format fmt) const;
|
|
int uploadChannels() const;
|
|
void setUploadChannels(int chans) const;
|
|
int uploadQuality() const;
|
|
void setUploadQuality(int qual) const;
|
|
int uploadBitRate() const;
|
|
void setUploadBitRate(int rate) const;
|
|
int uploadSampleRate() const;
|
|
void setUploadSampleRate(int rate) const;
|
|
QString uploadExtension() const;
|
|
void setUploadExtension(const QString &str);
|
|
QString uploadMimetype() const;
|
|
void setUploadMimetype(const QString &str);
|
|
int normalizeLevel() const;
|
|
void setNormalizeLevel(int lvl) const;
|
|
QString redirectPath() const;
|
|
void setRedirectPath(const QString &str);
|
|
RDFeed::MediaLinkMode mediaLinkMode() const;
|
|
void setMediaLinkMode(RDFeed::MediaLinkMode mode) const;
|
|
int importImageFile(const QString &pathname,QString *err_msg,
|
|
QString desc="") const;
|
|
bool deleteImage(int img_id,QString *err_msg);
|
|
QString audioUrl(RDFeed::MediaLinkMode mode,const QString &cgi_hostname,
|
|
unsigned cast_id);
|
|
QString imageUrl(int img_id) const;
|
|
bool postXml(QString *err_msg);
|
|
bool postXmlConditional(const QString &caption,QWidget *widget);
|
|
bool deleteXml(QString *err_msg);
|
|
unsigned postCut(RDUser *user,RDStation *station,
|
|
const QString &cutname,Error *err,bool log_debug,
|
|
RDConfig *config);
|
|
unsigned postFile(RDStation *station,const QString &srcfile,Error *err,
|
|
bool log_debug,RDConfig *config);
|
|
int totalPostSteps() const;
|
|
QString rssXml(QString *err_msg,bool *ok=NULL);
|
|
static unsigned create(const QString &keyname,bool enable_users,
|
|
QString *err_msg,const QString &exemplar="");
|
|
static QString errorString(RDFeed::Error err);
|
|
static QString rssSchemaString(RDFeed::RssSchema schema);
|
|
static QString rssHeaderTemplate(RssSchema schema);
|
|
static QString rssChannelTemplate(RssSchema schema);
|
|
static QString rssItemTemplate(RssSchema schema);
|
|
static QString imageFilename(int feed_id,int img_id,const QString &ext);
|
|
|
|
signals:
|
|
void postProgressChanged(int step);
|
|
|
|
private:
|
|
unsigned CreateCast(QString *filename,int bytes,int msecs) const;
|
|
QString ResolveChannelWildcards(const QString &tmplt,RDSqlQuery *chan_q);
|
|
QString ResolveItemWildcards(const QString &tmplt,RDSqlQuery *item_q,
|
|
RDSqlQuery *chan_q);
|
|
QString GetTempFilename() const;
|
|
void SetRow(const QString ¶m,int value) const;
|
|
void SetRow(const QString ¶m,const QString &value) const;
|
|
void SetRow(const QString ¶m,const QDateTime &value,
|
|
const QString &format) const;
|
|
QString feed_keyname;
|
|
unsigned feed_id;
|
|
QString feed_cgi_hostname;
|
|
RDConfig *feed_config;
|
|
QByteArray feed_xml;
|
|
int feed_xml_ptr;
|
|
friend size_t __RDFeed_Readfunction_Callback(char *buffer,size_t size,
|
|
size_t nitems,void *userdata);
|
|
};
|
|
|
|
|
|
#endif // RDFEED_H
|