2020-10-31 Fred Gleason <fredg@paravelsystems.com>

* Added an '--output-pattern' switch to rdimport(1).

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2020-10-31 12:18:02 -04:00
parent 0904c2cbe3
commit b7702a9c79
14 changed files with 160 additions and 21 deletions

View File

@ -20518,3 +20518,5 @@
* Fixed a regression in 'RDFormPost' that broke file control
processing.
* Added a 'put' section to the WebGet interface.
2020-10-31 Fred Gleason <fredg@paravelsystems.com>
* Added an '--output-pattern' switch to rdimport(1).

View File

@ -370,7 +370,9 @@ class Update(object):
#
# MAINTAINER'S NOTE: These mappings must be kept in sync with
# those of the 'RDLogLine::resolveWildcards()'
# method in 'lib/rdlog_line.cpp'.
# method in 'lib/rdlog_line.cpp' as well as
# the 'RunPattern()' and 'VerifyPattern()' methods
# in 'utils/rdimport/rdimport.cpp'.
#
string=self.__replaceWildcardPair('a','artist',string,esc)
string=self.__replaceWildcardPair('b','label',string,esc)

View File

@ -6,7 +6,7 @@
<refmeta>
<refentrytitle>rdimport</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class='source'>February 2020</refmiscinfo>
<refmiscinfo class='source'>October 2020</refmiscinfo>
<refmiscinfo class='manual'>Linux Audio Manual</refmiscinfo>
</refmeta>
<refnamediv>
@ -502,6 +502,25 @@
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--output-pattern=</option><replaceable>pattern</replaceable>
</term>
<listitem>
<para>
Specify a <replaceable>pattern</replaceable> string
(which may include metadata wildcards), which will cause
<command>rdimport</command><manvolnum>1</manvolnum> to print
this string to standard output once for each file successfully
imported, with the wildcards appropriately resolved.
</para>
<para>
See the <option>--metadata-pattern</option> section (above) for
the list of supported wildcards.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--segue-length=</option><replaceable>length</replaceable>

View File

@ -845,6 +845,10 @@
<source>new profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -841,6 +841,10 @@
<source>new profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -841,6 +841,10 @@
<source>new profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -811,6 +811,10 @@
<source>new profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -841,6 +841,10 @@
<source>new profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -841,6 +841,10 @@
<source>new profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -841,6 +841,10 @@
<source>new profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -38,16 +38,28 @@ RDLogLine::RDLogLine()
}
RDLogLine::RDLogLine(unsigned cartnum)
RDLogLine::RDLogLine(unsigned cartnum,int cutnum)
{
QString sql;
RDSqlQuery *q;
clear();
log_cart_number=cartnum;
sql=QString().sprintf("select GROUP_NAME,TITLE,ARTIST,ALBUM,YEAR,LABEL,\
CLIENT,AGENCY,COMPOSER,PUBLISHER,USER_DEFINED,NOTES \
from CART where NUMBER=%u",log_cart_number);
sql=QString("select ")+
"GROUP_NAME,"+ // 00
"TITLE,"+ // 01
"ARTIST,"+ // 02
"ALBUM,"+ // 03
"YEAR,"+ // 04
"LABEL," // 05
"CLIENT,"+ // 06
"AGENCY,"+ // 07
"COMPOSER,"+ // 08
"PUBLISHER,"+ // 09
"USER_DEFINED,"+ // 10
"NOTES "+ // 11
"from CART where "+
QString().sprintf("NUMBER=%u",log_cart_number);
q=new RDSqlQuery(sql);
if(q->first()) {
log_group_name=q->value(0).toString();
@ -64,6 +76,33 @@ RDLogLine::RDLogLine(unsigned cartnum)
log_cart_notes=q->value(11).toString();
}
delete q;
if(cutnum>0) {
log_cut_number=cutnum;
sql=QString("select ")+
"DESCRIPTION,"+ // 00
"START_DATETIME,"+ // 01
"END_DATETIME,"+ // 02
"OUTCUE,"+ // 03
"ISCI,"+ // 04
"ISRC,"+ // 05
"RECORDING_MBID,"+ // 06
"RELEASE_MBID "+ // 07
"from CUTS where "+
"CUT_NAME=\""+RDEscapeString(RDCut::cutName(cartnum,cutnum))+"\"";
q=new RDSqlQuery(sql);
if(q->first()) {
log_description=q->value(0).toString();
log_start_datetime=q->value(1).toDateTime();
log_end_datetime=q->value(2).toDateTime();
log_outcue=q->value(3).toString();
log_isci=q->value(4).toString();
log_isrc=q->value(5).toString();
log_recording_mbid=q->value(6).toString();
log_release_mbid=q->value(7).toString();
}
delete q;
}
}
@ -1710,8 +1749,30 @@ QString RDLogLine::resolveWildcards(QString pattern,int log_id)
{
// MAINTAINERS'S NOTE: These mappings must be kept in sync with those
// of the 'resolvePadFields()' method in
// 'apis/PyPAD/api/PyPAD.py'!
// 'apis/PyPAD/api/PyPAD.py', as well as the
// 'RunPattern()' and 'VerifyPattern()' methods
// in 'utils/rdimport/rdimport.cpp'.
//
// Generate Start/End Datetime Strings
//
QString start_date=QObject::tr("[none]");
QString end_date=QObject::tr("[none]");
QString start_time=QObject::tr("[none]");
QString end_time=QObject::tr("[none]");
if(startDatetime().isValid()) {
start_date=startDatetime().toString("yyyy-MM-dd");
start_time=startDatetime().toString("hh:mm:ss");
}
if(endDatetime().isValid()) {
end_date=endDatetime().toString("yyyy-MM-dd");
end_time=endDatetime().toString("hh:mm:ss");
}
//
// Resolve Wildcards
//
pattern.replace("%a",artist());
pattern.replace("%b",label());
pattern.replace("%c",client());
@ -1722,13 +1783,15 @@ QString RDLogLine::resolveWildcards(QString pattern,int log_id)
pattern.replace("%h",QString().sprintf("%d",effectiveLength()));
pattern.replace("%i",description());
pattern.replace("%j",QString().sprintf("%03d",cutNumber()));
// %k rdimport(1) parameter
pattern.replace("%k",start_time);
pattern.replace("%K",end_time);
pattern.replace("%l",album());
pattern.replace("%m",composer());
pattern.replace("%n",QString().sprintf("%06u",cartNumber()));
pattern.replace("%o",outcue());
pattern.replace("%p",publisher());
// %q rdimport(1) parameter
pattern.replace("%q",start_date);
pattern.replace("%Q",end_date);
pattern.replace("%r",conductor());
pattern.replace("%s",songId());
pattern.replace("%t",title());

View File

@ -48,7 +48,7 @@ class RDLogLine
CartSlot=5};
enum PointerSource {CartPointer=0,LogPointer=1,AutoPointer=2};
RDLogLine();
RDLogLine(unsigned cartnum);
RDLogLine(unsigned cartnum,int cutnum=0);
void clear();
void clearExternalData();
void clearTrackData(RDLogLine::TransEdge edge);

View File

@ -302,7 +302,15 @@ MainObject::MainObject(QObject *parent)
if(rda->cmdSwitch()->key(i)=="--metadata-pattern") {
import_metadata_pattern=rda->cmdSwitch()->value(i);
if(!VerifyPattern(import_metadata_pattern)) {
Log(LOG_ERR,QString("rdimport: invalid metadata pattern\n"));
Log(LOG_ERR,QString("rdimport: invalid --metadata-pattern\n"));
exit(2);
}
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--output-pattern") {
import_output_pattern=rda->cmdSwitch()->value(i);
if(!VerifyPattern(import_output_pattern)) {
Log(LOG_ERR,QString("rdimport: invalid --output-pattern\n"));
exit(2);
}
rda->cmdSwitch()->setProcessed(i,true);
@ -453,16 +461,6 @@ MainObject::MainObject(QObject *parent)
Log(LOG_ERR,QString().sprintf("rdimport: --metadata-pattern and --xml are mutually exclusive\n"));
exit(255);
}
/*
if((!import_log_directory.isEmpty())&&import_log_filename.isEmpty()) {
Log(LOG_ERR,QString().sprintf("rdimport: --log-directory requires --log-filename\n"));
exit(255);
}
if((!import_log_filename.isEmpty())&&import_log_directory.isEmpty()) {
Log(LOG_ERR,QString().sprintf("rdimport: --log-filename requires --log-directory\n"));
exit(255);
}
*/
if((!import_log_filename.isEmpty())&&import_log_syslog) {
Log(LOG_ERR,QString().sprintf("rdimport: --log-filename and --log-syslog are mutually exclusive\n"));
exit(255);
@ -678,6 +676,10 @@ MainObject::MainObject(QObject *parent)
Log(LOG_INFO,QString().sprintf(" Using metadata pattern: %s\n",
(const char *)import_metadata_pattern));
}
if(!import_output_pattern.isEmpty()) {
Log(LOG_INFO,QString().sprintf(" Using output pattern: %s\n",
(const char *)import_output_pattern));
}
Log(LOG_INFO,QString().sprintf(" Start Date Offset = %d days\n",import_startdate_offset));
Log(LOG_INFO,QString().sprintf(" End Date Offset = %d days\n",import_enddate_offset));
if((!import_dayparts[0].isNull())||(!import_dayparts[1].isNull())) {
@ -1333,6 +1335,14 @@ MainObject::Result MainObject::ImportFile(const QString &filename,
else {
SendNotification(RDNotification::ModifyAction,cart->number());
}
if(!import_output_pattern.isEmpty()) {
RDLogLine *ll=new RDLogLine(cart->number(),cut->cutNumber());
printf("%s\n",
ll->resolveWildcards(import_output_pattern).toUtf8().constData());
delete ll;
}
delete settings;
delete conv;
delete cut;
@ -1623,6 +1633,13 @@ bool MainObject::FixChunkSizes(const QString &filename)
bool MainObject::RunPattern(const QString &pattern,const QString &filename,
RDWaveData *wavedata,QString *groupname)
{
// MAINTAINERS'S NOTE: These mappings must be kept in sync with those
// of the 'resolvePadFields()' method in
// 'apis/PyPAD/api/PyPAD.py', as well as the
// 'resolveWildcards()' method in the
// 'lib/rdlog_line.cpp' file and the
// 'VerifyPattern()' method in this file.
bool macro_active=false;
int ptr=0;
QChar field;
@ -1922,6 +1939,13 @@ bool MainObject::RunPattern(const QString &pattern,const QString &filename,
bool MainObject::VerifyPattern(const QString &pattern)
{
// MAINTAINERS'S NOTE: These mappings must be kept in sync with those
// of the 'resolvePadFields()' method in
// 'apis/PyPAD/api/PyPAD.py', as well as the
// 'resolveWildcards()' method in the
// 'lib/rdlog_line.cpp' file and the
// 'RunPattern()' method in this file.
bool macro_active=false;
for(int i=0;i<pattern.length();i++) {
if(pattern.at(i)==QChar('%')) {

View File

@ -114,6 +114,7 @@ class MainObject : public QObject
int import_segue_length;
unsigned import_cart_number;
QString import_metadata_pattern;
QString import_output_pattern;
QString import_string_agency;
QString import_string_album;
QString import_string_artist;