Opened 20 years ago
Closed 20 years ago
#937 closed patch (fixed)
[PATCH]: mythfilldatabase --file tweaks
| Reported by: | Owned by: | Isaac Richards | |
|---|---|---|---|
| Priority: | minor | Milestone: | unknown |
| Component: | mythtv | Version: | head |
| Severity: | medium | Keywords: | |
| Cc: | Ticket locked: | no |
Description
mythfilldatabase --file doesn't add the xmltvid to the channel table. This patch fixes this and also provides two additional features:
- build callsign from first two words of the channel name
- if the --preset option is present and chanstr is empty, use chanid%1000 (produces chanstr 1..n)
Index: filldata.cpp
===================================================================
--- filldata.cpp (revision 8501)
+++ filldata.cpp (working copy)
@@ -2200,18 +2200,34 @@
if ((mplexid > 0) || (minor == 0))
chanid = ChannelUtil::CreateChanID(id, (*i).chanstr);
- if ((*i).callsign == "")
- (*i).callsign = QString::number(chanid);
+ if ((*i).callsign.isEmpty() ) {
+ QString tmp = (*i).name.stripWhiteSpace().upper();
+ QString t1 = tmp.section(" ", 0,0);
+ QString t2 = tmp.section(" ", 1,1);
+ if( t2.isEmpty() ) {
+ tmp.remove(5,tmp.length());
+ } else {
+ t1.remove(4,t1.length()).stripWhiteSpace();
+ t1.append(t2.remove(5-t1.length(),t2.length()));
+ tmp=t1;
+ }
+ (*i).callsign = tmp.stripWhiteSpace();
+ }
if (chanid > 0)
{
+ QString cstr = QString((*i).chanstr);
+ if( channel_preset && cstr.isEmpty() ) {
+ cstr = QString::number(chanid%1000);
+ }
ChannelUtil::CreateChannel(
mplexid, id, chanid,
- (*i).callsign, (*i).name, (*i).chanstr,
+ (*i).callsign, (*i).name, cstr,
0 /*service id*/, major, minor,
false /*use on air guide*/, false /*hidden*/,
false /*hidden in guide*/,
- freqid, localfile, (*i).tvformat);
+ freqid, localfile, (*i).tvformat,
+ (*i).xmltvid);
}
}
}
Change History (5)
comment:1 by , 20 years ago
| Version: | → head |
|---|
comment:2 by , 20 years ago
comment:3 by , 20 years ago
I hate it when it reformats my comment. :( Anyway, fix the indention on the code in my comment and see if you think it accomplishes what you're looking for.
comment:4 by , 20 years ago
Thanks for the review and corrections. Here's a revised version of the patch:
Index: filldata.cpp
===================================================================
--- filldata.cpp (revision 8506)
+++ filldata.cpp (working copy)
@@ -2200,18 +2200,37 @@
if ((mplexid > 0) || (minor == 0))
chanid = ChannelUtil::CreateChanID(id, (*i).chanstr);
- if ((*i).callsign == "")
- (*i).callsign = QString::number(chanid);
+ if ((*i).callsign.isEmpty())
+ {
+ QStringList words = QStringList::split(" ", (*i).name.simplifyWhiteSpace().upper());
+ QString callsign = "";
+ if (words[1].isEmpty())
+ {
+ callsign = words[0].left(5);
+ }
+ else
+ {
+ callsign = words[0].left(words[1].length()==1?4:3);
+ callsign += words[1].left(5-callsign.length());
+ }
+ (*i).callsign = callsign;
+ }
if (chanid > 0)
{
+ QString cstr = QString((*i).chanstr);
+ if( channel_preset && cstr.isEmpty() )
+ {
+ cstr = QString::number(chanid%1000);
+ }
ChannelUtil::CreateChannel(
mplexid, id, chanid,
- (*i).callsign, (*i).name, (*i).chanstr,
+ (*i).callsign, (*i).name, cstr,
0 /*service id*/, major, minor,
false /*use on air guide*/, false /*hidden*/,
false /*hidden in guide*/,
- freqid, localfile, (*i).tvformat);
+ freqid, localfile, (*i).tvformat,
+ (*i).xmltvid);
}
}
}
comment:5 by , 20 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.

I haven't tested this yet since I don't use --file, but is the following line correct?
QString tmp = (*i).name.stripWhiteSpace().upper();
Shouldn't that be simplifyWhiteSpace() since you then split on spaces right below that?
And stripWhiteSpace() returns a QString, it does not modify the QString in place, so the following line would not be stripped:
t1.remove(4,t1.length()).stripWhiteSpace();
Would something like this work and be easier to follow?
QStringList words = QStringList::split(" ", (*i).name.simplifyWhiteSpace().upper(); QString callsign = ""; if (words[1].isEmpty()) {
} else {
} (*i).callsign = callsign;