Jump to content

New Plugin - Custom Scripting | Emby ScripterX


Anthony Musgrove

Recommended Posts

maegibbons
On 24/03/2022 at 02:22, Anthony Musgrove said:

Hey guys, I am so sorry about the delay.  I will be getting back onto this project shortly.

 

I'll also be looking for another developer who would be keen to continue developing with me.

Thank you so much everyone for the feedback and for using my plugin.

 

Warmest regards,

Anthony 

 

Hi Anthony

Great to know you are still around.  However, looks like you are busy.

What sort of time frame are we looking at for a fix?  Should we start looking at other methods?

Can you give the source to luke?

Krs

 

Mark

Link to comment
Share on other sites

Spaceboy
On 22/03/2022 at 19:50, Luke said:

OK so the next webhooks plugin update will have six new events related to live tv that you can subscribe to. It will be available for server versions 4.7.0.32+:

Untitled1.png

sorry luke, i don't understand how this is supposed to replace scripterx if you can only call urls and not local file paths?

Link to comment
Share on other sites

14 minutes ago, Spaceboy said:

sorry luke, i don't understand how this is supposed to replace scripterx if you can only call urls and not local file paths?

You have to setup a webserver, receive the http requests, and then do something with them. I had an idea here for how the webhooks requests could be passed through to a command line: 

I think if someone wanted to whip that up, that would be great. Then all you'd have to do is come to us with more webhooks requests whenever you need new events. And then everybody wins doing it that way, webhooks users, command line users, etc.

Link to comment
Share on other sites

maegibbons
3 minutes ago, Luke said:

You have to setup a webserver, receive the http requests, and then do something with them. I had an idea here for how the webhooks requests could be passed through to a command line: 

I think if someone wanted to whip that up, that would be great. Then all you'd have to do is come to us with more webhooks requests whenever you need new events. And then everybody wins doing it that way, webhooks users, command line users, etc.

I take it this is your April fools idea?

Perhaps you can just add the script hooks needed to the "post processing" options already in existence?

  • Haha 1
Link to comment
Share on other sites

Just now, maegibbons said:

I take it this is your April fools idea?

Perhaps you can just add the script hooks needed to the "post processing" options already in existence?

Well that's what webhooks are, they are http requests.

Link to comment
Share on other sites

ttgapers

Does anyone know if there is a possibility to use this solution to have a script that checks m3u or LiveTV channels - do a GET and if anything but a HTTP 200 code received then mark/report the channel as down or better yet "disable" it in Live TV? I know @Luke there isn't a "Disable Channel" option right now, but something to perhaps consider. I have been thinking of a method to auto-disable "dead" channels from Live TV via Emby.

Just a thought. Cheers and this is an awesome tool.

Link to comment
Share on other sites

2 minutes ago, ttgapers said:

Does anyone know if there is a possibility to use this solution to have a script that checks m3u or LiveTV channels - do a GET and if anything but a HTTP 200 code received then mark/report the channel as down or better yet "disable" it in Live TV? I know @Luke there isn't a "Disable Channel" option right now, but something to perhaps consider. I have been thinking of a method to auto-disable "dead" channels from Live TV via Emby.

Just a thought. Cheers and this is an awesome tool.

Sure there is, with the checkboxes on the channel management list screen.

Link to comment
Share on other sites

mickle026
45 minutes ago, Luke said:

Sure there is, with the checkboxes on the channel management list screen.

They are there but don't work in beta .32 on windows.   I just thought they were an in progress feature.

They won't recheck after unchecking and nothing happens either.

Link to comment
Share on other sites

maegibbons
1 hour ago, Luke said:

Well that's what webhooks are, they are http requests.

I know what they are but not easy to process on the local machine to run a powershell script.  Expanding the post recording scripts to include recording start script would be easy.

Krs

 

Mark

 

Link to comment
Share on other sites

59 minutes ago, mickle026 said:

They are there but don't work in beta .32 on windows.   I just thought they were an in progress feature.

They won't recheck after unchecking and nothing happens either.

The function works, it's just the state of the checkbox that is having an issue after re-checking. We'll look at it. Thanks.

Link to comment
Share on other sites

45 minutes ago, maegibbons said:

I know what they are but not easy to process on the local machine to run a powershell script.  Expanding the post recording scripts to include recording start script would be easy.

Krs

 

Mark

 

Right I understand that when you're only using a single machine, webhooks are a bit more work to setup. What additional info is needed for post processing?

Link to comment
Share on other sites

ttgapers
3 hours ago, Luke said:

Sure there is, with the checkboxes on the channel management list screen.

@Luke ok I guess this can be done programmatically then? Awesome. Will have to check the API call for it. I thought the checkboxes only removes it from a Mapped Channel (meaning the channel shows but no EPG).

Link to comment
Share on other sites

sydlexius
2 hours ago, maegibbons said:

I know what they are but not easy to process on the local machine to run a powershell script.  Expanding the post recording scripts to include recording start script would be easy.

Krs

 

Mark

 

You'd also be able to potentially do work with batch + cURL, though that would not be my preference 🤮

Edited by sydlexius
Link to comment
Share on other sites

Problem is there is hardly any webhooks to use and by their very nature are status or event message.  Some of the things people including myself have wanted to do are only available  using an actual API like what's shown when clicking on the Swagger API link at the bottom of the Dashboard https://localhost:8096/emby/openapi. If the API shown  here https://github.com/MediaBrowser/Emby.ApiClient  worked as well as doing what I mention next we would have a powerful set of tools to work with quite easily.

Webhooks need to be more dynamically built right into the code at the class level so they are automatically added and work with any function added to the code. That shouldn't be difficult to do at all. A user should be able to hook nearly anything that takes place inside Emby that is event worthy from a login to a failed login to to a security or message written to Alerts or more often not written.  One way that would be very clean an user friendly is a webpage very similar to Swagger that populates automatically.  You would be able to hook anything listed by simply filling in the URL you want to trigger for that event.  You should be able to choose getting the notification before or after the event takes place. Some events would only be useful after such as a failed login but a bit of common sense would used would take care of that type of thing so web hooks don't need to be custom built but just happen and made available  with the pre/post subscription.

If the API was updated and web hooks were done this way, we would have a very powerful set of tools that are easy to work with external to Emby.  Populating an external dashboard could be done in real time knowing active user count, Number of streams being played, how many transcoded vs direct play, piece of cake.  Right now to do anything like this requires parsing the log files which isn't clean.

With the ability to access the API externally a long with a full featured webhook subscription a whole lot of cool things could be done pretty easily.  Users have been asking for a "Watch Together" functionality which is now a rather easy little programming task.  You could take a video chat board like Matters Most to use as a family get together or waiting room. Text chatting or video conferencing.  When everyone is ready they could easily watch a family movie together.  The webhooks let you know if a stream is stopped, started or paused and with the API if one of 4 was paused they all could be.  It because rather trivial to keep streams in sync and make timing adjustments externally to Emby with these tools.  You could probably pipe the video into the conference but it's a lot slicker being able to watch on your own TV while communicating or texting on a phone or table.

Emby would only need to allow one hook per function so not to burden the system.  Any admin could set a web hook proxy if they have a need to take one notification and send it out to multiple people such as failed logins especially after the second time.  Or external to Emby a login coming from an unfamiliar IP could trigger something else.

Theoretically a person could build a web hook proxy to get a notification from Emby once then turn around and use that one notification for many things or send it on.  If two people wanted to know when someone logs in and 4 people need to know when a login fails Emby could send it one time vs 4 subscriptions and the proxy could handle it.  That would limit the burden of webhook overload and sending multiple of the same type.  Having a swagger like GUI would make it a lot easier to track what's hooked and what isn't and if the ONE hook is in use of not if multiple people have admin rights.

Having the hooks available like this would allow a person to start commercial processing a file as soon as it starts recording.  Then using the hooks know when it's done recording and if anyone was playing it.  Could easily track what's being played and wait for the last person to get done with the recording which could then be replaced with the commercial cut version and moved eliminating issues with this today of not knowing if files are in use.

The combination of those two things would open Emby up to a lot more developers or scripters that have no chance at plugin development which has a much steeper learning curve.  My heads spinning with all kinds of things I could do with that combination of features.

  • Agree 1
Link to comment
Share on other sites

Quote

Problem is there is hardly any webhooks to use and by their very nature are status or event message. 

Sure, but once upon a time this plugin didn't have many events either. Webhooks and ScripterX are essentially the same, they just output in different ways. That's why I think everyone would benefit if there were only one eventing model but other alternative output mechanisms.

Link to comment
Share on other sites

Spaceboy
9 hours ago, Luke said:

Right I understand that when you're only using a single machine, webhooks are a bit more work to setup. What additional info is needed for post processing?

was already laid out for you here image.thumb.png.a642ef8e3c211dde19efc6415c3d8658.png

all we need is emby to call a program on the commencement of a recording. very simple, just an extension of what we currently have which is calling the program on the end of a recording

Link to comment
Share on other sites

maegibbons
47 minutes ago, Spaceboy said:

was already laid out for you here image.thumb.png.a642ef8e3c211dde19efc6415c3d8658.png

all we need is emby to call a program on the commencement of a recording. very simple, just an extension of what we currently have which is calling the program on the end of a recording

Exactly.

Let's not over complicate this.

If the webhooks event model could call a script instead of generating a webhook, that is indeed another way.

Link to comment
Share on other sites

6 hours ago, maegibbons said:

Exactly.

Let's not over complicate this.

If the webhooks event model could call a script instead of generating a webhook, that is indeed another way.

 

@maegibbons it should be really easy to do this generically outside of Emby if you want to do that.  But right now you get an event for Live TV but not playing, scheduling, recording, etc You would want/need to parse the web hooks before acting on them.  But you could whip up a little script or executable that would do exactly that and allow you to run scripts at will based on receiving a specific event type like Live TV and only if the Event is "InProgress".

Something simple like this is all you would need: Pass the "URL", the status to act on, the script/executable to run. IE:
webhookrun "/webhook-receive/live-tv" "InProgress" "recording-started.bat @filename@"
Then in Emby you would use http://ip:port/webhook-receive/live-tv

Something as simple as that would allow you to run your own scripts or programs and do different things based on what you receive. You could pretty much do this right in perl, php that running as a mini server and script if you wanted.

@Luke When ever something is using a file can you pass the full file path with the webhook?  For example it's impossible to determine a new recording from the event information received with the webhook.  Here's an example start of a recording from my windows test server"

C:\Users\carlo\AppData\Roaming\Emby-Server\programdata\data\livetv\recordings\Law & Order Special Victims Unit (1999)\Law & Order Special Victims Unit S05E16 Home.ts 

Here's the info received with the webhook:

{"Event":"livetv.TimerCreated","TimerInfo":{"Status":"New","RunTimeTicks":36000000000,"ProgramInfo":{"Name":"Law & Order: Special Victims Unit","ServerId":"94c62f47febe48369377cbfaead65bca","Id":"1339501","Etag":"2acad64a575e6877cad8296a88e0007f","DateCreated":"2022-04-02T15:01:02.0000000+00:00","CanDelete":false,"CanDownload":false,"PresentationUniqueKey":"EP003169780109","SortName":"Law & Order: Special Victims Unit - Home","ForcedSortName":"Law & Order: Special Victims Unit - Home","PremiereDate":"2004-02-17T05:00:00.0000000+00:00","ExternalUrls":[],"OfficialRating":"TV-14","ChannelId":"1334762","ChannelName":"WPPXDT","Overview":"Detectives interview an overprotective woman (Diane Verona) to find out why her son is scavenging for food in the garbage; the boy later is later found dead and his older brother confesses to killing him.","Taglines":[],"Genres":["Crime drama","Drama","Action","Thriller"],"RunTimeTicks":36000000000,"ProductionYear":2004,"ChannelNumber":"1061","IndexNumber":16,"ParentIndexNumber":5,"RemoteTrailers":[],"ProviderIds":{"SeriesZap2It":"EP00316978"},"ParentId":"1334762","Type":"Program","GenreItems":[{"Name":"Crime drama","Id":1335098},{"Name":"Drama","Id":11886},{"Name":"Action","Id":12071},{"Name":"Thriller","Id":11879}],"TagItems":[],"DisplayPreferencesId":"8cab5e5f60ae4830c47f6431bbe4c3cb","Status":"New","PrimaryImageAspectRatio":0.6666666666666666,"SeasonName":"Season 5","ImageTags":{"Primary":"4a56958163a12efb055e3309d495de9a"},"BackdropImageTags":[],"MediaType":"Video","EndDate":"2022-04-02T16:00:00.0000000+00:00","LockedFields":[],"LockData":false,"Width":1920,"Height":1080,"ChannelPrimaryImageTag":"6d34ce1e8f1f3f7261df3190ee3f19b7","StartDate":"2022-04-02T15:00:00.0000000+00:00","IsRepeat":true,"EpisodeTitle":"Home","IsSeries":true,"TimerId":"c40b716f11314c5b8d9562f1aa8c5d94"},"Id":"c40b716f11314c5b8d9562f1aa8c5d94","Type":"Timer","ServerId":"94c62f47febe48369377cbfaead65bca","ChannelId":"1334762","ChannelName":"WPPXDT","ChannelPrimaryImageTag":"6d34ce1e8f1f3f7261df3190ee3f19b7","ProgramId":"1339501","Name":"Law & Order: Special Victims Unit","Overview":"Detectives interview an overprotective woman (Diane Verona) to find out why her son is scavenging for food in the garbage; the boy later is later found dead and his older brother confesses to killing him.","StartDate":"2022-04-02T15:00:00.0000000Z","EndDate":"2022-04-02T16:00:00.0000000Z","Priority":0,"PrePaddingSeconds":0,"PostPaddingSeconds":0,"IsPrePaddingRequired":false,"IsPostPaddingRequired":false,"KeepUntil":"UntilDeleted"},"Server":{"Name":"MSI17","Id":"94c62f47febe48369377cbfaead65bca"}}

Just a simple check and the year of the TV show 1999 isn't present.

  • Confused 1
Link to comment
Share on other sites

maegibbons
5 minutes ago, cayars said:

 

@maegibbons it should be really easy to do this generically outside of Emby if you want to do that.  But right now you get an event for Live TV but not playing, scheduling, recording, etc You would want/need to parse the web hooks before acting on them.  But you could whip up a little script or executable that would do exactly that and allow you to run scripts at will based on receiving a specific event type like Live TV and only if the Event is "InProgress".

Something simple like this is all you would need: Pass the "URL", the status to act on, the script/executable to run. IE:
webhookrun "/webhook-receive/live-tv" "InProgress" "recording-started.bat @filename@"
Then in Emby you would use http://ip:port/webhook-receive/live-tv

Something as simple as that would allow you to run your own scripts or programs and do different things based on what you receive. You could pretty much do this right in perl, php that running as a mini server and script if you wanted.

@Luke When ever something is using a file can you pass the full file path with the webhook?  For example it's impossible to determine a new recording from the event information received with the webhook.  Here's an example start of a recording from my windows test server"

C:\Users\carlo\AppData\Roaming\Emby-Server\programdata\data\livetv\recordings\Law & Order Special Victims Unit (1999)\Law & Order Special Victims Unit S05E16 Home.ts 

Here's the info received with the webhook:

{"Event":"livetv.TimerCreated","TimerInfo":{"Status":"New","RunTimeTicks":36000000000,"ProgramInfo":{"Name":"Law & Order: Special Victims Unit","ServerId":"94c62f47febe48369377cbfaead65bca","Id":"1339501","Etag":"2acad64a575e6877cad8296a88e0007f","DateCreated":"2022-04-02T15:01:02.0000000+00:00","CanDelete":false,"CanDownload":false,"PresentationUniqueKey":"EP003169780109","SortName":"Law & Order: Special Victims Unit - Home","ForcedSortName":"Law & Order: Special Victims Unit - Home","PremiereDate":"2004-02-17T05:00:00.0000000+00:00","ExternalUrls":[],"OfficialRating":"TV-14","ChannelId":"1334762","ChannelName":"WPPXDT","Overview":"Detectives interview an overprotective woman (Diane Verona) to find out why her son is scavenging for food in the garbage; the boy later is later found dead and his older brother confesses to killing him.","Taglines":[],"Genres":["Crime drama","Drama","Action","Thriller"],"RunTimeTicks":36000000000,"ProductionYear":2004,"ChannelNumber":"1061","IndexNumber":16,"ParentIndexNumber":5,"RemoteTrailers":[],"ProviderIds":{"SeriesZap2It":"EP00316978"},"ParentId":"1334762","Type":"Program","GenreItems":[{"Name":"Crime drama","Id":1335098},{"Name":"Drama","Id":11886},{"Name":"Action","Id":12071},{"Name":"Thriller","Id":11879}],"TagItems":[],"DisplayPreferencesId":"8cab5e5f60ae4830c47f6431bbe4c3cb","Status":"New","PrimaryImageAspectRatio":0.6666666666666666,"SeasonName":"Season 5","ImageTags":{"Primary":"4a56958163a12efb055e3309d495de9a"},"BackdropImageTags":[],"MediaType":"Video","EndDate":"2022-04-02T16:00:00.0000000+00:00","LockedFields":[],"LockData":false,"Width":1920,"Height":1080,"ChannelPrimaryImageTag":"6d34ce1e8f1f3f7261df3190ee3f19b7","StartDate":"2022-04-02T15:00:00.0000000+00:00","IsRepeat":true,"EpisodeTitle":"Home","IsSeries":true,"TimerId":"c40b716f11314c5b8d9562f1aa8c5d94"},"Id":"c40b716f11314c5b8d9562f1aa8c5d94","Type":"Timer","ServerId":"94c62f47febe48369377cbfaead65bca","ChannelId":"1334762","ChannelName":"WPPXDT","ChannelPrimaryImageTag":"6d34ce1e8f1f3f7261df3190ee3f19b7","ProgramId":"1339501","Name":"Law & Order: Special Victims Unit","Overview":"Detectives interview an overprotective woman (Diane Verona) to find out why her son is scavenging for food in the garbage; the boy later is later found dead and his older brother confesses to killing him.","StartDate":"2022-04-02T15:00:00.0000000Z","EndDate":"2022-04-02T16:00:00.0000000Z","Priority":0,"PrePaddingSeconds":0,"PostPaddingSeconds":0,"IsPrePaddingRequired":false,"IsPostPaddingRequired":false,"KeepUntil":"UntilDeleted"},"Server":{"Name":"MSI17","Id":"94c62f47febe48369377cbfaead65bca"}}

Just a simple check and the year of the TV show 1999 isn't present.

You are still over complicating this way to much.  At the moment we have a post recording processing script call built in.  All I am asking for is another one added for calling at the start of the recording.

I really do not want to get in to shims to process webhooks locally.  Yes I know it can be done but that does not mean its the best way.

Link to comment
Share on other sites

Luke has already provided for this event.  It's the second from the bottom.

image.png.6d811f5bbd2f2220ac669b03939ba5de.png 

Link to comment
Share on other sites

maegibbons
1 hour ago, cayars said:

Luke has already provided for this event.  It's the second from the bottom.

image.png.6d811f5bbd2f2220ac669b03939ba5de.png 

Yes in webhooks.  I am talking vanilla script calling as per "post recording" script just for recording start.

Link to comment
Share on other sites

Spaceboy
2 hours ago, cayars said:

Luke has already provided for this event.  It's the second from the bottom.

image.png.6d811f5bbd2f2220ac669b03939ba5de.png 

not what was asked for though, is it? we just want a simple way of calling a local program on the start of a recording. no faffing about with the user writing an additional script or executable. the comskipper plugin needs this support especially as scripterx has been broken

Link to comment
Share on other sites

maegibbons
15 minutes ago, Luke said:

I'll add some additional post processing command line arguments. Thanks.

It's not just command line arguments!

It's the option to run an entirely seperate script/program at the START of a recording.

Link to comment
Share on other sites

CJTripper

Do we know what changed between the 4.7.0.30 beta and 4.7.0.31 beta that broke ScripterX? And was that change necessary? This is what was posted in the 4.7.0.31 beta release change log:

Fix various transcoding regressions with hardware transcoding and subtitles

Safeguard against junk year values when probing audio files

Save writers as composers when probing audio files

Windows: restart scheduled task and dvr times when system time changes (daylight savings)

Fix incorrect photo orientation in slideshows

Was there something there that could be rolled back or done in another way to keep ScripterX working?

If I recall correctly, my ScripterX was still working for "onPlaybackStart" but not for "onLiveTVRecordingStart" after the 4.7.0.31 beta upgrade. (I was calling bash scripts and passing parameters to them, on an Asustor NAS).

Also, did anyone try an uninstall and reinstall/recreate actions of ScripterX after the 4.7.0.31 beta upgrade? I never thought of trying that until after I had rolled my NAS back to 4.7.0.30 Beta, I assume someone here has tried that and can confirm? Update: I seen @maegibbons already tested the ScripterX uninstall/reinstall, can you confirm you also deleted and recreated your actions when you reinstalled? BTW, everything in ScripterX started working again after rolling back to 4.7.0.30, without making any changes or removing/reinstalling ScripterX or actions.

Edited by CJTripper
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...