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

mtvf2894
Junior
Posts: 81
Joined: Sat Apr 10, 2021 2:33 pm
Great Britain

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

Post by mtvf2894 »

You are using MythTV Frontend and have gone into Watch Recordings. You have the description of the recording displayed.

Is it possible to find this recording in the recorded table in the database and change the contents of description field and then tell MythTV to update the frontend so this change is displayed within the currently open frontend?

I have tried looking at the API and the Protocol but can't find anything that will tell MythTV to do this.

I was thinking the "recording list change" may allow this but I can't seem to find the correct method of using "mythutil --event" to test this or even if this is the correct method of attempting this.
https://www.mythtv.org/wiki/RECORDING_L ... _Protocol)

Thanks
Current: v32 now v33.1 / Lubuntu 22.04 / AMD APU
Previous: v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
User avatar
bill6502
Developer
Posts: 2299
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 »

The Services API endpoint solution hasn't been released yet.

In mythfrontend, position on the recording of interest (e.g. on the Watch Recordings page) and press:
Menu->Recording Options->Change Recording Metadata. You can edit the Description (and other data)
there.
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 »

Many thanks for the reply.

I understand there is a frontend option but I would like to have something scriptable so I will cross fingers and hope for future API support.

Is trying to use commands like "mythutil --clearcache" and "mythutil --event" a dead end for what I am trying to do?

As a workaround does anyone know how existing user scripts that for example transcode handle the filename and filesize changing with regards to the database and them updating the frontend I may be able to adapt something?

Thanks
Current: v32 now v33.1 / Lubuntu 22.04 / AMD APU
Previous: v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
blm-ubunet
Senior
Posts: 265
Joined: Sun Jun 15, 2014 1:08 am
Cambodia

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

Post by blm-ubunet »

I don't change the filename but replace existing file with modified one. The actual filename does not need changing.

ionice -c3 mythcommflag --rebuild --chanid $CHANID --starttime $temp3
mythutil --clearcutlist --chanid $CHANID --starttime $temp3
mythutil --clearskiplist --chanid $CHANID --starttime $temp3

then later notify the user..
mythutil --bcastaddr 192.168.1.32 --notification --type normal --message_text "Finished Job: "$basename --description "MythCutKey mpegts cutter" --timeout=3
User avatar
bill6502
Developer
Posts: 2299
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 »

There's always the Python bindings. Consider this (which has no error checking, but it works.)

Code: Select all

#!/usr/bin/env python3                                                          
                                                                                
import sys                                                                      
from MythTV import Recorded                                                     
from MythTV.database import DBDataWrite                                         
                                                                                
                                                                                
class UpdateRecorded(DBDataWrite):                                              
    _table = 'recorded'                                                         
                                                                                
                                                                                
old = Recorded((sys.argv[1], sys.argv[2]))                                      
old.description = sys.argv[3]                                                   
                                                                                
new = UpdateRecorded()                                                          
new = old                                                                       
new.update()
The three arguments are: chanid, starttime (in localtime not UTC) and a description (enclosed in quotes).
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 »

bill6502 wrote:
Thu Jun 23, 2022 1:47 am
There's always the Python bindings. Consider this (which has no error checking, but it works.)
Thanks for posting the Python bindings may be the solution. I will check it out.
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 »

bill6502 wrote:
Thu Jun 23, 2022 1:47 am
There's always the Python bindings. Consider this (which has no error checking, but it works.)
Unfortunately this does not work.

It updates the database but you still have to exit the watch recordings screen and go back to the watch recordings screen for the new description to show.

It is no different than just updating the database directly. :? :(

At least I have learned a tiny bit more Python :D (make sure you get your time offsets correct or the bindings complain about a database error when it actually means it can't find a matching record)
Current: v32 now v33.1 / Lubuntu 22.04 / AMD APU
Previous: v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
User avatar
bill6502
Developer
Posts: 2299
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 »

The new API endpoint does cause an update to an active recording. Let me know if you build from source
and I can get you copy of the changes. Need to know your version though.
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 »

bill6502 wrote:
Wed Jun 29, 2022 2:25 am
The new API endpoint does cause an update to an active recording. Let me know if you build from source
and I can get you copy of the changes. Need to know your version though.
Thanks for the offer and that sounds like a great new feature I however was after more of a just refresh all the Watch Recordings screen. Still on v31 will be upgrading soon but not really in a position to run a custom release as I do not have a test setup. If there was something a bit closer being considered I could probably setup a VM to test things out.

If you have an external script running completely outside MythTV that may be updating Title, Subtitle, Description, Filesize, Recording Group etc in the recorded table if you can tell MythTV to refresh the Watch Recordings screen that would be perfect.

At the moment you can update these fields in the recorded table and you have to completely leave the Watch Recordings screen and re-enter the screen before MythTV will refresh its "cache".

Purely feature ideas I understand these may only be useful to people using external scripts/API. If it could automatically use the lastmodified field and see if any data has changed since it has loaded the Watch Recordings screen that would be perfect or have a "mythutil --refreshrecordings" that would trigger an update of the screen using the lastmodified field and when the Watch Recordings screen was first opened.

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: 909
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 »

I wonder if we could fake one of the MythEvents that the Watch Recordings screen listens for like RECORDING_LIST_CHANGE. The API's that add/delete/update available recordings probably should be sending out that event anyway to let any FE's or third part clients know something changed?
User avatar
bill6502
Developer
Posts: 2299
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 »

Paul, it's in Dvr::AddRecordedProgram where ri.SendUpdateEvent() is used. It's working in my
unreleased UpdateRecordedMetadata but called over in RecordingInfo::Apply* methods. I'm
planning on releasing it this week in master in the V2 API.
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 »

Paul / Bill this all sounds great and very promising.

If I am understanding correctly there is nothing I can do at the moment especially with v31 but hopefully in a future version something may be possible?

Or is there something that may work now with v31 using mythutil & fake events to update existing recordings and get the recording list to refresh?

All the more reason to get updated to v32 and latest LTS done.

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: 909
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 »

Easy answer is wait for v33 which should have all the necessary bits put in place for this to just work with the API.

The frontend Watch Recordings screen already listens for the necessary mythevents and will automatically update when required but from what Bill said it sounds like some parts of the API don't send the mythevents so the Watch Recordings screen does not currently update properly.

The plan is to release v33 in time for the Ubuntu 22.10 release which means to make the feature freeze (August 25th) we have about 5 weeks to at least get the pre release out. It's doable but with the imminent ffmpeg resync I expect many regressions so I have my doubts. It's easier to herd cats than get MythTV developers to co-operate getting a release ready and I no longer have the energy to push things along so if it happens fine if not we will just have to try again in April :)
User avatar
bill6502
Developer
Posts: 2299
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 »

Pushed [66bb8383]
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 »

This sounds great.

I need to first concentrate on getting off Ubuntu 20.10 to 22.04 LTS so I can get updates (both OS and MythTV).

Once I have done that I will give the new API a try either in v33 or via trying (do not know if I will succeed) to compile myself if it doesn't make it into v33.

Thanks again.
Current: v32 now v33.1 / Lubuntu 22.04 / AMD APU
Previous: v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
Post Reply