mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-19 14:43:30 +02:00
2021-09-16 Fred Gleason <fredg@paravelsystems.com>
* Added a ' SaveWebgetFilesDirectory=' directive to rd.conf(5). Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
2666c2998e
commit
1bf1d94bfe
@ -22427,3 +22427,5 @@
|
||||
2021-09-13 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added an 'RDGroups::create()' static method.
|
||||
* Added an 'RDGroups::remove()' static method.
|
||||
2021-09-16 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added a ' SaveWebgetFilesDirectory=' directive to rd.conf(5).
|
||||
|
@ -188,3 +188,12 @@ TranscodingDelay=0
|
||||
; dropboxes configured. Rivendell imposes a hard limit of 999 on this
|
||||
; setting.
|
||||
; MeterPortRange=100
|
||||
|
||||
; Save original files processed by the Webget service to the indicated
|
||||
; directory. Files so saved will have the date-time that the file was
|
||||
; processed prepended to the original filename, for example:
|
||||
;
|
||||
; myfile.mp3 => YYYYMMDD-HHMMSS-myfile.mp3
|
||||
;
|
||||
; Default action is to not save files.
|
||||
; SaveWebgetFilesDirectory=
|
||||
|
@ -387,6 +387,12 @@ bool RDConfig::lockRdairplayMemory() const
|
||||
}
|
||||
|
||||
|
||||
QString RDConfig::saveWebgetFilesDirectory() const
|
||||
{
|
||||
return conf_save_webget_files_directory;
|
||||
}
|
||||
|
||||
|
||||
int RDConfig::meterBasePort() const
|
||||
{
|
||||
return conf_meter_base_port;
|
||||
@ -607,7 +613,9 @@ bool RDConfig::load()
|
||||
|
||||
conf_disable_maint_checks=
|
||||
profile->boolValue("Hacks","DisableMaintChecks",false);
|
||||
conf_lock_rdairplay_memory=
|
||||
conf_save_webget_files_directory=
|
||||
profile->stringValue("Hacks","SaveWebgetFilesDirectory");
|
||||
conf_lock_rdairplay_memory=
|
||||
profile->boolValue("Hacks","LockRdairplayMemory",false);
|
||||
conf_meter_base_port=
|
||||
profile->intValue("Hacks","MeterPortBaseNumber",RD_DEFAULT_METER_SOCKET_BASE_UDP_PORT);
|
||||
@ -736,6 +744,7 @@ void RDConfig::clear()
|
||||
conf_jack_ports[0].clear();
|
||||
conf_jack_ports[1].clear();
|
||||
conf_disable_maint_checks=false;
|
||||
conf_save_webget_files_directory="";
|
||||
conf_lock_rdairplay_memory=false;
|
||||
conf_meter_base_port=RD_DEFAULT_METER_SOCKET_BASE_UDP_PORT;
|
||||
conf_meter_port_range=RD_METER_SOCKET_PORT_RANGE;
|
||||
|
@ -103,6 +103,7 @@ class RDConfig
|
||||
bool lockRdairplayMemory() const;
|
||||
int meterBasePort() const;
|
||||
int meterPortRange() const;
|
||||
QString saveWebgetFilesDirectory() const;
|
||||
bool enableMixerLogging() const;
|
||||
uid_t uid() const;
|
||||
gid_t gid() const;
|
||||
@ -174,6 +175,7 @@ class RDConfig
|
||||
QString conf_http_user_agent;
|
||||
bool conf_disable_maint_checks;
|
||||
bool conf_lock_rdairplay_memory;
|
||||
QString conf_save_webget_files_directory;
|
||||
int conf_meter_base_port;
|
||||
int conf_meter_port_range;
|
||||
std::vector<QString> conf_jack_ports[2];
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <ctype.h>
|
||||
#include <stdint.h>
|
||||
@ -473,6 +474,9 @@ void MainObject::PutAudio()
|
||||
//
|
||||
QStringList args;
|
||||
|
||||
if(!rda->config()->saveWebgetFilesDirectory().isEmpty()) {
|
||||
SaveSourceFile(filename);
|
||||
}
|
||||
args.push_back(QString("--ticket=")+webget_ticket+":"+
|
||||
webget_post->clientAddress().toString());
|
||||
args.push_back("--send-mail");
|
||||
@ -770,6 +774,67 @@ bool MainObject::Authenticate()
|
||||
}
|
||||
|
||||
|
||||
void MainObject::SaveSourceFile(const QString &filepath) const
|
||||
{
|
||||
char buffer[1024];
|
||||
ssize_t n;
|
||||
int src_fd=-1;
|
||||
int dst_fd=-1;
|
||||
QDir dir(rda->config()->saveWebgetFilesDirectory());
|
||||
if(!dir.exists()) {
|
||||
rda->syslog(LOG_WARNING,"SaveWebgetFilesDirectory \"%s\" does not exist",
|
||||
rda->config()->saveWebgetFilesDirectory().toUtf8().constData());
|
||||
return;
|
||||
}
|
||||
QDateTime now=QDateTime::currentDateTime();
|
||||
QStringList f0=filepath.split("/",QString::SkipEmptyParts);
|
||||
QString filename=rda->config()->saveWebgetFilesDirectory()+"/"+
|
||||
now.toString("yyyyMMdd-hhmmss-")+f0.last();
|
||||
|
||||
//
|
||||
// Open Source File
|
||||
//
|
||||
if((src_fd=open(filepath.toUtf8(),O_RDONLY))<0) {
|
||||
rda->syslog(LOG_WARNING,
|
||||
"unable to open source file \"%s\" for SaveWebgetFilesDirectory [%s]",
|
||||
filepath.toUtf8().constData(),strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Open Destination File
|
||||
//
|
||||
int num=1;
|
||||
while((dst_fd=open(filename.toUtf8(),O_WRONLY|O_CREAT|O_EXCL,S_IRUSR|S_IRGRP))<0) {
|
||||
if(errno!=EEXIST) {
|
||||
rda->syslog(LOG_WARNING,
|
||||
"unable to open destination file \"%s\" for SaveWebgetFilesDirectory [%s]",
|
||||
filename.toUtf8().constData(),strerror(errno));
|
||||
close(src_fd);
|
||||
return;
|
||||
}
|
||||
filename=rda->config()->saveWebgetFilesDirectory()+"/"+
|
||||
now.toString("yyyyMMdd-hhmmss")+QString().sprintf("[%d]-",num)+f0.last();
|
||||
num++;
|
||||
}
|
||||
|
||||
//
|
||||
// Move the data
|
||||
//
|
||||
while((n=read(src_fd,buffer,1024))>0) {
|
||||
write(dst_fd,buffer,n);
|
||||
}
|
||||
if(n<0) {
|
||||
rda->syslog(LOG_WARNING,"error while reading source file \"%s\" for SaveWebgetFilesDirectory [%s]",
|
||||
filepath.toUtf8().constData(),strerror(errno));
|
||||
}
|
||||
close(src_fd);
|
||||
close(dst_fd);
|
||||
rda->syslog(LOG_INFO,"saved Webget file \"%s\"",
|
||||
filename.toUtf8().constData());
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Exit(int code)
|
||||
{
|
||||
if(webget_post!=NULL) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Rivendell audio upload/download utility
|
||||
//
|
||||
// (C) Copyright 2018-2020 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2018-2021 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
|
||||
@ -21,7 +21,7 @@
|
||||
#ifndef WEBGET_H
|
||||
#define WEBGET_H
|
||||
|
||||
#include <qobject.h>
|
||||
#include <QObject>
|
||||
|
||||
#include <rdaudioconvert.h>
|
||||
#include <rdformpost.h>
|
||||
@ -46,6 +46,7 @@ class MainObject : public QObject
|
||||
void ServeForm();
|
||||
void ServeLogin(int resp_code);
|
||||
bool Authenticate();
|
||||
void SaveSourceFile(const QString &filepath) const;
|
||||
void Exit(int code);
|
||||
void TextExit(const QString &msg,int code,int line) const;
|
||||
RDFormPost *webget_post;
|
||||
|
Loading…
x
Reference in New Issue
Block a user