From 48c9388e52def10c82991ab8f4946e58c421875a Mon Sep 17 00:00:00 2001 From: Patrick Linstruth Date: Tue, 28 May 2019 14:20:25 -0700 Subject: [PATCH] Added rdmetadata(8) utility for setting cart metadata from the command line. --- ChangeLog | 3 + configure.ac | 1 + docs/manpages/Makefile.am | 4 + docs/manpages/rdmetadata.xml | 240 ++++++++++++++++++++++++++ rivendell.spec.in | 3 + utils/Makefile.am | 1 + utils/rdmetadata/Makefile.am | 48 ++++++ utils/rdmetadata/rdmetadata | 228 +++++++++++++++++++++++++ utils/rdmetadata/rdmetadata.cpp | 294 ++++++++++++++++++++++++++++++++ utils/rdmetadata/rdmetadata.h | 80 +++++++++ 10 files changed, 902 insertions(+) create mode 100644 docs/manpages/rdmetadata.xml create mode 100644 utils/rdmetadata/Makefile.am create mode 100755 utils/rdmetadata/rdmetadata create mode 100644 utils/rdmetadata/rdmetadata.cpp create mode 100644 utils/rdmetadata/rdmetadata.h diff --git a/ChangeLog b/ChangeLog index 2e5566e0..284cef77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18696,3 +18696,6 @@ 2019-05-24 Fred Gleason * Fixed a regression in rdgpimon(1) that caused GPIO status to fail to be displayed in the status widgets. +2019-05-28 Patrick Linstruth + * Added rdmetadata(8) utility for setting cart metadata from the + command line. diff --git a/configure.ac b/configure.ac index c0a07337..30135985 100644 --- a/configure.ac +++ b/configure.ac @@ -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 \ diff --git a/docs/manpages/Makefile.am b/docs/manpages/Makefile.am index b2246cb8..9169abd7 100644 --- a/docs/manpages/Makefile.am +++ b/docs/manpages/Makefile.am @@ -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\ diff --git a/docs/manpages/rdmetadata.xml b/docs/manpages/rdmetadata.xml new file mode 100644 index 00000000..66ba6791 --- /dev/null +++ b/docs/manpages/rdmetadata.xml @@ -0,0 +1,240 @@ + + + + + rdmetadata + 8 + May 2019 + Linux Audio Manual + + + rdmetadata + Tool for altering Rivendell cart metadata + + + + + Patrick + Linstruth + patrick@deltecent.com + + Application Author + + + + + + + rdmetadata --cart-number=cart + OPTIONS + + + + + Description + + rdmetadata8 is a command-line + tool for setting or altering cart metadata in the Rivendell Radio + Automation System. + + + + Options + + + + agency + + + + Set cart agency metadata + to agency. + Default action is to leave the agency unaltered. + + + + + + + album + + + + Set cart album metadata + to album. + Default action is to leave the album unaltered. + + + + + + + artist + + + + Set cart artist metadata + to artist. + Default action is to leave the artist unaltered. + + + + + + + bpm + + + + Set cart BPM metadata + to bpm. + Default action is to leave the BPM unaltered. + + + + + + + composer + + + + Set cart composer metadata + to composer. + Default action is to leave the composer unaltered. + + + + + + + conductor + + + + Set cart conductor metadata + to conductor. + Default action is to leave the conductor unaltered. + + + + + + + label + + + + Set cart label metadata + to label. + Default action is to leave the label unaltered. + + + + + + + publisher + + + + Set cart publisher metadata + to publisher. + Default action is to leave the publisher unaltered. + + + + + + + songid + + + + Set cart song ID metadata + to songid. + Default action is to leave the song ID unaltered. + + + + + + + title + + + + Set cart title metadata + to title. + Default action is to leave the title unaltered. + + + + + + + year + + + + Set cart year metadata + to year. + Default action is to leave the year unaltered. + + + + + + + schedcode + + + + Add scheduler code schedcode to + cart. + Default action is to leave the scheduler codes unaltered. + + + + + + + schedcode + + + + Remove scheduler code schedcode from + cart. + Default action is to leave the scheduler codes unaltered. + + + + + + + + + + + Print messages to STDOUT describing progress. + + + + + + + See Also + + + rdlibrary1 + + + + + + + diff --git a/rivendell.spec.in b/rivendell.spec.in index a2d5c597..82862fcb 100644 --- a/rivendell.spec.in +++ b/rivendell.spec.in @@ -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@ diff --git a/utils/Makefile.am b/utils/Makefile.am index dd6dbc15..e6cb45fd 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -40,6 +40,7 @@ SUBDIRS = $(ALSACONFIG_RD_OPT)\ rdimport\ rdmaint\ rdmarkerset\ + rdmetadata\ rdpopup\ rdpurgecasts\ rdrender\ diff --git a/utils/rdmetadata/Makefile.am b/utils/rdmetadata/Makefile.am new file mode 100644 index 00000000..b43fbb3c --- /dev/null +++ b/utils/rdmetadata/Makefile.am @@ -0,0 +1,48 @@ +## Makefile.am +## +## (C) Copyright 2002-2014,2016-2018 Fred Gleason +## +## 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_* diff --git a/utils/rdmetadata/rdmetadata b/utils/rdmetadata/rdmetadata new file mode 100755 index 00000000..0569add9 --- /dev/null +++ b/utils/rdmetadata/rdmetadata @@ -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 diff --git a/utils/rdmetadata/rdmetadata.cpp b/utils/rdmetadata/rdmetadata.cpp new file mode 100644 index 00000000..01da0f81 --- /dev/null +++ b/utils/rdmetadata/rdmetadata.cpp @@ -0,0 +1,294 @@ +// rdmetadata.cpp +// +// Command-line tool for setting Rivendell Cart Metadata +// +// Patrick Linstruth +// (C) Copyright 2019 Fred Gleason +// +// 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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#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;icmdSwitch()->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(); +} diff --git a/utils/rdmetadata/rdmetadata.h b/utils/rdmetadata/rdmetadata.h new file mode 100644 index 00000000..f5c144cc --- /dev/null +++ b/utils/rdmetadata/rdmetadata.h @@ -0,0 +1,80 @@ +// rdmarkerset.h +// +// Command-line tool for setting Rivendell Cart Metadata +// +// Patrick Linstruth +// (C) Copyright 2019 Fred Gleason +// +// 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 + +#include + +#include + +#define RDMETADATA_USAGE "--cart-number= [options]\n\nThe following options are recognized:\n\n\ + --agency=\n\ + --album=\n\ + --artist=\n\ + --bpm=\n\ + --composer=\n\ + --conductor=\n\ + --label=