mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-11 09:03:40 +02:00
2016-07-12 Fred Gleason <fredg@paravelsystems.com>
* Added an '--xml' switch to rdimport(1) in 'utils/rdimport/rdimport.cpp' and 'utils/rdimport/rdimport.h'.
This commit is contained in:
@@ -89,6 +89,7 @@ MainObject::MainObject(QObject *parent)
|
||||
import_string_year=0;
|
||||
import_clear_datetimes=false;
|
||||
import_clear_dayparts=false;
|
||||
import_xml=false;
|
||||
|
||||
//
|
||||
// Read Command Options
|
||||
@@ -379,7 +380,15 @@ MainObject::MainObject(QObject *parent)
|
||||
}
|
||||
import_cmd->setProcessed(i,true);
|
||||
}
|
||||
if(import_cmd->key(i)=="--xml") {
|
||||
import_xml=true;
|
||||
import_cmd->setProcessed(i,true);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Sanity Checks
|
||||
//
|
||||
if(import_datetimes[0].isValid()&&import_clear_datetimes) {
|
||||
fprintf(stderr,"rdimport: --set-datetimes and --clear-datetimes are mutually exclusive\n");
|
||||
exit(255);
|
||||
@@ -388,6 +397,10 @@ MainObject::MainObject(QObject *parent)
|
||||
fprintf(stderr,"rdimport: --set-daypart-times and --clear-daypart-times are mutually exclusive\n");
|
||||
exit(255);
|
||||
}
|
||||
if((!import_metadata_pattern.isEmpty())&&import_xml) {
|
||||
fprintf(stderr,"rdimport: --metadata-pattern and --xml are mutually exclusive\n");
|
||||
exit(255);
|
||||
}
|
||||
|
||||
import_cut_markers=new MarkerSet();
|
||||
import_cut_markers->loadMarker(import_cmd,"cut");
|
||||
@@ -722,6 +735,9 @@ MainObject::MainObject(QObject *parent)
|
||||
if(import_string_year!=0) {
|
||||
printf(" Year set to: %d\n",import_string_year);
|
||||
}
|
||||
if(import_xml) {
|
||||
printf(" Importing RDXML metadata from external file\n");
|
||||
}
|
||||
import_cut_markers->dump();
|
||||
import_talk_markers->dump();
|
||||
import_hook_markers->dump();
|
||||
@@ -1026,6 +1042,10 @@ MainObject::Result MainObject::ImportFile(const QString &filename,
|
||||
}
|
||||
}
|
||||
|
||||
if(import_xml) {
|
||||
ReadXmlFile(filename,wavedata);
|
||||
}
|
||||
|
||||
if(import_use_cartchunk_cutid||found_cart) {
|
||||
*cartnum=0;
|
||||
sscanf(wavedata->cutId(),"%u",cartnum);
|
||||
@@ -1897,6 +1917,53 @@ bool MainObject::SchedulerCodeExists(const QString &code) const
|
||||
}
|
||||
|
||||
|
||||
void MainObject::ReadXmlFile(const QString &basename,RDWaveData *wavedata) const
|
||||
{
|
||||
QString xmlname="";
|
||||
FILE *f=NULL;
|
||||
char line[1024];
|
||||
QString xml="";
|
||||
std::vector<RDWaveData> wavedatas;
|
||||
|
||||
//
|
||||
// Get XML Filename
|
||||
//
|
||||
QStringList f0=f0.split(".",basename);
|
||||
for(unsigned i=0;i<f0.size()-1;i++) {
|
||||
xmlname+=f0[i]+".";
|
||||
}
|
||||
xmlname+="xml";
|
||||
if(import_verbose) {
|
||||
printf(" Reading xml metadata from \"%s\": ",(const char *)xmlname);
|
||||
}
|
||||
|
||||
//
|
||||
// Read XML
|
||||
//
|
||||
wavedata->clear();
|
||||
if((f=fopen(xmlname,"r"))==NULL) {
|
||||
if(import_verbose) {
|
||||
printf("failed [%s]\n",strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(import_verbose) {
|
||||
printf("success\n");
|
||||
}
|
||||
while(fgets(line,1024,f)!=NULL) {
|
||||
xml+=line;
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
//
|
||||
// Parse
|
||||
//
|
||||
if(RDCart::readXml(&wavedatas,xml)>0) {
|
||||
*wavedata=wavedatas[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
QApplication a(argc,argv,false);
|
||||
|
@@ -78,6 +78,7 @@ class MainObject : public QObject
|
||||
QDateTime GetCachedTimestamp(const QString &filename);
|
||||
void WriteTimestampCache(const QString &filename,const QDateTime &dt);
|
||||
bool SchedulerCodeExists(const QString &code) const;
|
||||
void ReadXmlFile(const QString &basename,RDWaveData *wavedata) const;
|
||||
RDConfig *import_config;
|
||||
RDCmdSwitch *import_cmd;
|
||||
unsigned import_file_key;
|
||||
@@ -107,6 +108,7 @@ class MainObject : public QObject
|
||||
bool import_clear_dayparts;
|
||||
bool import_fix_broken_formats;
|
||||
int import_persistent_dropbox_id;
|
||||
bool import_xml;
|
||||
unsigned import_format;
|
||||
unsigned import_samprate;
|
||||
unsigned import_bitrate;
|
||||
|
Reference in New Issue
Block a user