Jump to content

New Plugin - Custom Scripting | Emby ScripterX


Anthony Musgrove

Recommended Posts

clost
On 1/3/2024 at 11:25 AM, Anthony Musgrove said:

attempting to replicate now, please stand by :) 

I meet the same problem

Link to comment
Share on other sites

Anthony Musgrove

Almost done :) Just processing through issues with transitioning over to I guess some new framework changes on the Emby dev's side.  All good almost finished :) 

 

image.thumb.png.4030f9239127c433d31c1c39cc82cd84.png

 

image.png.5d24b65ba27ff66a0c318a61c2a3df7c.png

 

 

Link to comment
Share on other sites

Anthony Musgrove

Issue Resolved - v5.0.0.2 now in Catalog - PLEASE UPDATE!

image.thumb.png.24778a877d5aba2059b91e1d8e985df8.png

 

        5.0.0.2 Changelog

  • Rectified various javascript issues with new framework for Emby Beta 4.8.0.67+
  • Temporarily removed 'Packages' tab (this entire section needs revamping/re-evaluating)

 

 

  • Like 3
Link to comment
Share on other sites

joekingcool

im running the beta version of emby. i got the interface to show now after your update :) but still tring to figure out what i can do with this and how. i seen youtube on the playback . i thought this was a way to send cmd to emby but it seems like its for creating special logs?  im sorry its bit overwhelming to get started... ive been recently making apps to work with emby lately and would like a better way to interface with emby via cmd line. hopefully this makes sense :)

 

Link to comment
Share on other sites

Anthony Musgrove
33 minutes ago, joekingcool said:

im running the beta version of emby. i got the interface to show now after your update :) but still tring to figure out what i can do with this and how. i seen youtube on the playback . i thought this was a way to send cmd to emby but it seems like its for creating special logs?  im sorry its bit overwhelming to get started... ive been recently making apps to work with emby lately and would like a better way to interface with emby via cmd line. hopefully this makes sense :)

 

G'day Joe, 

thank you for your reply, so Emby Scripter-X provides methods to run/execute scripts/functions/commands based on various events that occur within the Emby Core.  It also provides the ability to develop custom packages that can extend/add functionality to the Emby API which would allow you to call URLs (with authentication), so that would be a way to access more via the command line.

 

My question firstly though would be - what are you trying to achieve via commandline?  What is it that you need to get emby to do/provide via commandline?

 

Cheers,

Anthony

Link to comment
Share on other sites

joekingcool

lately i have mostly been working on livetv related stuff. i made an app that monitors the logs and finds seek to start failed errors, then it stops emby and edits the json file for that recording to in progress and starts back up. its one error that happens with live streams during recordings that emby doesn't recover from. it would of been nice if i could of told emby to change status of that recording. but not really sure what cmds are available. also i use curl to shutdown emby properly. 

another one was setting recordings by season. i got this to work to. but it records all episodes of that season wither its in the library or not. so it would be nice if it determined what was already recorded. 

im still a bit of noob to programming, mostly comfortable with ahk scripts on windows. but would like to know how people make plugins for emby and how to make api calls to make emby do things from cmd line i guess. 

Link to comment
Share on other sites

clost
On 3/31/2023 at 11:22 AM, dmdyxx said:

Error logs when using the Scripter X plug-in

The same error occurred in both the docker version and the official native installation package testing    And has also been tried in version 4.7, with the same error

@dmdyxx

2023-03-31 14:37:43.421 Error App: Error in ItemRemoved event handler
	*** Error Report ***
	Version: 4.8.0.27
	Command line: /system/EmbyServer.dll -programdata /config -ffdetect /bin/ffdetect -ffmpeg /bin/ffmpeg -ffprobe /bin/ffprobe -restartexitcode 3
	Operating system: Linux version 5.10.60-qnap (root@U16BuildServer118) (x86_64-QNAP-linux-gnu-gcc (toolchain config: [gcc-4.9.2 binutils-2.25 glibc-2.21]) 4.9.2, GNU ld
	Framework: .NET 6.0.13
	OS/Process: x64/x64
	Runtime: system/System.Private.CoreLib.dll
	Processor count: 2
	Data path: /config
	Application path: /system
	System.IO.FileNotFoundException: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
	
	File name: 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
	   at EmbyScripterX.Core.ScripterXEventContext.getTemplate_substituteTokens(String template_contents, Boolean jsonSafe)
	   at EmbyScripterX.Core.ScripterXEventContext.ProcessWeb(String method)
	   at EmbyScripterX.Core.ScripterXEventContext.Process(EmbyScripterXAction withAction)
	   at EmbyScripterX.EventManagers.ScripterXLibraryManager._libraryManager_ItemRemoved(Object sender, ItemChangeEventArgs e)
	   at Emby.Server.Implementations.Library.LibraryManager.ReportItemRemoved(BaseItem item, BaseItem parent)
	Source: EmbyScripterX
	TargetSite: System.String getTemplate_substituteTokens(System.String, Boolean)

 

The following is the program configuration

 

I want to know what this error means or what the solution is. thank you

 

 

 

1H`3$}VTHT(%PJZM5)UBR%O.png

_OZ5L%NUGW}HP{$EQXJA06G.png

I meet the same problem, did you fix it?

Link to comment
Share on other sites

Anthony Musgrove
31 minutes ago, clost said:

I meet the same problem, did you fix it?

 

Hi @clost,

Out of curiosity, can you please try placing this dll file into the emby system directory?  (on Windows for example it is located at C:\Users\<username>\AppData\Roaming\Emby-Server\system, linux ubuntu/debian /opt/emby-server/system).

 

I just want to determine why the embedded assembly isn't being referenced properly on your platform.  These libraries are usually embedded into the scripterx dll, however for some reason your system/platform/implementation is choosing to ignore the embedded version).  if you can help me get to the top of this I would much appreciate it, as I can then future proof the issue from occuring within these specific implementations. 

 

Cheers mate,

Anthony

Newtonsoft.Json.dll

Link to comment
Share on other sites

Anthony Musgrove
49 minutes ago, joekingcool said:

lately i have mostly been working on livetv related stuff. i made an app that monitors the logs and finds seek to start failed errors, then it stops emby and edits the json file for that recording to in progress and starts back up. its one error that happens with live streams during recordings that emby doesn't recover from. it would of been nice if i could of told emby to change status of that recording. but not really sure what cmds are available. also i use curl to shutdown emby properly. 

another one was setting recordings by season. i got this to work to. but it records all episodes of that season wither its in the library or not. so it would be nice if it determined what was already recorded. 

im still a bit of noob to programming, mostly comfortable with ahk scripts on windows. but would like to know how people make plugins for emby and how to make api calls to make emby do things from cmd line i guess. 

Thanks Joe,

The following events can be handled within ScripterX with regard to live TV:

 image.png.e99b54d4c44412c91c9d83205d2a0776.png

 

Could you please provide a snippet of the log where these errors occur, I'll see if I can find where ScripterX can identify these, such that it can call a script for you when it occurs (as live).  All this can be achieved within Emby Scripter-X :)

Link to comment
Share on other sites

clost
2 hours ago, Anthony Musgrove said:

 

Hi @clost,

Out of curiosity, can you please try placing this dll file into the emby system directory?  (on Windows for example it is located at C:\Users\<username>\AppData\Roaming\Emby-Server\system, linux ubuntu/debian /opt/emby-server/system).

 

I just want to determine why the embedded assembly isn't being referenced properly on your platform.  These libraries are usually embedded into the scripterx dll, however for some reason your system/platform/implementation is choosing to ignore the embedded version).  if you can help me get to the top of this I would much appreciate it, as I can then future proof the issue from occuring within these specific implementations. 

 

Cheers mate,

Anthony

Newtonsoft.Json.dll 457.5 kB · 1 download

2024-01-11 23:58:06.728 Error SessionManager: Error in event handler
*** Error Report ***
Version: 4.8.0.66
Command line: /opt/emby-server/system/EmbyServer.dll -programdata /var/lib/emby -ffdetect /opt/emby-server/bin/ffdetect -ffmpeg /opt/emby-server/bin/ffmpeg -ffprobe /opt/emby-server/bin/ffprobe -restartexitcode 3 -updatepackage emby-server-deb_{version}_amd64.deb
Operating system: Linux version 5.10.0-0.deb10.16-amd64 (debian-kernel@lists.debian.org) (gcc-8 (Debian 8.3.0-6) 8.3.0, GNU ld (GNU Binutils for Debian) 2.31.1) #1 SMP
Framework: .NET 6.0.20
OS/Process: x64/x64
Runtime: opt/emby-server/system/System.Private.CoreLib.dll
Processor count: 4
Data path: /var/lib/emby
Application path: /opt/emby-server/system
System.IO.FileNotFoundException: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at EmbyScripterX.Core.ScripterXEventContext.getTemplate_substituteTokens(String template_contents, Boolean jsonSafe)
at EmbyScripterX.Core.ScripterXEventContext.ProcessWeb(String method)
at EmbyScripterX.Core.ScripterXEventContext.Process(EmbyScripterXAction withAction)
at EmbyScripterX.EventManagers.ScripterXSessionManager._sessionManager_PlaybackStart(Object sender, PlaybackProgressEventArgs e)
at MediaBrowser.Common.Events.EventHelper.TriggerAll[T](EventHandler`1 mainHandler, Object sender, T args, ILogger logger)
Source: EmbyScripterX
TargetSite: System.String getTemplate_substituteTokens(System.String, Boolean)

Second time, I install your dll and systemctl restart emby-server but still not working

*** Error Report ***
Version: 4.8.0.66
Command line: /opt/emby-server/system/EmbyServer.dll -programdata /var/lib/emby -ffdetect /opt/emby-server/bin/ffdetect -ffmpeg /opt/emby-server/bin/ffmpeg -ffprobe /opt/emby-server/bin/ffprobe -restartexitcode 3 -updatepackage emby-server-deb_{version}_amd64.deb
Operating system: Linux version 5.10.0-0.deb10.16-amd64 (debian-kernel@lists.debian.org) (gcc-8 (Debian 8.3.0-6) 8.3.0, GNU ld (GNU Binutils for Debian) 2.31.1) #1 SMP
Framework: .NET 6.0.20
OS/Process: x64/x64
Runtime: opt/emby-server/system/System.Private.CoreLib.dll
Processor count: 4
Data path: /var/lib/emby
Application path: /opt/emby-server/system
System.IO.FileNotFoundException: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at EmbyScripterX.Core.ScripterXEventContext.getTemplate_substituteTokens(String template_contents, Boolean jsonSafe)
at EmbyScripterX.Core.ScripterXEventContext.ProcessWeb(String method)
at EmbyScripterX.Core.ScripterXEventContext.Process(EmbyScripterXAction withAction)
at EmbyScripterX.EventManagers.ScripterXSessionManager._sessionManager_PlaybackStart(Object sender, PlaybackProgressEventArgs e)
at MediaBrowser.Common.Events.EventHelper.TriggerAll[T](EventHandler`1 mainHandler, Object sender, T args, ILogger logger)
Source: EmbyScripterX
TargetSite: System.String getTemplate_substituteTokens(System.String, Boolean)

 

Edited by clost
Link to comment
Share on other sites

joekingcool
4 hours ago, Anthony Musgrove said:

Could you please provide a snippet of the log where these errors occur, I'll see if I can find where ScripterX can identify these, such that it can call a script for you when it occurs (as live).  All this can be achieved within Emby Scripter-X :)

i attached the logs and did a test example by blocking ffmpeg briefly. it gives seek to start failed error then ffmpeg closes it, then emby changes the status in the timers.json from in progress to complete.

also if there was a way to send a cmd from windows to emby to run guide update that would be nice.

or shutdown or restart, but for these 2 i use curl currently. 

hardware_detection-63840573339.txtembyserver.txtrecording-conversion-1da9883a-3714-4a98-9c83-12106631de09_1.txtemby-scripterx.txt

Link to comment
Share on other sites

Anthony Musgrove
On 12/01/2024 at 03:06, clost said:
2024-01-11 23:58:06.728 Error SessionManager: Error in event handler
*** Error Report ***
Version: 4.8.0.66
Command line: /opt/emby-server/system/EmbyServer.dll -programdata /var/lib/emby -ffdetect /opt/emby-server/bin/ffdetect -ffmpeg /opt/emby-server/bin/ffmpeg -ffprobe /opt/emby-server/bin/ffprobe -restartexitcode 3 -updatepackage emby-server-deb_{version}_amd64.deb
Operating system: Linux version 5.10.0-0.deb10.16-amd64 (debian-kernel@lists.debian.org) (gcc-8 (Debian 8.3.0-6) 8.3.0, GNU ld (GNU Binutils for Debian) 2.31.1) #1 SMP
Framework: .NET 6.0.20
OS/Process: x64/x64
Runtime: opt/emby-server/system/System.Private.CoreLib.dll
Processor count: 4
Data path: /var/lib/emby
Application path: /opt/emby-server/system
System.IO.FileNotFoundException: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at EmbyScripterX.Core.ScripterXEventContext.getTemplate_substituteTokens(String template_contents, Boolean jsonSafe)
at EmbyScripterX.Core.ScripterXEventContext.ProcessWeb(String method)
at EmbyScripterX.Core.ScripterXEventContext.Process(EmbyScripterXAction withAction)
at EmbyScripterX.EventManagers.ScripterXSessionManager._sessionManager_PlaybackStart(Object sender, PlaybackProgressEventArgs e)
at MediaBrowser.Common.Events.EventHelper.TriggerAll[T](EventHandler`1 mainHandler, Object sender, T args, ILogger logger)
Source: EmbyScripterX
TargetSite: System.String getTemplate_substituteTokens(System.String, Boolean)

Second time, I install your dll and systemctl restart emby-server but still not working

*** Error Report ***
Version: 4.8.0.66
Command line: /opt/emby-server/system/EmbyServer.dll -programdata /var/lib/emby -ffdetect /opt/emby-server/bin/ffdetect -ffmpeg /opt/emby-server/bin/ffmpeg -ffprobe /opt/emby-server/bin/ffprobe -restartexitcode 3 -updatepackage emby-server-deb_{version}_amd64.deb
Operating system: Linux version 5.10.0-0.deb10.16-amd64 (debian-kernel@lists.debian.org) (gcc-8 (Debian 8.3.0-6) 8.3.0, GNU ld (GNU Binutils for Debian) 2.31.1) #1 SMP
Framework: .NET 6.0.20
OS/Process: x64/x64
Runtime: opt/emby-server/system/System.Private.CoreLib.dll
Processor count: 4
Data path: /var/lib/emby
Application path: /opt/emby-server/system
System.IO.FileNotFoundException: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at EmbyScripterX.Core.ScripterXEventContext.getTemplate_substituteTokens(String template_contents, Boolean jsonSafe)
at EmbyScripterX.Core.ScripterXEventContext.ProcessWeb(String method)
at EmbyScripterX.Core.ScripterXEventContext.Process(EmbyScripterXAction withAction)
at EmbyScripterX.EventManagers.ScripterXSessionManager._sessionManager_PlaybackStart(Object sender, PlaybackProgressEventArgs e)
at MediaBrowser.Common.Events.EventHelper.TriggerAll[T](EventHandler`1 mainHandler, Object sender, T args, ILogger logger)
Source: EmbyScripterX
TargetSite: System.String getTemplate_substituteTokens(System.String, Boolean)

 

Thank you for getting back to me on this one @clost--- I need to try to replicate your environment so that I can take a more indepth look.  Is this running within docker or something?  It looks like, for some reason, your ScripterX dll is trying to load the wrong assembly version of Newtonsoft.Json (v13.0.0.0), where as ScripterX is compiled against v9.x and should only ever look for that version.

Link to comment
Share on other sites

clost
9 hours ago, Anthony Musgrove said:

Thank you for getting back to me on this one @clost--- I need to try to replicate your environment so that I can take a more indepth look.  Is this running within docker or something?  It looks like, for some reason, your ScripterX dll is trying to load the wrong assembly version of Newtonsoft.Json (v13.0.0.0), where as ScripterX is compiled against v9.x and should only ever look for that version.

Debian 10, and I installed this called emby-server-deb_4.8.0.67_amd64.deb

Link to comment
Share on other sites

Anthony Musgrove
6 hours ago, clost said:

Debian 10, and I installed this called emby-server-deb_4.8.0.67_amd64.deb

Thank you, I'm now downloading debian-10.13.0-amd64-DVD-1.iso and will spin up a virtual machine and test the scenario.  

Link to comment
Share on other sites

Anthony Musgrove
10 hours ago, clost said:

Debian 10, and I installed this called emby-server-deb_4.8.0.67_amd64.deb

Can you please confirm for me which version of Emby Scripter-X you have installed from the catalog?  You should be able to see the version number underneath the ScripterX image, in the Catalog.  Cheers!

Link to comment
Share on other sites

clost
13 hours ago, Anthony Musgrove said:

Can you please confirm for me which version of Emby Scripter-X you have installed from the catalog?  You should be able to see the version number underneath the ScripterX image, in the Catalog.  Cheers!

5.0.0.2

Link to comment
Share on other sites

Anthony Musgrove
1 hour ago, clost said:

5.0.0.2

Thank you again @clostfor your reply.  After replicating this environment, Debian 10, ScripterX 5.0.0.2 with Emby Beta server, all is working very well.


I'm not quite sure why your environment is looking for the wrong assembly version of Newtonsoft.Json - if you'd like I could take a look at it for you.  But that is entirely up to you.

 

Kindest regards,

Anthony

Link to comment
Share on other sites

Stan Guiseppe

Hi Anthony, fantastic plugin!!

I have used it to send a GET request to turn lights off/on when movie started/stopped, and it works wonderfully.

Is there an Emby action for when playback is paused/resumed?

Is there a way that I can manually create a script for these actions?

If so, is there a way to access the stored scripts that I have created with the GUI so I could copy them and tweak them for the pause/resume, then add as ZIP package?

 

Thanks heaps

Link to comment
Share on other sites

Anthony Musgrove
51 minutes ago, Stan Guiseppe said:

Hi Anthony, fantastic plugin!!

I have used it to send a GET request to turn lights off/on when movie started/stopped, and it works wonderfully.

Is there an Emby action for when playback is paused/resumed?

Is there a way that I can manually create a script for these actions?

If so, is there a way to access the stored scripts that I have created with the GUI so I could copy them and tweak them for the pause/resume, then add as ZIP package?

 

Thanks heaps

Hey @Stan Guiseppe, thank you heaps for the awesome feedback! :)

 

I've just added Pause and Unpause into the next version, which I am about to release on the Emby catalog, v5.0.0.3.  

 

You'll notice %playback.event.name% which will equal Pause, Unpause, TimeEvent.  

With regard to packages, this will be available again shortly, I'm just revamping the packages implementation to ensure it is all secure and clean.

 

image.thumb.png.92bb67f7b01d1ccbc3c3b2da24c1357a.png

Link to comment
Share on other sites

Anthony Musgrove
3 minutes ago, Anthony Musgrove said:

Hey @Stan Guiseppe, thank you heaps for the awesome feedback! :)

 

I've just added Pause and Unpause into the next version, which I am about to release on the Emby catalog, v5.0.0.3.  

 

You'll notice %playback.event.name% which will equal Pause, Unpause, TimeEvent.  

With regard to packages, this will be available again shortly, I'm just revamping the packages implementation to ensure it is all secure and clean.

 

image.thumb.png.92bb67f7b01d1ccbc3c3b2da24c1357a.png

Sorry, not 'Paused' as in the image, its 'Pause'

Link to comment
Share on other sites

Stan Guiseppe

Great stuff, you're a legend. Thanks v much.

I'll be looking out for the next update!

  • Like 1
Link to comment
Share on other sites

Stan Guiseppe

Hey Anthony, looks like my Scripter X has auto updated, but no longer appears in Emby server settings, and no longer works. I tried installing again from the plugins page, but the same result, doesn't appear as a current plug in in Emby, and doesn't work anymore... this is for version 5.0.0.3.

Edited by Stan Guiseppe
Link to comment
Share on other sites

Anthony Musgrove
2 hours ago, Stan Guiseppe said:

Hey Anthony, looks like my Scripter X has auto updated, but no longer appears in Emby server settings, and no longer works. I tried installing again from the plugins page, but the same result, doesn't appear as a current plug in in Emby, and doesn't work anymore... this is for version 5.0.0.3.

Hey Stan, 

Are you using Emby Server Beta?  if you're not using the Beta channel of Server, the newer versions of ScripterX won't work.  Just want to make sure before I check it out :)

Link to comment
Share on other sites

kreris

we have the last stable version of emby (4.7.14.0), until now we are using the scripterX plugin with version 4.0.0.8 beta, without problems. But now with the last release version, the plugin auto updates, and stops working. If we install the previous version, autoupdates again. There any option for install the previuos version and avoid the autoupdate, or any other option for use the plugin with the stable version of emby

Edited by kreris
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...