[mythtv-users] Converting scripts to not use the database directly

Simon Hobson linux at thehobsons.co.uk
Tue Nov 4 14:19:46 UTC 2014


Michael T. Dean <mtdean at thirdcontact.com> wrote:

>> My observation was that we are taking a step back from being able to use a tool where all the looping is nicely handled for us. Instead, everyone who writes a script to operate with the API would, it appears, have to re-invent the wheel every time.
> 
> So it's that much harder to do:
> 
> chanids = [1031, 1081, 1161, 1281, 1282, 1283, 1384]
> for channel in Channel.GetChannelList(chanids)
>    channel.SetVisible(false)
> 
> than
> 
> UPDATE channel SET visible = 0 WHERE chanid in (1031, 1081, 1161, 1281, 1282, 1283, 1384);

Just the same way that pretty well everything that can be done with AWK can also be done in shell - it's just that AWK is often the superior tool for the job. The parallel being that AWK is great for "looping over stuff" and automatically handles the looping in the background - instead of writing the loops in shell as can also be done.

In any case, are you over simplifying the update to make it look "not as bad". Does the API have a fully flexible selection ability ? Ie, is "get a list of channels where <some arbitrary criteria>" doable directly with one call, or do we need to get a list of channels, iterate through them to select the ones to work on, and ONLY THEN do the simple bit you've written ?

BTW - is doing an update really just "channel.SetVisible(false)" or is there more to it than that ?

>> I understand the desire to remove direct access ot the DB, but to remove a "good" tool (from the user's perspective) and replace it with what appears at the moment to be very inferior does seem a step backwards. IMO to be a "good" replacement the API needs to support set operations, arbitrary joins, arbitrary selections, and relative updates - which makes it sound rather like SQL ! It looks very much like at least 1 or 2 of those are missing.
> 
> You make an interesting point.  I'll work on removing some of the inferior tools we have right away.
> 
> In Watch Recordings, we currently have MENU|Playlist Options|Storage Options|Change Recording Group, which simply changes the recgroup.  I don't know why someone put that in there when it's so easy to just:
> 
> UPDATE recorded SET recgroup = 'Cancelled' WHERE chanid = '1071' AND starttime = '20141103200000';

Well if you insist on making your self look stupid and silly, then make ridiculous comparisons like that.

Clearly, the examples you give are "designed for the job". Since there is no "designed for the job" function that will automagically (in my example) setup the channels as I like them, then it needs to be done via an alternative method.
Applying reductio ad absurdum then hardly anything in Myth makes sense. If you persist in deliberately trying to make out that I have a different position to what I express, then you could argue that the whole scheduler is redundant as the user could do that themselves. The playback system is redundant as the user could just use (eg) VLC to playback a file. The user could manually delete files as the disk fills up. Etc, etc, etc.

Put another way, what goes into Myth are all the functions that "most people need". What doesn't go in is special functions that only a few people need. You seem to be arguing that because I point out the proposed changes make those special functions less easy to do, that is somehow equivalent to arguing that the common functions should be removed.



More information about the mythtv-users mailing list