[mythtv-users] Converting scripts to not use the database directly
Mike Rice
mikerice1969 at gmail.com
Mon Nov 3 17:26:15 UTC 2014
On Sun, Nov 2, 2014 at 8:55 AM, Paul Harrison <mythtv at sky.com> wrote:
> On 02/11/14 16:40, Mike Rice wrote:
>
> On Sat, Nov 1, 2014 at 6:47 PM, Mike Rice <mikerice1969 at gmail.com
>> <mailto:mikerice1969 at gmail.com>> wrote:
>>
>>
>> I believe I have it generally working by using urlencoded data and
>> remapping the keys since as Bill mentioned they are different. To
>> me this seems pretty dangerous. Much more dangerous than using
>> mysql to set a single column.
>>
>> As far as I can tell you need to supply each parameter to the
>> function:
>>
>> bool Channel::UpdateDBChannel( uint MplexID,
>> uint SourceID,
>> uint ChannelID,
>> const QString &CallSign,
>> const QString &ChannelName,
>> const QString &ChannelNumber,
>> uint ServiceID,
>> uint ATSCMajorChannel,
>> uint ATSCMinorChannel,
>> bool UseEIT,
>> bool visible,
>> const QString &FrequencyID,
>> const QString &Icon,
>> const QString &Format,
>> const QString &XMLTVID,
>> const QString &DefaultAuthority )
>>
>> If you don't supply the parameter it ends up zero and your table
>> is updated with a zero value for that column. If I am careful I
>> can get this right now but if someone adds a parameter here and
>> does not add it with the same name in the GET function (or if my
>> script doesn't use those keys) it will be zero when I call the
>> function.
>>
>>
>> To answer my own question. The wsdl info describes all the parameters to
>> the routine. So the script can build the parameter data by walking the
>> wsdl parameters and then only issue to POST call when we have data for each
>> parameter. This would solve my concern about unspecified fields getting
>> zero values. It's also safer than relying only on the documentation.
>>
>> At some point when I get a better understanding of this stuff I will
>> update the Wiki with some examples.
>>
>>
> It sounds like UpdateDBChannel has been implemented incorrectly it's not
> meant to update a value which was not specified.
>
> Paul H.
>
Are all the APIs that update implemented like this or is this just an
anomaly? If it could just be called with ChannelID=1005&visible=false that
sure would make simpler and safer to use.
Anyway as it turns out writing a simple sql command was so easy I never
really gave this 'visible' problem much thought. After spending time
trying to write a script for it I've come to the conclusion that I don't
really even want this script anymore. I think I can do better just
adjusting my recording rules.
Currently I have rules that:
1. Record my favorite hockey team on any channel
2. Record my favorite baseball team on any channel
There are a set of channels GAME* that require an extra subscription and I
typically only buy the hockey version. To avoid trying to record baseball
from those channels I would change the visible field.
I now realize a better solution would be to change rules 1 and 2 so they do
not record on the GAME channels. Then add a third rule that only records
on the GAME channels. With this I can easily (without a script) deactivate
the rule when I do not have the subscription and reactivate it when I do
(or when there is a free preview happening). This should be much better
for me.
The next script I looked at appears to have the same issue. I record all
'New Movies" from a set of premium channels. Then daily use a script to
change the Recording Group to "Movies-Best, Movies-Better,
Movies-Subtitled, etc." based on the "stars" rating. Instead I really
should just set up separate rules for each and then they would
automatically go to the correct group. With rules I can also modify the
priorities of each rule so "Movies-Best" would be recorded before
"Movies-Good" and "Movies-Bad" would be expired before "Movies-Best".
I don't know if this is true for all my scripts but thought I'd bring it up
here. Turns out that because I could write a sql query easily I've been
doing stuff sub-optimally for years.
I am still going to purse learning how to use these APIs but by the time I
am done reviewing my scripts I might not actually need to use them.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20141103/e4c83fd1/attachment.html>
More information about the mythtv-users
mailing list