Added rdmetadata(8) utility for setting cart metadata from the command line.

This commit is contained in:
Patrick Linstruth 2019-05-28 14:20:25 -07:00
parent 20e6b3a72c
commit 48c9388e52
10 changed files with 902 additions and 0 deletions

View File

@ -18696,3 +18696,6 @@
2019-05-24 Fred Gleason <fredg@paravelsystems.com>
* Fixed a regression in rdgpimon(1) that caused GPIO status
to fail to be displayed in the status widgets.
2019-05-28 Patrick Linstruth <patrick@deltecent.com>
* Added rdmetadata(8) utility for setting cart metadata from the
command line.

View File

@ -552,6 +552,7 @@ AC_CONFIG_FILES([rivendell.spec \
utils/rdimport/Makefile \
utils/rdmaint/Makefile \
utils/rdmarkerset/Makefile \
utils/rdmetadata/Makefile \
utils/rdpopup/Makefile \
utils/rdpurgecasts/Makefile \
utils/rdrender/Makefile \

View File

@ -37,6 +37,7 @@ all-local: rdclilogedit.1\
rdexport.1\
rdimport.1\
rdmarkerset.8\
rdmetadata.8\
rdrender.1\
rmlsend.1\
rdservice.8
@ -47,6 +48,7 @@ man_MANS = rdclilogedit.1\
rdexport.1\
rdimport.1\
rdmarkerset.8\
rdmetadata.8\
rdrender.1\
rmlsend.1\
rdservice.8
@ -63,6 +65,8 @@ EXTRA_DIST = rdclilogedit.1\
rdimport.xml\
rdmarkerset.8\
rdmarkerset.xml\
rdmetadata.8\
rdmetadata.xml\
rdrender.1\
rdrender.xml\
rmlsend.1\

View File

@ -0,0 +1,240 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<refentry id="stdin" xmlns="http://docbook.org/ns/docbook" version="5.0">
<!--
Header
-->
<refmeta>
<refentrytitle>rdmetadata</refentrytitle>
<manvolnum>8</manvolnum>
<refmiscinfo class='source'>May 2019</refmiscinfo>
<refmiscinfo class='manual'>Linux Audio Manual</refmiscinfo>
</refmeta>
<refnamediv>
<refname>rdmetadata</refname>
<refpurpose>Tool for altering Rivendell cart metadata</refpurpose>
</refnamediv>
<info>
<author>
<personname>
<firstname>Patrick</firstname>
<surname>Linstruth</surname>
<email>patrick@deltecent.com</email>
</personname>
<contrib>Application Author</contrib>
</author>
</info>
<!--
Body
-->
<refsynopsisdiv id='synopsis'>
<cmdsynopsis>
<command>rdmetadata --cart-number=<replaceable>cart</replaceable></command>
<arg choice='opt'><replaceable>OPTIONS</replaceable></arg>
<sbr/>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1 id='description'><title>Description</title>
<para>
<command>rdmetadata</command><manvolnum>8</manvolnum> is a command-line
tool for setting or altering cart metadata in the Rivendell Radio
Automation System.
</para>
</refsect1>
<refsect1 id='options'><title>Options</title>
<variablelist remap='TP'>
<varlistentry>
<term>
<option>--agency=</option><replaceable>agency</replaceable>
</term>
<listitem>
<para>
Set <replaceable>cart</replaceable> agency metadata
to <replaceable>agency</replaceable>.
Default action is to leave the agency unaltered.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--album=</option><replaceable>album</replaceable>
</term>
<listitem>
<para>
Set <replaceable>cart</replaceable> album metadata
to <replaceable>album</replaceable>.
Default action is to leave the album unaltered.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--artist=</option><replaceable>artist</replaceable>
</term>
<listitem>
<para>
Set <replaceable>cart</replaceable> artist metadata
to <replaceable>artist</replaceable>.
Default action is to leave the artist unaltered.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--bpm=</option><replaceable>bpm</replaceable>
</term>
<listitem>
<para>
Set <replaceable>cart</replaceable> BPM metadata
to <replaceable>bpm</replaceable>.
Default action is to leave the BPM unaltered.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--composer=</option><replaceable>composer</replaceable>
</term>
<listitem>
<para>
Set <replaceable>cart</replaceable> composer metadata
to <replaceable>composer</replaceable>.
Default action is to leave the composer unaltered.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--conductor=</option><replaceable>conductor</replaceable>
</term>
<listitem>
<para>
Set <replaceable>cart</replaceable> conductor metadata
to <replaceable>conductor</replaceable>.
Default action is to leave the conductor unaltered.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--label=</option><replaceable>label</replaceable>
</term>
<listitem>
<para>
Set <replaceable>cart</replaceable> label metadata
to <replaceable>label</replaceable>.
Default action is to leave the label unaltered.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--publisher=</option><replaceable>publisher</replaceable>
</term>
<listitem>
<para>
Set <replaceable>cart</replaceable> publisher metadata
to <replaceable>publisher</replaceable>.
Default action is to leave the publisher unaltered.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--songid=</option><replaceable>songid</replaceable>
</term>
<listitem>
<para>
Set <replaceable>cart</replaceable> song ID metadata
to <replaceable>songid</replaceable>.
Default action is to leave the song ID unaltered.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--title=</option><replaceable>title</replaceable>
</term>
<listitem>
<para>
Set <replaceable>cart</replaceable> title metadata
to <replaceable>title</replaceable>.
Default action is to leave the title unaltered.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--year=</option><replaceable>year</replaceable>
</term>
<listitem>
<para>
Set <replaceable>cart</replaceable> year metadata
to <replaceable>year</replaceable>.
Default action is to leave the year unaltered.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--add-schedcode=</option><replaceable>schedcode</replaceable>
</term>
<listitem>
<para>
Add scheduler code <replaceable>schedcode</replaceable> to
<replaceable>cart</replaceable>.
Default action is to leave the scheduler codes unaltered.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--rem-schedcode=</option><replaceable>schedcode</replaceable>
</term>
<listitem>
<para>
Remove scheduler code <replaceable>schedcode</replaceable> from
<replaceable>cart</replaceable>.
Default action is to leave the scheduler codes unaltered.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--verbose</option>
</term>
<listitem>
<para>
Print messages to STDOUT describing progress.
</para>
</listitem>
</varlistentry>
</variablelist>
<refsect1 id='see_also'><title>See Also</title>
<para>
<citerefentry>
<refentrytitle>rdlibrary</refentrytitle><manvolnum>1</manvolnum>
</citerefentry>
</para>
</refsect1>
</refsect1>
</refentry>

View File

@ -258,6 +258,7 @@ rm -rf $RPM_BUILD_ROOT
@LOCAL_PREFIX@/bin/rdimport
@LOCAL_PREFIX@/bin/rdpurgecasts
@LOCAL_PREFIX@/bin/rdmaint
@LOCAL_PREFIX@/bin/rdmetadata
@LOCAL_PREFIX@/bin/rdcollect
@LOCAL_PREFIX@/bin/rdconvert
@LOCAL_PREFIX@/bin/rdcheckcuts
@ -387,6 +388,7 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/rmlsend.1.gz
%{_mandir}/man8/rddbmgr.8.gz
%{_mandir}/man8/rdmarkerset.8.gz
%{_mandir}/man8/rdmetadata.8.gz
%{_mandir}/man8/rdservice.8.gz
@DOC_PATH@/*
@LOCAL_PREFIX@/@RD_LIB_PATH@/librd-@VERSION@.so
@ -403,6 +405,7 @@ rm -rf $RPM_BUILD_ROOT
@LOCAL_PREFIX@/sbin/rdpadengined
@LOCAL_PREFIX@/sbin/sas_shim
@LOCAL_PREFIX@/sbin/rdmarkerset
@LOCAL_PREFIX@/sbin/rdmetadata
@LOCAL_PREFIX@/sbin/rdcleandirs
@LOCAL_PREFIX@/sbin/rddbmgr
@HPI_FILE1@

View File

@ -40,6 +40,7 @@ SUBDIRS = $(ALSACONFIG_RD_OPT)\
rdimport\
rdmaint\
rdmarkerset\
rdmetadata\
rdpopup\
rdpurgecasts\
rdrender\

View File

@ -0,0 +1,48 @@
## Makefile.am
##
## (C) Copyright 2002-2014,2016-2018 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)\" -I$(top_srcdir)/lib @QT4_CFLAGS@ -DQT3_SUPPORT -I/usr/include/Qt3Support
LIBS = -L$(top_srcdir)/lib
MOC = @QT_MOC@
# The dependency for qt's Meta Object Compiler (moc)
moc_%.cpp: %.h
$(MOC) $< -o $@
sbin_PROGRAMS = rdmetadata
dist_rdmetadata_SOURCES = rdmetadata.cpp rdmetadata.h
nodist_rdmetadata_SOURCES = moc_rdmetadata.cpp
rdmetadata_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ -lQt3Support
EXTRA_DIST =
CLEANFILES = *~\
*.idb\
*ilk\
*.obj\
*.pdb\
*.qm\
moc_*
MAINTAINERCLEANFILES = *~\
Makefile.in\
moc_*

228
utils/rdmetadata/rdmetadata Executable file
View File

@ -0,0 +1,228 @@
#! /bin/sh
# rdmetadata - temporary wrapper script for .libs/rdmetadata
# Generated by libtool (GNU libtool) 2.4.2
#
# The rdmetadata program cannot be directly executed until all the libtool
# libraries that it depends on are installed.
#
# This wrapper script should never be moved out of the build directory.
# If it is, it will not operate correctly.
# Sed substitution that helps us do robust quoting. It backslashifies
# metacharacters that are still active within double-quoted strings.
sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
fi
BIN_SH=xpg4; export BIN_SH # for Tru64
DUALCASE=1; export DUALCASE # for MKS sh
# The HP-UX ksh and POSIX shell print the target directory to stdout
# if CDPATH is set.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
relink_command="(cd /home/patrick/rivendell/utils/rdmetadata; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/patrick/.local/bin:/home/patrick/bin; export PATH; g++ -g -O2 -o \$progdir/\$file rdmetadata.o moc_rdmetadata.o -lm -lpthread /home/patrick/rivendell/lib/.libs/librd.so -lcurl -lid3 -ltag -lFLAC -lFLAC++ -lsndfile -lsamplerate -lcdda_interface -lcdda_paranoia -lcrypt -ldl -lpam -lSoundTouch -lcrypto -lvorbisfile -lvorbisenc -lQtXml -lQtGui -lQtNetwork -lQtSql -lQtCore -lQt3Support -L../../lib -Wl,-rpath -Wl,/home/patrick/rivendell/lib/.libs)"
# This environment variable determines our operation mode.
if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
# install mode needs the following variables:
generated_by_libtool_version='2.4.2'
notinst_deplibs=' /home/patrick/rivendell/lib/librd.la'
else
# When we are sourced in execute mode, $file and $ECHO are already set.
if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
file="$0"
# A function that is used when there is no print builtin or printf.
func_fallback_echo ()
{
eval 'cat <<_LTECHO_EOF
$1
_LTECHO_EOF'
}
ECHO="printf %s\\n"
fi
# Very basic option parsing. These options are (a) specific to
# the libtool wrapper, (b) are identical between the wrapper
# /script/ and the wrapper /executable/ which is used only on
# windows platforms, and (c) all begin with the string --lt-
# (application programs are unlikely to have options which match
# this pattern).
#
# There are only two supported options: --lt-debug and
# --lt-dump-script. There is, deliberately, no --lt-help.
#
# The first argument to this parsing function should be the
# script's ../../libtool value, followed by no.
lt_option_debug=
func_parse_lt_options ()
{
lt_script_arg0=$0
shift
for lt_opt
do
case "$lt_opt" in
--lt-debug) lt_option_debug=1 ;;
--lt-dump-script)
lt_dump_D=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 's%/[^/]*$%%'`
test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=.
lt_dump_F=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 's%^.*/%%'`
cat "$lt_dump_D/$lt_dump_F"
exit 0
;;
--lt-*)
$ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2
exit 1
;;
esac
done
# Print the debug banner immediately:
if test -n "$lt_option_debug"; then
echo "rdmetadata:rdmetadata:${LINENO}: libtool wrapper (GNU libtool) 2.4.2" 1>&2
fi
}
# Used when --lt-debug. Prints its arguments to stdout
# (redirection is the responsibility of the caller)
func_lt_dump_args ()
{
lt_dump_args_N=1;
for lt_arg
do
$ECHO "rdmetadata:rdmetadata:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg"
lt_dump_args_N=`expr $lt_dump_args_N + 1`
done
}
# Core function for launching the target application
func_exec_program_core ()
{
if test -n "$lt_option_debug"; then
$ECHO "rdmetadata:rdmetadata:${LINENO}: newargv[0]: $progdir/$program" 1>&2
func_lt_dump_args ${1+"$@"} 1>&2
fi
exec "$progdir/$program" ${1+"$@"}
$ECHO "$0: cannot exec $program $*" 1>&2
exit 1
}
# A function to encapsulate launching the target application
# Strips options in the --lt-* namespace from $@ and
# launches target application with the remaining arguments.
func_exec_program ()
{
case " $* " in
*\ --lt-*)
for lt_wr_arg
do
case $lt_wr_arg in
--lt-*) ;;
*) set x "$@" "$lt_wr_arg"; shift;;
esac
shift
done ;;
esac
func_exec_program_core ${1+"$@"}
}
# Parse options
func_parse_lt_options "$0" ${1+"$@"}
# Find the directory that this script lives in.
thisdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'`
test "x$thisdir" = "x$file" && thisdir=.
# Follow symbolic links until we get to the real thisdir.
file=`ls -ld "$file" | /usr/bin/sed -n 's/.*-> //p'`
while test -n "$file"; do
destdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'`
# If there was a directory component, then change thisdir.
if test "x$destdir" != "x$file"; then
case "$destdir" in
[\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
*) thisdir="$thisdir/$destdir" ;;
esac
fi
file=`$ECHO "$file" | /usr/bin/sed 's%^.*/%%'`
file=`ls -ld "$thisdir/$file" | /usr/bin/sed -n 's/.*-> //p'`
done
# Usually 'no', except on cygwin/mingw when embedded into
# the cwrapper.
WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
# special case for '.'
if test "$thisdir" = "."; then
thisdir=`pwd`
fi
# remove .libs from thisdir
case "$thisdir" in
*[\\/].libs ) thisdir=`$ECHO "$thisdir" | /usr/bin/sed 's%[\\/][^\\/]*$%%'` ;;
.libs ) thisdir=. ;;
esac
fi
# Try to get the absolute directory name.
absdir=`cd "$thisdir" && pwd`
test -n "$absdir" && thisdir="$absdir"
program=lt-'rdmetadata'
progdir="$thisdir/.libs"
if test ! -f "$progdir/$program" ||
{ file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /usr/bin/sed 1q`; \
test "X$file" != "X$progdir/$program"; }; then
file="$$-$program"
if test ! -d "$progdir"; then
mkdir "$progdir"
else
rm -f "$progdir/$file"
fi
# relink executable if necessary
if test -n "$relink_command"; then
if relink_command_output=`eval $relink_command 2>&1`; then :
else
printf %s\n "$relink_command_output" >&2
rm -f "$progdir/$file"
exit 1
fi
fi
mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null ||
{ rm -f "$progdir/$program";
mv -f "$progdir/$file" "$progdir/$program"; }
rm -f "$progdir/$file"
fi
if test -f "$progdir/$program"; then
if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
# Run the actual program with our arguments.
func_exec_program ${1+"$@"}
fi
else
# The program doesn't exist.
$ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2
$ECHO "This script is just a wrapper for $program." 1>&2
$ECHO "See the libtool documentation for more information." 1>&2
exit 1
fi
fi

View File

@ -0,0 +1,294 @@
// rdmetadata.cpp
//
// Command-line tool for setting Rivendell Cart Metadata
//
// Patrick Linstruth <patrick@deltecent.com>
// (C) Copyright 2019 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 <limits.h>
#include <glob.h>
#include <signal.h>
#include <math.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <QApplication>
#include <QDir>
#include <QFileInfo>
#include <QSqlQuery>
#include "rd.h"
#include "rdapplication.h"
#include "rdcart.h"
#include "rdschedcode.h"
#include "rdnotification.h"
#include "rdmetadata.h"
MainObject::MainObject(QObject *parent)
:QObject(parent)
{
QString err_msg;
verbose=false;
cartnum=0;
year=0;
//
// Check for root permission
//
if(geteuid()!=0) {
fprintf(stderr,"rdmetadata: must be user \"root\"\n");
exit(256);
}
//
// Open the Database
//
rda=new RDApplication("rdmetadata","rdmetadata",RDMETADATA_USAGE,this);
if(!rda->open(&err_msg)) {
fprintf(stderr,"rdmetadata: %s\n",(const char *)err_msg);
exit(1);
}
//
// Read Command Options
//
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
if(rda->cmdSwitch()->key(i)=="--cart-number") {
cartnum=rda->cmdSwitch()->value(i).toUInt();
cartstring=QString().sprintf("%06u",cartnum);
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--artist") {
artist=rda->cmdSwitch()->value(i);
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--title") {
title=rda->cmdSwitch()->value(i);
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--album") {
album=rda->cmdSwitch()->value(i);
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--year") {
year=rda->cmdSwitch()->value(i).toInt();
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--conductor") {
conductor=rda->cmdSwitch()->value(i);
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--label") {
label=rda->cmdSwitch()->value(i);
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--agency") {
agency=rda->cmdSwitch()->value(i);
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--publisher") {
publisher=rda->cmdSwitch()->value(i);
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--composer") {
composer=rda->cmdSwitch()->value(i);
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--songid") {
songid=rda->cmdSwitch()->value(i);
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--bpm") {
bpm=rda->cmdSwitch()->value(i).toInt();
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--add-schedcode") {
add_schedcode=rda->cmdSwitch()->value(i);
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--rem-schedcode") {
rem_schedcode=rda->cmdSwitch()->value(i);
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--verbose") {
verbose=true;
rda->cmdSwitch()->setProcessed(i,true);
}
if(!rda->cmdSwitch()->processed(i)) {
fprintf(stderr,"rdmetadata: unknown command option \"%s\"\n",
(const char *)rda->cmdSwitch()->key(i));
exit(2);
}
}
//
// Sanity Checks
//
if(!cartnum) {
fprintf(stderr,"rdmetadata: --cart-number must be specified\n");
exit(256);
}
if(!add_schedcode.isEmpty()) {
RDSchedCode *sched=new RDSchedCode(add_schedcode);
if (!sched->exists()) {
fprintf(stderr,"rdmetadata: scheduler code '%s' does not exist\n",
qPrintable(sched->code()));
exit(256);
}
else {
// Get proper case
add_schedcode=sched->code();
}
delete sched;
}
if(!rem_schedcode.isEmpty()) {
RDSchedCode *sched=new RDSchedCode(rem_schedcode);
if (!sched->exists()) {
fprintf(stderr,"rdmetadata: scheduler code '%s' does not exist\n",
qPrintable(sched->code()));
exit(256);
}
else {
// Get proper case
rem_schedcode=sched->code();
}
delete sched;
}
//
// RIPCD Connection
//
connect(rda,SIGNAL(userChanged()),this,SLOT(userChangedData()));
rda->ripc()->connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
}
void MainObject::userChangedData()
{
updateMetadata();
exit(0);
}
void MainObject::updateMetadata()
{
RDCart *cart;
QStringList schedcodes;
cart=new RDCart(cartnum);
if(!cart->exists()) {
fprintf(stderr,"rdmetadata: cart %06u does not exist.\n",cartnum);
exit(1);
}
schedcodes=cart->schedCodesList();
if(!artist.isNull()) {
cart->setArtist(artist);
Print(QString("rdmetadata: Set cart %1 artist to '%2'").arg(cartstring).arg(artist));
}
if(!title.isNull()) {
cart->setTitle(title);
Print(QString("rdmetadata: Set cart %1 title to '%2'").arg(cartstring).arg(title));
}
if(!album.isNull()) {
cart->setAlbum(album);
Print(QString("rdmetadata: Set cart %1 album to '%2'").arg(cartstring).arg(album));
}
if(year) {
cart->setYear(year);
Print(QString("rdmetadata: Set cart %1 year to '%2'").arg(cartstring).arg(year));
}
if(!conductor.isNull()) {
cart->setConductor(conductor);
Print(QString("rdmetadata: Set cart %1 conductor to '%2'").arg(cartstring).arg(conductor));
}
if(!label.isNull()) {
cart->setLabel(label);
Print(QString("rdmetadata: Set cart %1 label to '%2'").arg(cartstring).arg(label));
}
if(!agency.isNull()) {
cart->setAgency(agency);
Print(QString("rdmetadata: Set cart %1 agency to '%2'").arg(cartstring).arg(agency));
}
if(!publisher.isNull()) {
cart->setPublisher(publisher);
Print(QString("rdmetadata: Set cart %1 publisher to '%2'").arg(cartstring).arg(publisher));
}
if(!composer.isNull()) {
cart->setComposer(composer);
Print(QString("rdmetadata: Set cart %1 composer to '%2'").arg(cartstring).arg(composer));
}
if(!songid.isNull()) {
cart->setSongId(songid);
Print(QString("rdmetadata: Set cart %1 songid to '%2'").arg(cartstring).arg(songid));
}
if(bpm) {
cart->setBeatsPerMinute(bpm);
Print(QString("rdmetadata: Set cart %1 bpm to '%2'").arg(cartstring).arg(bpm));
}
if(!add_schedcode.isEmpty()&&!schedcodes.contains(add_schedcode)) {
cart->addSchedCode(add_schedcode);
Print(QString("rdmetadata: Added scheduler code '%1' to cart %2").arg(add_schedcode).arg(cartstring));
}
if(!rem_schedcode.isEmpty()&&schedcodes.contains(rem_schedcode)) {
cart->removeSchedCode(rem_schedcode);
Print(QString("rdmetadata: Removed scheduler code '%1' from cart %2").arg(rem_schedcode).arg(cartstring));
}
delete cart;
RDNotification *notify=new RDNotification(
RDNotification::CartType,RDNotification::ModifyAction,QVariant(cartnum));
rda->ripc()->sendNotification(*notify);
delete notify;
}
void MainObject::Print(const QString &msg)
{
if(verbose) {
printf("%s\n",(const char *)msg);
}
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv,false);
new MainObject();
return a.exec();
}

View File

@ -0,0 +1,80 @@
// rdmarkerset.h
//
// Command-line tool for setting Rivendell Cart Metadata
//
// Patrick Linstruth <patrick@deltecent.com>
// (C) Copyright 2019 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 RDMETADATA_H
#define RDMETADATA_H
#include <stdlib.h>
#include <vector>
#include <QObject>
#define RDMETADATA_USAGE "--cart-number=<cart number> [options]\n\nThe following options are recognized:\n\n\
--agency=<agency>\n\
--album=<album>\n\
--artist=<artist>\n\
--bpm=<bpm>\n\
--composer=<composer>\n\
--conductor=<conductor>\n\
--label=<label>\n\
--publisher=<publisher>\n\
--songid=<songid>\n\
--title=<title>\n\
--year=<year>\n\
--add_schedcode=<schedcode>\n\
--rem-schedcode=<schedcode>\n\
--verbose\n\
\n"
class MainObject : public QObject
{
Q_OBJECT;
public:
MainObject(QObject *parent=0);
private slots:
void userChangedData();
private:
void updateMetadata();
void Print(const QString &msg);
bool verbose;
unsigned cartnum;
QString cartstring;
QString artist;
QString title;
QString album;
int year;
QString conductor;
QString label;
QString agency;
QString publisher;
QString composer;
QString songid;
int bpm;
QString add_schedcode;
QString rem_schedcode;
};
#endif // RDMETADATA_H