mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-09-15 16:00:23 +02:00
2016-04-27 Brian McGlynn <brian.mcglynn@geneseemedia.net>
* Added a 'bitRate' field in the return for the AudioInfo web method. * Added an rdexport(1) utility in 'utils/rdexport/'.
This commit is contained in:
parent
20101e168c
commit
687a8c6fc8
1
.gitignore
vendored
1
.gitignore
vendored
@ -98,6 +98,7 @@ utils/rddelete/rddelete
|
||||
utils/rdgpimon/rdgpimon
|
||||
utils/rdimport/rdimport
|
||||
utils/rdcollect/rdcollect
|
||||
utils/rdexport/rdexport
|
||||
utils/rdmaint/rdmaint
|
||||
utils/rdgen/rdgen
|
||||
utils/rdrevert/rdrevert
|
||||
|
@ -15101,3 +15101,6 @@
|
||||
2016-04-26 Brian McGlynn <brian.mcglynn@geneseemedia.net>
|
||||
* Updated Cart Scheduler to favor weighted playback for cuts expiring
|
||||
first following the number of plays
|
||||
2016-04-27 Brian McGlynn <brian.mcglynn@geneseemedia.net>
|
||||
* Added a 'bitRate' field in the return for the AudioInfo web method.
|
||||
* Added an rdexport(1) utility in 'utils/rdexport/'.
|
||||
|
@ -458,9 +458,10 @@ AC_CONFIG_FILES([rivendell.spec \
|
||||
utils/rddelete/Makefile \
|
||||
utils/rddgimport/Makefile \
|
||||
utils/rddiscimport/Makefile \
|
||||
utils/rdexport/Makefile \
|
||||
utils/rdgen/Makefile \
|
||||
utils/rdhpiinfo/Makefile \
|
||||
utils/rdgpimon/Makefile \
|
||||
utils/rdhpiinfo/Makefile \
|
||||
utils/rdimport/Makefile \
|
||||
utils/rdmaint/Makefile \
|
||||
utils/rdmarkerset/Makefile \
|
||||
|
@ -34,6 +34,7 @@
|
||||
all-local: cae.html\
|
||||
cae.pdf\
|
||||
rdrevert.8\
|
||||
rdexport.1\
|
||||
rml.html\
|
||||
rml.pdf\
|
||||
web_api.html\
|
||||
@ -46,6 +47,8 @@ EXTRA_DIST = cae.html\
|
||||
cae.xml\
|
||||
rdrevert.8\
|
||||
rdrevert.xml\
|
||||
rdexport.8\
|
||||
rdexport.xml\
|
||||
rml.html\
|
||||
rml.pdf\
|
||||
rml.xml\
|
||||
|
220
docs/docbook/rdexport.xml
Normal file
220
docs/docbook/rdexport.xml
Normal file
@ -0,0 +1,220 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<refentry id="stdin" xmlns="http://docbook.org/ns/docbook" version="5.0">
|
||||
<!--
|
||||
Header
|
||||
-->
|
||||
<refmeta>
|
||||
<refentrytitle>rdexport</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo class='source'>April 2016</refmiscinfo>
|
||||
<refmiscinfo class='manual'>Linux Audio Manual</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>rdexport</refname>
|
||||
<refpurpose>Export audio from a Rivendell audio store</refpurpose>
|
||||
</refnamediv>
|
||||
<info>
|
||||
<author>
|
||||
<personname>
|
||||
<firstname>Fred</firstname>
|
||||
<surname>Gleason</surname>
|
||||
<email>fredg@paravelsystems.com</email>
|
||||
</personname>
|
||||
<contrib>Application Author</contrib>
|
||||
</author>
|
||||
</info>
|
||||
|
||||
<!--
|
||||
Body
|
||||
-->
|
||||
<refsynopsisdiv id='synopsis'>
|
||||
<cmdsynopsis>
|
||||
<command>rdexport</command>
|
||||
<arg choice='opt'><replaceable>OPTIONS</replaceable></arg>
|
||||
<arg choice='req'><replaceable>output-dir</replaceable></arg>
|
||||
<sbr/>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id='description'><title>Description</title>
|
||||
<para>
|
||||
<command>rdexport</command><manvolnum>1</manvolnum> can be used to export
|
||||
audio from a Rivendell audio store.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='options'><title>Options</title>
|
||||
<variablelist remap='TP'>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--carts=</option><replaceable>start-cart</replaceable>:<replaceable>end-cart</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specify a range of cart numbers to be exported, from
|
||||
<replaceable>start-cart</replaceable> to
|
||||
<replaceable>end-cart</replaceable> (both inclusive). This option
|
||||
may be given multiple times.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--group=</option><replaceable>group-name</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specify a group to be exported. This option may be given multiple
|
||||
times.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--metadata-pattern=</option><replaceable>pattern</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specify a pattern to define how output files should be named.
|
||||
Patterns consist of characters interspersed with zero or more
|
||||
wildcard characters as follows:
|
||||
</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>%a</term>
|
||||
<listitem>
|
||||
<para>Artist</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>%b</term>
|
||||
<listitem>
|
||||
<para>Record Label</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%c</term>
|
||||
<listitem>
|
||||
<para>Client</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%e</term>
|
||||
<listitem>
|
||||
<para>Agency</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%g</term>
|
||||
<listitem>
|
||||
<para>Rivendell group name</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%h</term>
|
||||
<listitem>
|
||||
<para>Event length in milliseconds</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%i</term>
|
||||
<listitem>
|
||||
<para>Cut Description</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%j</term>
|
||||
<listitem>
|
||||
<para>Cut Number</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%l</term>
|
||||
<listitem>
|
||||
<para>Album</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%m</term>
|
||||
<listitem>
|
||||
<para>Composer</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%n</term>
|
||||
<listitem>
|
||||
<para>Cart Number</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%o</term>
|
||||
<listitem>
|
||||
<para>Outcue</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%p</term>
|
||||
<listitem>
|
||||
<para>Publisher</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%r</term>
|
||||
<listitem>
|
||||
<para>Conductor</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%s</term>
|
||||
<listitem>
|
||||
<para>Song ID</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%t</term>
|
||||
<listitem>
|
||||
<para>Title</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%u</term>
|
||||
<listitem>
|
||||
<para>User Defined</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>%y</term>
|
||||
<listitem>
|
||||
<para>Release Year</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<para>
|
||||
Default value is <userinput>%n_%j</userinput>.
|
||||
</para>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
@ -16,7 +16,7 @@ Now Next Field
|
||||
%g %G The Rivendell group name
|
||||
%h %H Event length (in milliseconds)
|
||||
%i %I Cut Description
|
||||
%j %J [Unassigned]
|
||||
%j %J Cut Number
|
||||
%k %K [Unassigned]
|
||||
%l %L Album
|
||||
%m %M Composer
|
||||
|
@ -58,6 +58,7 @@ RDAudioInfo::RDAudioInfo(RDStation *station,RDConfig *config,
|
||||
conv_format=RDWaveFile::Pcm16;
|
||||
conv_channels=0;
|
||||
conv_sample_rate=0;
|
||||
conv_bit_rate=0;
|
||||
conv_frames=0;
|
||||
conv_length=0;
|
||||
}
|
||||
@ -81,6 +82,12 @@ unsigned RDAudioInfo::sampleRate() const
|
||||
}
|
||||
|
||||
|
||||
unsigned RDAudioInfo::bitRate() const
|
||||
{
|
||||
return conv_bit_rate;
|
||||
}
|
||||
|
||||
|
||||
unsigned RDAudioInfo::frames() const
|
||||
{
|
||||
return conv_frames;
|
||||
@ -183,6 +190,7 @@ RDAudioInfo::ErrorCode RDAudioInfo::runInfo(const QString &username,
|
||||
conv_format=(RDWaveFile::Format)ParseInt("format",conv_xml);
|
||||
conv_channels=ParseInt("channels",conv_xml);
|
||||
conv_sample_rate=ParseInt("sampleRate",conv_xml);
|
||||
conv_bit_rate=ParseInt("bitRate",conv_xml);
|
||||
conv_frames=ParseInt("frames",conv_xml);
|
||||
conv_length=ParseInt("length",conv_xml);
|
||||
|
||||
|
@ -40,6 +40,7 @@ class RDAudioInfo : public QObject
|
||||
RDWaveFile::Format format() const;
|
||||
unsigned channels() const;
|
||||
unsigned sampleRate() const;
|
||||
unsigned bitRate() const;
|
||||
unsigned frames() const;
|
||||
unsigned length() const;
|
||||
void setCartNumber(unsigned cartnum);
|
||||
@ -57,6 +58,7 @@ class RDAudioInfo : public QObject
|
||||
RDWaveFile::Format conv_format;
|
||||
unsigned conv_channels;
|
||||
unsigned conv_sample_rate;
|
||||
unsigned conv_bit_rate;
|
||||
unsigned conv_frames;
|
||||
unsigned conv_length;
|
||||
QString conv_xml;
|
||||
|
@ -285,6 +285,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
@WIN32_PATH@
|
||||
/etc/pam.d/rdalsaconfig-root
|
||||
/etc/security/console.apps/rdalsaconfig-root
|
||||
%{_mandir}/man1/rdexport.1.gz
|
||||
%{_mandir}/man1/rdimport.1.gz
|
||||
%{_mandir}/man8/rdmarkerset.8.gz
|
||||
%{_mandir}/man8/rdrevert.8.gz
|
||||
|
@ -36,6 +36,7 @@ SUBDIRS = $(ALSACONFIG_RD_OPT)\
|
||||
rdcollect\
|
||||
rddelete\
|
||||
rddiscimport\
|
||||
rdexport\
|
||||
rdgen\
|
||||
rdgpimon\
|
||||
rdimport\
|
||||
|
48
utils/rdexport/Makefile.am
Normal file
48
utils/rdexport/Makefile.am
Normal file
@ -0,0 +1,48 @@
|
||||
## automake.am
|
||||
##
|
||||
## Automake.am for rivendell/utils/rdexport
|
||||
##
|
||||
## (C) Copyright 2016 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.
|
||||
##
|
||||
## Use automake to process this into a Makefile.in
|
||||
|
||||
AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -DQTDIR=\"@QT_DIR@\" @QT_CXXFLAGS@ -I$(top_srcdir)/lib
|
||||
LIBS = @QT_LIBS@ -L$(top_srcdir)/lib
|
||||
MOC = @QT_MOC@
|
||||
|
||||
# The dependency for qt's Meta Object Compiler (moc)
|
||||
moc_%.cpp: %.h
|
||||
$(MOC) $< -o $@
|
||||
|
||||
bin_PROGRAMS = rdexport
|
||||
|
||||
dist_rdexport_SOURCES = rdexport.cpp rdexport.h
|
||||
|
||||
nodist_rdexport_SOURCES = moc_rdexport.cpp
|
||||
|
||||
rdexport_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
|
||||
|
||||
CLEANFILES = *~\
|
||||
*.idb\
|
||||
*ilk\
|
||||
*.obj\
|
||||
*.pdb\
|
||||
*.qm\
|
||||
moc_*
|
||||
|
||||
MAINTAINERCLEANFILES = *~\
|
||||
Makefile.in\
|
||||
moc_*
|
352
utils/rdexport/rdexport.cpp
Normal file
352
utils/rdexport/rdexport.cpp
Normal file
@ -0,0 +1,352 @@
|
||||
// rdexport.cpp
|
||||
//
|
||||
// A Batch Exporter for Rivendell.
|
||||
//
|
||||
// (C) Copyright 2016 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.
|
||||
//
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qfile.h>
|
||||
|
||||
#include <rd.h>
|
||||
#include <rdaudioconvert.h>
|
||||
#include <rdaudioexport.h>
|
||||
#include <rdaudioinfo.h>
|
||||
#include <rdcart.h>
|
||||
#include <rdcmd_switch.h>
|
||||
#include <rdescape_string.h>
|
||||
#include <rdgroup.h>
|
||||
#include <rddbheartbeat.h>
|
||||
|
||||
#include "rdexport.h"
|
||||
|
||||
MainObject::MainObject(QObject *parent,const char *name)
|
||||
:QObject(parent,name)
|
||||
{
|
||||
export_metadata_pattern="%n_%j";
|
||||
|
||||
//
|
||||
// Read Command Options
|
||||
//
|
||||
RDCmdSwitch *cmd=
|
||||
new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdimport",RDEXPORT_USAGE);
|
||||
if(cmd->keys()<1) {
|
||||
fprintf(stderr,"rdexport: you must specify an output directory\n");
|
||||
exit(256);
|
||||
}
|
||||
for(int i=0;i<(int)cmd->keys()-1;i++) {
|
||||
if(cmd->key(i)=="--carts") {
|
||||
bool ok=false;
|
||||
bool valid=false;
|
||||
QStringList f0=f0.split(":",cmd->value(i));
|
||||
if(f0.size()==2) {
|
||||
int start=f0[0].toUInt(&valid);
|
||||
if(valid&&(start>0)&&(valid<=RD_MAX_CART_NUMBER)) {
|
||||
int end=f0[1].toUInt(&valid);
|
||||
if(valid&&(start>0)&&(valid<=RD_MAX_CART_NUMBER)&&(end>=start)) {
|
||||
export_start_carts.push_back(start);
|
||||
export_end_carts.push_back(end);
|
||||
ok=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!ok) {
|
||||
fprintf(stderr,"rdexport: invalid --carts argument\n");
|
||||
exit(256);
|
||||
}
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--group") {
|
||||
export_groups.push_back(cmd->value(i));
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--metadata-pattern") {
|
||||
export_metadata_pattern=cmd->value(i);
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--verbose") {
|
||||
export_verbose=true;
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(!cmd->processed(i)) {
|
||||
fprintf(stderr,"rdexport: unrecognized option\n");
|
||||
exit(256);
|
||||
}
|
||||
}
|
||||
export_output_to=cmd->key(cmd->keys()-1);
|
||||
|
||||
//
|
||||
// Read Configuration
|
||||
//
|
||||
export_config=new RDConfig();
|
||||
export_config->load();
|
||||
|
||||
//
|
||||
// Open Database
|
||||
//
|
||||
QSqlDatabase *db=QSqlDatabase::addDatabase(export_config->mysqlDriver());
|
||||
if(!db) {
|
||||
fprintf(stderr,"rdexport: unable to initialize connection to database\n");
|
||||
exit(256);
|
||||
}
|
||||
db->setDatabaseName(export_config->mysqlDbname());
|
||||
db->setUserName(export_config->mysqlUsername());
|
||||
db->setPassword(export_config->mysqlPassword());
|
||||
db->setHostName(export_config->mysqlHostname());
|
||||
if(!db->open()) {
|
||||
fprintf(stderr,"rdimport: unable to connect to database\n");
|
||||
db->removeDatabase(export_config->mysqlDbname());
|
||||
exit(256);
|
||||
}
|
||||
new RDDbHeartbeat(export_config->mysqlHeartbeatInterval(),this);
|
||||
|
||||
//
|
||||
// Validate Group List
|
||||
//
|
||||
std::vector<QString> bad_groups;
|
||||
for(unsigned i=0;i<export_groups.size();i++) {
|
||||
RDGroup *grp=new RDGroup(export_groups[i]);
|
||||
if(!grp->exists()) {
|
||||
bad_groups.push_back(export_groups[i]);
|
||||
}
|
||||
delete grp;
|
||||
}
|
||||
if(bad_groups.size()>0) {
|
||||
QString str="no such group(s): ";
|
||||
for(unsigned i=0;i<bad_groups.size();i++) {
|
||||
str+=bad_groups[i]+", ";
|
||||
}
|
||||
str=str.left(str.length()-2);
|
||||
fprintf(stderr,"rdexport: %s\n",(const char *)str);
|
||||
exit(256);
|
||||
}
|
||||
|
||||
//
|
||||
// RIPC Connection
|
||||
//
|
||||
export_ripc=new RDRipc(export_config->stationName());
|
||||
connect(export_ripc,SIGNAL(userChanged()),this,SLOT(userData()));
|
||||
export_ripc->
|
||||
connectHost("localhost",RIPCD_TCP_PORT,export_config->password());
|
||||
|
||||
//
|
||||
// Station Configuration
|
||||
//
|
||||
export_station=new RDStation(export_config->stationName());
|
||||
|
||||
//
|
||||
// User
|
||||
//
|
||||
export_user=NULL;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::userData()
|
||||
{
|
||||
//
|
||||
// Get User Context
|
||||
//
|
||||
disconnect(export_ripc,SIGNAL(userChanged()),this,SLOT(userData()));
|
||||
if(export_user!=NULL) {
|
||||
delete export_user;
|
||||
}
|
||||
export_user=new RDUser(export_ripc->user());
|
||||
|
||||
//
|
||||
// Verify Permissions
|
||||
//
|
||||
if(!export_user->editAudio()) {
|
||||
fprintf(stderr,"rdexport: user \"%s\" has no edit audio permission\n",
|
||||
(const char *)export_user->name());
|
||||
exit(256);
|
||||
}
|
||||
|
||||
//
|
||||
// Process Groups
|
||||
//
|
||||
for(unsigned i=0;i<export_groups.size();i++) {
|
||||
Verbose("Processing group \""+export_groups[i]+"\"...");
|
||||
ExportGroup(export_groups[i]);
|
||||
}
|
||||
|
||||
//
|
||||
// Process Cart Ranges
|
||||
//
|
||||
for(unsigned i=0;i<export_start_carts.size();i++) {
|
||||
for(unsigned j=export_start_carts[i];j<=export_end_carts[i];j++) {
|
||||
ExportCart(j);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Clean Up and Exit
|
||||
//
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::ExportGroup(const QString &groupname)
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
|
||||
sql=QString("select NUMBER from CART where ")+
|
||||
"(GROUP_NAME=\""+RDEscapeString(groupname)+"\")&&"+
|
||||
QString().sprintf("(TYPE=%u) ",RDCart::Audio)+
|
||||
"order by NUMBER";
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
ExportCart(q->value(0).toUInt());
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::ExportCart(unsigned cartnum)
|
||||
{
|
||||
RDCart *cart=new RDCart(cartnum);
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
|
||||
if(cart->exists()&&(cart->type()==RDCart::Audio)) {
|
||||
sql=QString().sprintf("select CUT_NAME from CUTS where CART_NUMBER=%u",
|
||||
cartnum);
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
RDCut *cut=new RDCut(q->value(0).toString());
|
||||
ExportCut(cart,cut);
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
delete cart;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::ExportCut(RDCart *cart,RDCut *cut)
|
||||
{
|
||||
RDAudioExport *conv=new RDAudioExport(export_station,export_config,this);
|
||||
RDAudioExport::ErrorCode export_err;
|
||||
RDAudioConvert::ErrorCode conv_err;
|
||||
RDAudioInfo::ErrorCode info_err;
|
||||
|
||||
//
|
||||
// Get Audio Parameters
|
||||
//
|
||||
RDAudioInfo *info=new RDAudioInfo(export_station,export_config);
|
||||
info->setCartNumber(cart->number());
|
||||
info->setCutNumber(RDCut::cutNumber(cut->cutName()));
|
||||
if((info_err=info->runInfo(export_user->name(),export_user->password()))!=
|
||||
RDAudioInfo::ErrorOk) {
|
||||
fprintf(stderr,"rdexport: error getting cut info [%s]\n",
|
||||
(const char *)RDAudioInfo::errorText(info_err));
|
||||
exit(256);
|
||||
}
|
||||
RDSettings settings;
|
||||
switch(info->format()) {
|
||||
case RDWaveFile::Pcm16:
|
||||
settings.setFormat(RDSettings::Pcm16);
|
||||
break;
|
||||
|
||||
case RDWaveFile::Pcm24:
|
||||
settings.setFormat(RDSettings::Pcm24);
|
||||
break;
|
||||
|
||||
case RDWaveFile::MpegL2:
|
||||
settings.setFormat(RDSettings::MpegL2);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr,"rdexport: unsupported source audio format\n");
|
||||
exit(256);
|
||||
}
|
||||
settings.setChannels(info->channels());
|
||||
settings.setSampleRate(info->sampleRate());
|
||||
settings.setBitRate(info->bitRate());
|
||||
|
||||
Verbose(QString("exporting cart/cut ")+
|
||||
QString().sprintf("%06u/%03d",RDCut::cartNumber(cut->cutName()),
|
||||
RDCut::cutNumber(cut->cutName()))+" ["+cart->title()+"]");
|
||||
conv->setCartNumber(cart->number());
|
||||
conv->setCutNumber(RDCut::cutNumber(cut->cutName()));
|
||||
conv->setDestinationSettings(&settings);
|
||||
conv->setDestinationFile(ResolveOutputName(cart,cut,
|
||||
RDSettings::defaultExtension(export_station->name(),settings.format())));
|
||||
conv->setEnableMetadata(true);
|
||||
|
||||
if((export_err=conv->runExport(export_user->name(),export_user->password(),
|
||||
&conv_err))!=RDAudioExport::ErrorOk) {
|
||||
fprintf(stderr,"rdexport: exporter error [%s]\n",
|
||||
(const char *)RDAudioExport::errorText(export_err,conv_err));
|
||||
exit(256);
|
||||
}
|
||||
|
||||
delete conv;
|
||||
delete info;
|
||||
}
|
||||
|
||||
|
||||
QString MainObject::ResolveOutputName(RDCart *cart,RDCut *cut,
|
||||
const QString &exten)
|
||||
{
|
||||
QString name=export_metadata_pattern;
|
||||
|
||||
name.replace("%a",cart->artist());
|
||||
name.replace("%b",cart->label());
|
||||
name.replace("%c",cart->client());
|
||||
name.replace("%e",cart->agency());
|
||||
name.replace("%g",cart->groupName());
|
||||
name.replace("%h",QString().sprintf("%d",cut->length()));
|
||||
name.replace("%i",cut->description());
|
||||
name.replace("%j",QString().sprintf("%03d",RDCut::cutNumber(cut->cutName())));
|
||||
name.replace("%l",cart->album());
|
||||
name.replace("%m",cart->composer());
|
||||
name.replace("%n",QString().sprintf("%06u",cart->number()));
|
||||
name.replace("%o",cut->outcue());
|
||||
name.replace("%p",cart->publisher());
|
||||
name.replace("%r",cart->conductor());
|
||||
name.replace("%s",cart->songId());
|
||||
name.replace("%t",cart->title());
|
||||
name.replace("%u",cart->userDefined());
|
||||
name.replace("%y",QString().sprintf("%d",cart->year()));
|
||||
|
||||
QString ret=name;
|
||||
int count=1;
|
||||
while(QFile::exists(export_output_to+"/"+ret+"."+exten)) {
|
||||
ret=name+QString().sprintf("[%d]",count++);
|
||||
}
|
||||
|
||||
return export_output_to+"/"+ret+"."+exten;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Verbose(const QString &msg)
|
||||
{
|
||||
if(export_verbose) {
|
||||
fprintf(stderr,"%s\n",(const char *)msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
QApplication a(argc,argv,false);
|
||||
new MainObject(NULL);
|
||||
return a.exec();
|
||||
}
|
66
utils/rdexport/rdexport.h
Normal file
66
utils/rdexport/rdexport.h
Normal file
@ -0,0 +1,66 @@
|
||||
// rdexport.h
|
||||
//
|
||||
// A Batch Exporter for Rivendell.
|
||||
//
|
||||
// (C) Copyright 2016 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 RDEXPORT_H
|
||||
#define RDEXPORT_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <qobject.h>
|
||||
|
||||
#include <rdcart.h>
|
||||
#include <rdconfig.h>
|
||||
#include <rdcut.h>
|
||||
#include <rddb.h>
|
||||
#include <rdripc.h>
|
||||
#include <rdstation.h>
|
||||
#include <rduser.h>
|
||||
|
||||
#define RDEXPORT_USAGE "[options] <output-dir>\n"
|
||||
|
||||
class MainObject : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
MainObject(QObject *parent=0,const char *name=0);
|
||||
|
||||
private slots:
|
||||
void userData();
|
||||
|
||||
private:
|
||||
void ExportGroup(const QString &groupname);
|
||||
void ExportCart(unsigned cartnum);
|
||||
void ExportCut(RDCart *cart,RDCut *cut);
|
||||
QString ResolveOutputName(RDCart *cart,RDCut *cut,const QString &exten);
|
||||
void Verbose(const QString &msg);
|
||||
std::vector<unsigned> export_start_carts;
|
||||
std::vector<unsigned> export_end_carts;
|
||||
std::vector<QString> export_groups;
|
||||
QString export_metadata_pattern;
|
||||
QString export_output_to;
|
||||
RDConfig *export_config;
|
||||
RDRipc *export_ripc;
|
||||
RDStation *export_station;
|
||||
RDUser *export_user;
|
||||
bool export_verbose;
|
||||
};
|
||||
|
||||
|
||||
#endif // RDEXPORT_H
|
@ -106,6 +106,7 @@ void Xport::AudioInfo()
|
||||
printf(" <format>%d</format>\n",format);
|
||||
printf(" <channels>%d</channels>\n",wave->getChannels());
|
||||
printf(" <sampleRate>%d</sampleRate>\n",wave->getSamplesPerSec());
|
||||
printf(" <bitRate>%d</bitRate>\n",wave->getHeadBitRate());
|
||||
printf(" <frames>%u</frames>\n",wave->getSampleLength());
|
||||
printf(" <length>%u</length>\n",wave->getExtTimeLength());
|
||||
printf("</audioInfo>\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user