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

I have been trying to progress this.

1. I can use http://url:6744/Dvr/GetRecorded to get details of a recording in JSON format. This should ensure everything is in the correct format for the next step.
2. I then take this JSON string change the dates and change the title/subtitle and filename to the string "test" to make it unique.
3. I then try to use http://url:6744/Dvr/AddRecordedProgram but it fails/returns the following (the chanid exists and is not 0):

If it should work what is the simplest amount of data I can use with AddRecordedProgram which should succeed?

Is there anything I can check/enable to see a more detailed error on what the problem is?

Wondering if it doesn't work in 0.32fixes?

Code: Select all

HTTP/1.1 400 Bad Request
Server: MythTV/32.0+fixes.202301232104.f2ce7e33aa~ubuntu22.04.1 Linux/5.15.0-58-generic UPnP/1.0
<!DOCTYPE html><HTML><HEAD><TITLE>AddRecordedProgram: chanid 0 does not exist.</TITLE><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"></HEAD><BODY><H1>AddRecordedProgram: chanid 0 does not exist.</H1></BODY></HTML>
Thanks
Current: MythTV v32 / Lubuntu 22.04 / AMD APU
Previous: MythTV v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
User avatar
paulh
Developer
Posts: 871
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 »

Just wondering if it's a regression in the V2 API? Can you do a quick test using the old API on port 6544 to confirm you get the same behaviour there.
mtvf2894
Junior
Posts: 63
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 »

paulh wrote:
Sat Jan 28, 2023 11:12 am
Just wondering if it's a regression in the V2 API? Can you do a quick test using the old API on port 6544 to confirm you get the same behaviour there.
Using :6544

Code: Select all

HTTP/1.1 501 Not Implemented
:cry:

Any ideas what I should try next?

Thanks
Current: MythTV v32 / Lubuntu 22.04 / AMD APU
Previous: MythTV v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
User avatar
paulh
Developer
Posts: 871
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 »

That's odd I see it in the code for fixes/32 :?
https://github.com/MythTV/mythtv/blob/f ... r.cpp#L335

It was added by John back in April 2021.
https://github.com/MythTV/mythtv/commit ... 6978be6e35

John recently said something about having problems with the Services API but not sure if it has anything to do with this.
mtvf2894
Junior
Posts: 63
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 »

paulh wrote:
Sun Jan 29, 2023 11:44 pm
That's odd I see it in the code for fixes/32 :?
https://github.com/MythTV/mythtv/blob/f ... r.cpp#L335
John recently said something about having problems with the Services API but not sure if it has anything to do with this.
No idea what I am doing here but it is around line 347 where the error is being generated in the link above.

I am using :6744 and to try to simplify things I am setting post data as follows still same error for me.

Thanks

Code: Select all

{"Program": { "Channel": {"ChanId": 10148}, "Recording": {}, "Artwork": {}, "Cast": {}}}

Code: Select all

HTTP/1.1 400 Bad Request
Server: MythTV/32.0+fixes.202301232104.f2ce7e33aa~ubuntu22.04.1 Linux/5.15.0-58-generic UPnP/1.0
<!DOCTYPE html><HTML><HEAD><TITLE>AddRecordedProgram: chanid 0 does not exist.</TITLE><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"></HEAD><BODY><H1>AddRecordedProgram: chanid 0 does not exist.</H1></BODY></HTML>

Code: Select all

int Dvr::AddRecordedProgram(const QJsonObject &jsonObj)
{
    QJsonObject root      = jsonObj;
    QJsonObject program   = root["Program"].toObject();
    QJsonObject channel   = program["Channel"].toObject();
    QJsonObject recording = program["Recording"].toObject();
    QJsonObject cast      = program["Cast"].toObject();

    ProgInfo *pi = new ProgInfo();
    int       chanid = channel.value("ChanId").toString("0").toUInt();
    QString   hostname = program["HostName"].toString("");

    if (ChannelUtil::GetChanNum(chanid).isEmpty())
        throw QString("AddRecordedProgram: chanid %1 does "
                      "not exist.").arg(chanid);
Current: MythTV v32 / Lubuntu 22.04 / AMD APU
Previous: MythTV v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
User avatar
paulh
Developer
Posts: 871
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 »

Just came across this commit which probably explains why the V1 API is broken
https://github.com/MythTV/mythtv/commit/225664a3399e

For some reason the ChanID isn't being found or extracted properly so the API call fails. There are some strange differences between master and fixes/32 in this area.

I've pinged John maybe he can shed some light on it :idea:
User avatar
bill6502
Developer
Posts: 2162
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 »

Just tested my old add_recording.py (https://pastebin.com/DwEmV7tF) and it works
on both ports. It's easier to get a template and modify it. That answers the original
question about minimum number of parameters required.

I *think* the issue here is in using the "test" program name because it probably doesn't
exist in the Guide.
User avatar
paulh
Developer
Posts: 871
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 »

We have a theory you can help test :)

If you pass the ChanId in quotes does it work or at least get past that failure?

Code: Select all

{"Program": { "Channel": {"ChanId": "10148"}, "Recording": {}, "Artwork": {}, "Cast": {}}}
User avatar
bill6502
Developer
Posts: 2162
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 »

Adds the rule either way. Here's the lines from the program above:

Code: Select all

        ######################## Just testing: Original (works as the returned Guide integer)                 
        # template['ChanId'] = guide_data['Channel']['ChanId']                  
        ######################## Pass ChanId as a string (also worked, with proper ChanId for the Program being used)          
        template['ChanId'] = '10501'
I reallllllllly suggest getting a template. The update_template function does that.

Here's the Wiki of interest: https://www.mythtv.org/wiki/DVR_Service ... rdSchedule
And it references:https://www.mythtv.org/wiki/DVR_Service ... rdSchedule that gets
the parameters needed without trying to figure out everything. I recall that I've been here
long ago and tried crafting the AddRecordSchedule by hand -- and failed miserably.

@mtvf2894 look at the update_template function. Also look at the options to GetRecordSchedule
and pick the the Template or ChanId and StartTime. Note the 'Station parameter equal to CallSign'
comment, that's critical. I used the Template method. You probably want the ChanId and StartTime.
mtvf2894
Junior
Posts: 63
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 »

Conscious I may be wasting your time due to inexperience so if I just need to wait until v33 let me know but if you are happy to continue:

1. Just in case there is some confusion I am referring to the end point Dvr/AddRecordedProgram (not Dvr/AddRecordSchedule) - but I am thinking I could give this a try if you want as if it works at least it shows to me I am setting the headers and post fields correctly and the problem is specific to Dvr/AddRecordedProgram?

2. :6544/Dvr/AddRecordedProgram does not work at all

Code: Select all

HTTP/1.1 501 Not Implemented
3. Unfortunately putting the ChanId in quotes when using :6744/Dvr/AddRecordedProgram does not help same error message (note I may be completely wrong on where the error message is coming from in code - I was only guessing) :(

Code: Select all

{"Program": { "Channel": {"ChanId": "10148"}, "Recording": {}, "Artwork": {}, "Cast": {}}}

Code: Select all

MythTV/32.0+fixes.202301232104.f2ce7e33aa~ubuntu22.04.1 Linux/5.15.0-58-generic UPnP/1.0

Code: Select all

AddRecordedProgram: chanid 0 does not exist.
Many thanks
Current: MythTV v32 / Lubuntu 22.04 / AMD APU
Previous: MythTV v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
User avatar
bill6502
Developer
Posts: 2162
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 »

I'm wasting yours.

Let's start over. Do you want to change the metadata for an existing recording or the data in the Guide?
mtvf2894
Junior
Posts: 63
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 »

At this point I would like to do a basic add and update of an item in the Watch Recordings area of MythTV.

I thought I would start with /Dvr/AddRecordedProgram as that should be in v32fixes which I am now running.

I can successfully get JSON results from /Dvr/GetRecordedList and /Dvr/GetRecorded so I think I have the basics.

When I try to use:
:6544/Dvr/AddRecordedProgram I get "Not Implemented"
:6744/Dvr/AddRecordedProgram I get "AddRecordedProgram: chanid 0 does not exist.".

I would like any suggestions on what I could be trying to see if it is something I am doing wrong or whether there is something that is stopping this from working in v32fixes?

All I can think of is should I try a different "Add" endpoint and see if that works?

Thanks
Current: MythTV v32 / Lubuntu 22.04 / AMD APU
Previous: MythTV v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
User avatar
paulh
Developer
Posts: 871
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 »

You should be able to take the output you get from /Dvr/GetRecorded make any changes you want and pass that to /Dvr/AddRecordedProgram at least that is what the original commit message said.

I thought there was a problem with extracting the ChanID if it was passed as a integer and not passed as a string but you say it still fails so not sure now.
User avatar
bill6502
Developer
Posts: 2162
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 »

This adds the recorded program. Use --help to see what needs to be done.
--debug will print the JSON used to add the program.

https://pastebin.com/yuWZ40CP

Note that the StartTime has to be modified otherwise the DB insert will fail.
I just changed the year for testing.

David was going to cut a v33 release 2/1/2023, so I'm not sure this is needed.
But, the endpoint does work. Tested on port 6544 only
Last edited by bill6502 on Wed Feb 01, 2023 8:25 am, edited 2 times in total.
Reason: Another try. This changes the StartTs as well as the StartTime and worked (once) on 6544 and 6744. Still doesn't appear in Watch List
User avatar
bill6502
Developer
Posts: 2162
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 »

Doesn't show up in the frontend Watched List though. Even with running mythutil --clearcache or --resched
or quitting the FE and starting it up again. Yet, my print_recorded.py tool finds the additions.
Post Reply