Can I edit a recording database entry and tell the frontend to update?

For discussion related to MythTV which doesn't belong in another forum.

Moderator: Forum Moderators

User avatar
paulh
Developer
Posts: 913
Joined: Thu Feb 06, 2014 6:09 pm
Great Britain

Re: Can I edit a recording database entry and tell the frontend to update?

Post by paulh »

@Bill did you test it on fixes/32 or master? The code is slightly different depending on what version you tested.
User avatar
bill6502
Developer
Posts: 2348
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Can I edit a recording database entry and tell the frontend to update?

Post by bill6502 »

Good point, tested on master.
User avatar
bill6502
Developer
Posts: 2348
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Can I edit a recording database entry and tell the frontend to update?

Post by bill6502 »

Replaced the previous pastebin link. Now changing StartTs in addition to StartTime. Worked on 6544 and 6744. But still doesn't show up in the Watch List. Use https://pastebin.com/yuWZ40CP . Always use the --starttime switch changing the value on every run.
Testing on master.
mtvf2894
Junior
Posts: 81
Joined: Sat Apr 10, 2021 2:33 pm
Great Britain

Re: Can I edit a recording database entry and tell the frontend to update?

Post by mtvf2894 »

Great thanks for this.

As I am only running v32 I have no option but to use v33 to progress this.

It doesn't seem to make sense to "waste" time on v32.

Any tips on what I could do as I need my v32 setup to continue to work reliably?
Current: v32 now v33.1 / Lubuntu 22.04 / AMD APU
Previous: v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
User avatar
paulh
Developer
Posts: 913
Joined: Thu Feb 06, 2014 6:09 pm
Great Britain

Re: Can I edit a recording database entry and tell the frontend to update?

Post by paulh »

The problem as I see it is the way we extract some of the numeric values like ChanId from the Qt JsonValue is not consistent and prone to failure depending on how they are represented in the JSON.

{ChanId: 123456} vs {ChanId: "123456"} The first should be correct because ChanId is an integer/number. The second one should be incorrect because ChanId is not a string.

At the moment master and fixes/32 extract the value differently.
For the V2 API in master it's like this

Code: Select all

int       chanid = channel.value("ChanId").toVariant().toString().toUInt();  
and in fixes/32 it is like this

Code: Select all

int       chanid = channel.value("ChanId").toString("0").toUInt();
If I'm interpreting the Qt docs correctly (they say "If type() is not String, the defaultValue will be returned") the last one will only work if ChanId is a string otherwise it will use the default "0" value which is why I think the ChanId keeps being reset to 0 for mtvf2894.

The question is is the way master is doing it the proper way to extract the ChanId? It seems rather convoluted but Peter suggested it could have been done like that so it will work with ChanId as both a number and a string?

I think the important thing is /dvr/GetRecorded and /dvr/AddRecordedProgram should use a consistent format so you should be able to use the result from GetRecorded and pass it back to AddRecordedProgram.
mtvf2894
Junior
Posts: 81
Joined: Sat Apr 10, 2021 2:33 pm
Great Britain

Re: Can I edit a recording database entry and tell the frontend to update?

Post by mtvf2894 »

Now using a v33 VM but my script still returns a ChanID 0 does not exist error so something isn't correct. :(

If I use the .py script I have managed to get it working :D but I have no idea why it is not working in my script. :(

Mine works fine for "getting" end points so I just must have something set incorrect for posting.

Is it possible for the py script to output more debug information for example the post data it is using, the HTTP headers and anything else that may have an impact?

Thanks
Current: v32 now v33.1 / Lubuntu 22.04 / AMD APU
Previous: v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
User avatar
paulh
Developer
Posts: 913
Joined: Thu Feb 06, 2014 6:09 pm
Great Britain

Re: Can I edit a recording database entry and tell the frontend to update?

Post by paulh »

Try increasing the log level on the backend to include the http:debug messages which may give a clue as to what the backend is receiving and trying to process etc. :idea:
User avatar
bill6502
Developer
Posts: 2348
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Can I edit a recording database entry and tell the frontend to update?

Post by bill6502 »

@ mtvf2894 On v33, try this version: https://pastebin.com/jLrbMTJx with a command line like this:

Code: Select all

add_recorded_program.py --host=localhost --recorded=816 --port=6744 --starttime="2023-01-26T04:04:00Z" --title="Just Testing123" --jdump
Use --help to see what the switches do. You need a valid RecordId, either port and you get to make up the starttime/title.
You can only use a starttime once, always change or you get an error. There's a --v32 switch that will send the ChanId as an
integer otherwise it gets sent as a string. Still doesn't show up in my Watch screen.

Won't work on v32 because it doesn't have John's fix to pass jsondata as opposed to postdata. But, on v33 you can test. Of course there's always the
UpdateRecordedMetadata endpoint available to you with v33. That DOES make changes visible in Watch Recordings.

You can't use AddRecordedProgram to change existing metadata because it will fail if the recording (RecordedId)
already exists. I think the authors intent was for recorded files that have no entry in the recorded table.
mtvf2894
Junior
Posts: 81
Joined: Sat Apr 10, 2021 2:33 pm
Great Britain

Re: Can I edit a recording database entry and tell the frontend to update?

Post by mtvf2894 »

[deleted - rewriting due to it not making sense!]
Current: v32 now v33.1 / Lubuntu 22.04 / AMD APU
Previous: v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
mtvf2894
Junior
Posts: 81
Joined: Sat Apr 10, 2021 2:33 pm
Great Britain

Re: Can I edit a recording database entry and tell the frontend to update?

Post by mtvf2894 »

Thanks again for all the help.

Here is an update:
  • My problem with v33 was not setting the correct headers for the /Dvr/AddRecordedProgram endpoint. Setting the correct headers and it works* without any ChanId = 0 error.

    Code: Select all

    Content-Type:application/json
  • Whatever I do I can't get it to work with v32 but this may need a fix as you mention.
  • Have also tried the /Dvr/UpdateRecordedMetadata endpoint on v33 with no problems so far.
A few issues which have unfortunately stopped me in my tracks*:
  • /Dvr/AddRecordedProgram is not using some fields and overwriting them. For example, the FileName field is not used (it is overwritten with an auto-generated MythTV type filename).
  • /Dvr/UpdateRecordedMetadata there are fields missing I was hoping to change including Basename/Filename, Filesize, Category, RecGroup, TimeStretch and PlayGroup.
Are there any workarounds to my predicament?
Current: v32 now v33.1 / Lubuntu 22.04 / AMD APU
Previous: v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
Post Reply