Possible to run (trigger) user job via api?
Possible to run (trigger) user job via api?
This would be so powerful if this could be done! It would allow so many things to be done in an automated manner. In this case, my use is to remotely trigger a transcode for a specific video, which it then uploads to Google drive in the user job so I can more easily download it the next day. But I can think of at least a dozen uses.
Re: Possible to run (trigger) user job via api?
Hi,
A couple of questions first:
Just to be clear, from the command line does this do what
you want, only via a new endpoint in the Services API?
mythutil --queuejob userjob4 --chanid ... --starttime ...
Ref: mythutil --help queuejob
I'd be interested in understanding the dozen uses, remembering that there
are four User Jobs.
Do you build from source?
The understanding would be if the backend has a global address,
that anyone could cause a User Job to run.
A couple of questions first:
Just to be clear, from the command line does this do what
you want, only via a new endpoint in the Services API?
mythutil --queuejob userjob4 --chanid ... --starttime ...
Ref: mythutil --help queuejob
I'd be interested in understanding the dozen uses, remembering that there
are four User Jobs.
Do you build from source?
The understanding would be if the backend has a global address,
that anyone could cause a User Job to run.
Re: Possible to run (trigger) user job via api?
I believe mythutil —queuejob would do what I want. As long as it functions identically to user jobs run via mythfrontend and passes all variables.
Add the word potential before uses, i.e. a dozen potential uses. Really, way more than that as this opens up lots of automation possibilities. I don’t lierally mean I personally have a dozen uses I want to immediately use. . I see this as having huge potential use. Other examples, virtually any script in the wiki dealing with a recording could be triggered via a frontend app or an ip remote, etc. so, another use for me, archiving. Sometimes we like something so much, after watching it, we want to retain in Plex. Well, if I could trigger a user job from a frontend (non myth), then it could archive it without logging in, command line for the wife, etc. This seems like a very powerful technique for people.
Regarding global address, of course not! Would be a tunnel.
I have built from source, don’t really have any great desire to unless there’s some good reason, why do you ask? I am sure I could code it and test after I heal from surgery, maybe in June or so.
Let me know if you have further questions.
Add the word potential before uses, i.e. a dozen potential uses. Really, way more than that as this opens up lots of automation possibilities. I don’t lierally mean I personally have a dozen uses I want to immediately use. . I see this as having huge potential use. Other examples, virtually any script in the wiki dealing with a recording could be triggered via a frontend app or an ip remote, etc. so, another use for me, archiving. Sometimes we like something so much, after watching it, we want to retain in Plex. Well, if I could trigger a user job from a frontend (non myth), then it could archive it without logging in, command line for the wife, etc. This seems like a very powerful technique for people.
Regarding global address, of course not! Would be a tunnel.
I have built from source, don’t really have any great desire to unless there’s some good reason, why do you ask? I am sure I could code it and test after I heal from surgery, maybe in June or so.
Let me know if you have further questions.
Re: Possible to run (trigger) user job via api?
I've only tested %JOBID% and %TITLE% and they work.
Do you have any specific %% type variables that you use?
I can pass additional arguments to the jobqueue. This is working
on my test box:
Not sure everyone that uses global addresses knows about
tunneling (they should.)
Was just curious if you would have been able to be a tester,
no problem.
Do you have any specific %% type variables that you use?
I can pass additional arguments to the jobqueue. This is working
on my test box:
Code: Select all
curl --data UserJob=1 --data Chanid=1051 --data StartTime=2018-01-28T15:00:00 --data Args='a1 b2 c3' ofc0:6544/Dvr/AddJobQueueEntry
tunneling (they should.)
Was just curious if you would have been able to be a tester,
no problem.
Re: Possible to run (trigger) user job via api?
Ah, ok, yes, I can be a tester. I would test on OSX most likely as I have a build environment set up there and a lot of data.
Regarding user jobs and variables, fully aware that user jobs run on the backend. Definitely %TITLE% and %SUBTITLE% are useful, scanning the wiki, %SEASON%, %RECID%, %ORIGINALAIRDATE%, %FILE%, %EPISODE%, %CHANID% seem like they would be useful. These are stored in the DB, so, when available could be populated. Of course, the user job could also acquire these, just seems like the variables should be sent ideally, whatever is the stored value.
Looks like you already have an endpoint coded since you showed your cURL command, or was it already there?
This technique could even work around other missing API functions, I have a separate request out there to allow preserve and do not autoexpire for a richer frontend from non myth "frontends". Well, if the user job call was available, one of them could simply be to set those. Of course, that puts meup to 3 of the 4 I would use, and am quite confident I would have more. If you could accept name value pairs with arbitrary names and pass them on to the userjob, then, a single userjob could function in multiple roles even. But that's a nice to have.
What would be needed is a call to obtain the user job list so something useful can be presented on the frontend as far as what it does. It appears there is a GetSettingList that might do that. Running it it seems to return all settings. Which I suppose could work, or one could do 4 GetSetting calls to get each Userjob name.
Just an FYI, the past few years, I have been a system architect for a large internet company. That ended at year end 2017, I retired from work. Though I owe one last conversion management task. Just not sure yet after rotator cuff surgery when I will be up to it! And I head to Spain in mid May, which is a scary thought right now.
I see the potential for very rich frontends that are not myth coded. Thus far, have used Kodi plugin, Plex plugin (both need work which I may do), MrMC and the Apple TV app "MythTV" from SwiftBit who I have talked to in the hope I can get some more functionality added. But it needs some API calls like this one, so, long road. Then there is the IOS app that I have not tried yet. To me, supporting those types of clients is very important and could get mythtv out there even more. Those are just examples, I am sure others exist on other platforms.
Thank you very much for your interest.
Regarding user jobs and variables, fully aware that user jobs run on the backend. Definitely %TITLE% and %SUBTITLE% are useful, scanning the wiki, %SEASON%, %RECID%, %ORIGINALAIRDATE%, %FILE%, %EPISODE%, %CHANID% seem like they would be useful. These are stored in the DB, so, when available could be populated. Of course, the user job could also acquire these, just seems like the variables should be sent ideally, whatever is the stored value.
Looks like you already have an endpoint coded since you showed your cURL command, or was it already there?
This technique could even work around other missing API functions, I have a separate request out there to allow preserve and do not autoexpire for a richer frontend from non myth "frontends". Well, if the user job call was available, one of them could simply be to set those. Of course, that puts meup to 3 of the 4 I would use, and am quite confident I would have more. If you could accept name value pairs with arbitrary names and pass them on to the userjob, then, a single userjob could function in multiple roles even. But that's a nice to have.
What would be needed is a call to obtain the user job list so something useful can be presented on the frontend as far as what it does. It appears there is a GetSettingList that might do that. Running it it seems to return all settings. Which I suppose could work, or one could do 4 GetSetting calls to get each Userjob name.
Just an FYI, the past few years, I have been a system architect for a large internet company. That ended at year end 2017, I retired from work. Though I owe one last conversion management task. Just not sure yet after rotator cuff surgery when I will be up to it! And I head to Spain in mid May, which is a scary thought right now.
I see the potential for very rich frontends that are not myth coded. Thus far, have used Kodi plugin, Plex plugin (both need work which I may do), MrMC and the Apple TV app "MythTV" from SwiftBit who I have talked to in the hope I can get some more functionality added. But it needs some API calls like this one, so, long road. Then there is the IOS app that I have not tried yet. To me, supporting those types of clients is very important and could get mythtv out there even more. Those are just examples, I am sure others exist on other platforms.
Thank you very much for your interest.
Re: Possible to run (trigger) user job via api?
The endpoint is complete and tested on my box only. However, there are additional
security concerns from other developers that are being discussed now - so release
of this is on hold.
Interesting that during testing I found parameters missing from the Wiki (which have
been added.)
Not all parameters are available to all User Jobs/Events as you read in the Wiki. In this case
%RECID% isn't replaced in User Jobs.
security concerns from other developers that are being discussed now - so release
of this is on hold.
Interesting that during testing I found parameters missing from the Wiki (which have
been added.)
Not all parameters are available to all User Jobs/Events as you read in the Wiki. In this case
%RECID% isn't replaced in User Jobs.
Re: Possible to run (trigger) user job via api?
Thanks for the update!
I am sure you guys know this. It's available today via mythweb, which a frontend could send http to and execute in that manner. It's not an API, but it is already possible.
I am sure you guys know this. It's available today via mythweb, which a frontend could send http to and execute in that manner. It's not an API, but it is already possible.
Re: Possible to run (trigger) user job via api?
Dvr/ManageJobQueue was added to v30-Pre on May 14th, 2018.
https://github.com/MythTV/mythtv/commit ... deaa0fe8f2
https://github.com/MythTV/mythtv/commit ... deaa0fe8f2
Re: Possible to run (trigger) user job via api?
Thank you very much for this and for updating this post! Once I get back from Spain and the Canary Islands (leaving Wednesday), I'll have to update and try it out. This is just awesome.
Re: Possible to run (trigger) user job via api?
git log --since=5/11/2018 --author=Bill is the only documentation right now.
Wiki will follow.
Note that Myth/ManageDigestUser and Myth/ManageUrlProtection should be
used (if an application uses any POST endpoints, like this one.)
Wiki will follow.
Note that Myth/ManageDigestUser and Myth/ManageUrlProtection should be
used (if an application uses any POST endpoints, like this one.)
Re: Possible to run (trigger) user job via api?
Looked through the commit, all makes sense. Thanks again.