Code Monkey home page Code Monkey logo

emby-scripterx's People

Contributors

anthonymusgrove avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emby-scripterx's Issues

Unexpected end of input error

Describe the bug
After every event handler function call, I see the following error in the emby log:

2020-06-21 06:47:02.068 Error Emby ScripterX: Error invoking function '_onPlaybackStopped' on package with installationId '679b7e32-79be-4330-b8c7-6dfdf992f740' failed: Jint.Parser.ParserException: Line 0: Unexpected end of input
at Jint.Runtime.Interop.MethodInfoFunctionInstance.Invoke(MethodInfo[] methodInfos, JsValue thisObject, JsValue[] jsArguments)
at Jint.Runtime.ExpressionInterpreter.EvaluateCallExpression(CallExpression callExpression)
at Jint.Runtime.StatementInterpreter.ExecuteExpressionStatement(ExpressionStatement expressionStatement)
at Jint.Engine.ExecuteStatement(Statement statement)
at Jint.Runtime.StatementInterpreter.ExecuteStatementList(IEnumerable`1 statementList)
at Jint.Engine.ExecuteStatement(Statement statement)
at Jint.Native.Function.ScriptFunctionInstance.Call(JsValue thisArg, JsValue[] arguments)
at EmbyScripterX.Packages.Package.invokeFunction(String function, Object[] param_objects)

All of my event handlers are single line functions calling JsonPost(). My webhooks are called, but I do see this error logged after every invocation of my functions.

To Reproduce
Steps to reproduce the behavior:

  1. Install a package with event handlers
  2. Trigger any of the events
  3. See error in emby log

Expected behavior
No error or if this isn't an error/can be ignored then probably suppress it or log it at debug/trace.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Adding an AA with more than one album or a large number of songs

Describe the bug
See this post for details
https://emby.media/community/index.php?/topic/84816-new-plugin-custom-scripting-emby-scripterx/?p=884576

To Reproduce
Steps to reproduce the behavior:
e.g. Add the folder for the AA and its associated album folders in one go

One event for AA Folder - correct

13 events for MusicAlbum - incorrect - only 8 albums added - so 5 duplicate events

167 events for Songs - incorrect - only 105 songs added - so 62 duplicate events

so a total of 181 events instead of 114

Expected behavior
correct number of events by item type

Episodes - Virtual and Missing

Is your feature request related to a problem? Please describe.
Emby has a concept of Virtual and Missing episodes - can these be filtered out of events

Describe the solution you'd like
Future episodes are of type virtual - they only appear on the upcoming tab of a tv library
Missing episodes - if the feature is enabled - are any that the library does not have per series

Additional context
The issue comes that when say adding a new series to a tv library (possibly Mixed content as well) additional itemadded/itemrenoved etc etc events are created for these types of episode

Emby does not clean these types of episodes up till after a library scan / and the virtual episode has passed into history

So adding a new episode to any series can kick emby into creating "unwanted" events.

An alternative would be to have say a variable item.episode.type of real, virtual or missing - so they could be filtered that way

audio transcode etc parameters not in 2.3.7/8

%transcoding.height%,%transcoding.audio.channels%,%transcoding.audio.codec%,%transcoding.bitrate%,%transcoding.container%,%transcoding.framerate%,%transcoding.reasons%

are not available in onplaybackprogress

Subtitles Events

Is your feature request related to a problem? Please describe.

When adding/removing an external subtitles file - no event is fired for itemadded/itemremoved - this maybe an emby thing not sure
itemupdated does fire for both removal and addition - but the reason "None, MetadataImport" is not meaningful - but again an emby thing i suspect
So i guess what i am asking is - does emby report on subs being added/removed or not?

Incorrect context values for _onAuthenticationFailed

Describe the bug
In the context for this event, the %user.id% token is always set to 0, even for user ids that exist.

To Reproduce
Steps to reproduce the behavior:

  1. Install package with _onAuthenticationFailed handler
  2. Trigger the handler
  3. View the received context

Expected behavior
The %user.id% token is set based on the username received.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Allow actions to run executables on Linux

Is your feature request related to a problem? Please describe.
When defining an action, I must include an interpreter. What if I want to run an executable? I'd rather not have to wrap executables around a bash script.

Describe the solution you'd like
Allow actions to run executables

Describe alternatives you've considered
Wrapping exe calls in a bash script, but just seems like an unnecessary extra layer

Additional context
If I have some exe that I want to run, I should be able to (i.e. if the execute bit is set, let me just run it). Additionally, I could just set the exe bit on a shell script and not have to invoke it thru an interpreter. This way I don't have to modify my actions if I do change the interpreter of an action script (an example might be a python2 script ported to python3, now I have to remember to update the action definition after I port the script). Yes, this would be rare, but definitely would be nice. I could see myself writing some C code, for example, and I really don't want to have to wrap that in shell script in order to invoke it in an action.

Details on JavaScript env for Packages

Is your feature request related to a problem? Please describe.
Looking for details on the JavaScript engine/env available for Packages. Safe to assume it's Node.js under the hood? What access to the system do we have? Does our js run with the same access rights as the Emby server process? For example, if I wanted to go querying the user's file system, can I do that? Can I spawn other processes? Or are we running in some kind of restricted sandbox? If so, what are the restrictions?

I see there's a ScripterX namespace with an http client, for example. Is this for convenience or are we prohibited from doing our own http calls use node.js (again, assuming it's node.js under the hood)?

What about access to the Emby api from within this javascript env? Or are we just to make raw http calls? Would be nice if we could access the api thru this ScripterX object.

Describe the solution you'd like

  • More formal api docs for this ScripterX object in the js env.
  • More details about the js env itself
  • Access to the emby api from this js env

Describe alternatives you've considered
n/a

Additional context
As you might guess, I'm in the early stages of a project of my own and integrating with ScripterX seems like it's going to save me a lot of work, especially this Packages idea. Just trying to get as much info about this env before I decide to go with developing a Package vs. just installing a series of actions for the various events.

Add Confirmation Button for deleting an Action

Is your feature request related to a problem? Please describe.

Could we have a comfirmation dialog for when you hit the delete button on an event
To prevent the ******* issue i just had when i clicked it by mistake

How to run sqlite commands

Can this plugin run these commands to optimize the sqllite db?

/var/packages/EmbyServer/target/sqlite/bin/sqlite3 library.db "VACUUM"
/var/packages/EmbyServer/target/sqlite/bin/sqlite3 library.db "ANALYZE"
/var/packages/EmbyServer/target/sqlite/bin/sqlite3 library.db "REINDEX"

Runtime errors in package js only logged if debug logging is enabled

Describe the bug
When an event handler fails, the error is only logged at the debug level. Errors are properly caught, but they should be logged at the error level so they are always present without the need for debug logging being turned on. I had a subtle syntax error in some js I was testing with and couldn't figure out why I wasn't seeing anything happening. Once I enabled debug logging, ScripterX printed out an error that lead me to my problem.

I don't know if JInt provides full stacktraces itself, but if it does, it would be great to log that along with the exception error message.

To Reproduce
Steps to reproduce the behavior:

  1. Install a package
  2. Include a runtime error in the js code for your package
  3. Trigger the event handler to run
  4. Nothing in the log file unless you enable debug logging

Expected behavior
When an error is caught, log it at error level instead of debug level so errors are always present in the log file to help with troubleshooting.

Screenshots
n/a

Desktop (please complete the following information):
n/a

Smartphone (please complete the following information):
n/a

'Test' button for an Action

Is your feature request related to a problem? Please describe.
It is easy to make a typo or incorrect formatting at times, and usually doesn't get picked up until an Event has fired, which could take time depending on what that event is.

Describe the solution you'd like
A simple 'Test' button for an Action that will fire the Event with dummy data so that you can check that your script received the correct data, and the script does what it is designed to do

New Event - New recording created

When you add a new recording (manually) to LiveTV and/or a new recording is added to a (an Existing) Series recording - i guess after the EPG is updated.

Describe the solution you'd like
A new event, time/date for when the start end of the recording will occur, Name, Series, Season, Episode, name of recording, channel number, Library name etc

Describe alternatives you've considered
Reading the recording events periodically via the API - and reporting on them - clunky but works

Variables are Case Sensitive

Describe the bug
%item.name% works but %item.Name% does not - returns %item.Name%

Expected behavior
If the variables need to be case sensitive then needs to be in the user notes.
or
the variables could be case insensitive?

Additional context
Tested on v2.2.6 (windows) but been this way since the initial versions.

it's not a big issue just catches you out occasionally.
The Test button will help with this :)

Token for ID %recording.tuner.friendlyname% does not exist

Describe the bug
I have an action for OnRecordingTimerCreated. In the where clause, I reference %recording.tuner.friendlyname% but it no longer works.

To Reproduce
Steps to reproduce the behavior:

  1. Create some sort of OnRecordingTimerCreated action.
  2. In the where clause, use %recording.tuner.friendlyname%
  3. You will see in the Emby log an error

Expected behavior
It should check the condition

Desktop (please complete the following information):

  • Ubuntu 20.04.1
  • Browser Chrome
  • Version 84.0.4147.105

Additional context

Application directory: /opt/emby-server/system
System.Exception: System.Exception: Token for ID %recording.tuner.friendlyname% does not exist.
at EmbyScripterX.Core.ScripterXEventContext.getTokenbyId(String token_id)
at EmbyScripterX.Core.ScripterXEventContext.checkConditions()
at EmbyScripterX.Core.ScripterXEventContext.Process(EmbyScripterXAction withAction)
at EmbyScripterX.ScripterXDVRMonitor._embyTv_TimerCreated(Object sender, GenericEventArgs`1 e)
at Emby.LiveTV.EmbyTV.CreateTimer(TimerInfo timer, CancellationToken cancellationToken)
at Emby.LiveTV.LiveTvManager.CreateTimer(TimerInfoDto timer, CancellationToken cancellationToken)
at Emby.Server.Implementations.Services.ServiceController.GetTaskResult(Task task)
at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(HttpListenerHost appHost, IRequest httpReq, IResponse httpRes, RestPath restPath, String responseContentType, CancellationToken cancellationToken)
at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(IRequest httpReq, ReadOnlyMemory`1 urlString, ReadOnlyMemory`1 localPath, CancellationToken cancellationToken)
Source: EmbyScripterX
TargetSite: EmbyScripterX.Core.TokenVariable getTokenbyId(System.String)

Add ability to list installed packages

Is your feature request related to a problem? Please describe.
I can upload a package via the emby api, but I can't list all installed packages. I would need to do this to determine if my package is installed before trying to upload it.

Describe the solution you'd like
You have POST /ScripterX/Packages/Upload api call. We'd need a GET /ScripterX/Packages and maybe a GET /ScripterX/Packages/{PackageIdFromPackageInfo.json} to search for details about a specific package by id.

The basic idea here is my standalone app will include a package for ScripterX, I'd like to automate the installation/upgrade of that package everytime my app is started.

Describe alternatives you've considered
The alternative is to always upload the package zip on startup. What happens if a package is uploaded that already exists?

Provide package js access to full token object

Is your feature request related to a problem? Please describe.
In my package event handler, I'll be doing a lot of posting to web hooks in my app. It would be ideal if I could just ask the context for an object of all of the tokens for the event instead of manually building an object for posting. Something like:

function onScheduledTask(ctx) {
   ScripterX.Log.Info('Starting scheduled task');
   var eventDetails = ctx.TokenObject; // this returns an object containing all available tokens for the current event
   ScripterX.Web.Post('http://192.168.1.2/event', JSON.stringify(eventDetails));
   ScripterX.Log.Info('Finished scheduled task');
}

This way, if/when event tokens change, I don't have to deal with it.

Describe alternatives you've considered
The alternative is I build the object myself, which is difficult because I don't appear to have access to a list of keys available and prone to errors/becoming obsolete if/when an event's tokens change.

Additional system capabilities

Is your feature request related to a problem? Please describe.
Some of my integration plans require access to the emby server. Specifically, I need access to two things:

  1. Access to the Emby server's file system information (via say System.IO.DriveInfo)
  2. Access to run processes on the system (via say System.Diagnostics.Process)

Describe the solution you'd like
Need access to more of the .Net runtime from package js code

Describe alternatives you've considered
n/a

Additional context
I'd be happy with just adding the above to the ScripterX namespace, but thinking long term, if there was a way I could just request inclusion of any of the .net packages I needed, that would be ideal. Of course, I'm not considering security implications of such a thing, I'll leave that that to you. ;) But if I could just do a

var Process = ScripterX.DotNetCore.Import('System.Diagnositics.Process');
// Use Process as I see fit

That would save me from adding these kinds of feature requests anytime I need another piece of the .net core made available to my js. Of course the security implications of providing such access would have to be considered carefully.

On the other hand, I also love the idea of you providing a ScripterX.Process.execute(exe) that returns let's say a ProcessResult with exit code, stdout, stderr, etc. all managed and dealt with by ScripterX. A more secure/controlled environment for sure.

I'm open to either sol'n, but would like access to be able to launch processes and query the emby server file system one way or the other. Personally, the ScripterX.Process.execute() sol'n is easier for me, but probably a lot more work for you. :) But also probably more secure.

ScripterX now supports two additional context libraries;

Please check out the wiki for more information;

ScripterX.Api.Register, ScripterX.Api.Unregister, ScripterX.Include.Script

Packages

  • Introduced API extensions. This new feature is an amazing way to extend your Emby API without having to write
    a plugin to do so. In your package you can 'register' and 'unregister' your own Package API commands that will
    direct to a defined callback when they're called from the Emby API. For more information - please see the
    ScripterX wiki page https://wiki.emby-scripterx.info/books/packages/page/api-extensions

Packages

onItemRemoved - %item.library.* not available

Describe the bug
When using onItemRemoved, %item.library.*% tokens are not substituted for values

To Reproduce
Steps to reproduce the behavior:

  1. Create an onItemRemoved action using any %item.library.* tokens as parameters
  2. Check Emby Log for output for onItemRemoved; Info Emby ScripterX: onItemRemoved: REMOVED 12111 "The Simpsons S23X01 2 Maggie Simpson in The Longest Daycare - Copy" "D:\Media\Movies\The Simpsons S23X01 2 Maggie Simpson in The Longest Daycare - Copy.mp4" "%item.library.name%"

Expected behavior
%item.library.name% should be substituted for its correct value, in this case 'Movies'

Screenshots
n/a

Create event - onTVRecording*

Is your feature request related to a problem? Please describe.
Implement onTVRecording events, such as Start, Complete, etc, to allow for a more flexible post processing system.

Describe the solution you'd like

Describe alternatives you've considered

Additional context

Condition: "%item.type% = Movie/Series" not working?

Describe the bug
Setting the condition to "%item.type% = Movie/Series" doesn't seem to work.

Expected behavior
Execute script when conditions are met.

Screenshots
Screenshot from 2020-07-28 09-18-53

Desktop (please complete the following information):

  • OS: Linux Mint 19.3 Tricia
  • Browser: Chromium
  • Version: 83.0.4103.61

Additional context
I could be going about this all wrong.
If I am, I apologize.

Event scripts don't execute

Describe the bug
Fresh install on Linux. Setup one event to test: onScheduledTask. Trigger the scheduled task from Emby dashboard and nothing happens.

To Reproduce
Steps to reproduce the behavior:

  1. Install ScripterX on Linux
  2. Configure onScheduledTask event
  3. Go to Scheduled Tasks in Emby dashboard
  4. Manually fire ScripterX task
  5. Task reports as "Failed"
  6. Stacktrace from logs pasted below

Expected behavior
The configured script to execute when the scheduled task is triggered
I also tried setting up other events (Auth failed, etc.) and triggered those events in Emby but the script was never triggered by the plugin.

Screenshots
image
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chorme
  • Version: 83

Smartphone (please complete the following information):
n/a

Additional context

2020-06-07 09:10:01.781 Error TaskManager: Error in event handler
	*** Error Report ***
	Version: 4.4.2.0
	Command line: /app/emby/EmbyServer.dll -programdata /config -ffdetect /app/emby/ffdetect -ffmpeg /app/emby/ffmpeg -ffprobe /app/emby/ffprobe -restartexitcode 3
	Operating system: Unix 4.19.0.9
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Runtime: file:///app/emby/System.Private.CoreLib.dll
	System.Environment.Version: 3.1.2
	Processor count: 4
	Program data path: /config
	Application directory: /app/emby
	System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
	   at EmbyScripterX.EventManagers.ScripterXTaskManager._taskManager_TaskExecuting(Object sender, GenericEventArgs`1 e)
	   at MediaBrowser.Common.Events.EventHelper.FireEventIfNotNull[T](EventHandler`1 handler, Object sender, T args, ILogger logger)
	Source: EmbyScripterX
	TargetSite: Void _taskManager_TaskExecuting(System.Object, MediaBrowser.Model.Events.GenericEventArgs`1[MediaBrowser.Model.Tasks.IScheduledTaskWorker])
	
2020-06-07 09:10:01.782 Error TaskManager: Error
	*** Error Report ***
	Version: 4.4.2.0
	Command line: /app/emby/EmbyServer.dll -programdata /config -ffdetect /app/emby/ffdetect -ffmpeg /app/emby/ffmpeg -ffprobe /app/emby/ffprobe -restartexitcode 3
	Operating system: Unix 4.19.0.9
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Runtime: file:///app/emby/System.Private.CoreLib.dll
	System.Environment.Version: 3.1.2
	Processor count: 4
	Program data path: /config
	Application directory: /app/emby
	System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
	   at EmbyScripterX.ScripterXScheduledTaskController.ProcessScheduledTask()
	   at EmbyScripterX.ScripterXScheduledTaskController.Execute(CancellationToken cancellationToken, IProgress`1 progress)
	   at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)
	Source: EmbyScripterX
	TargetSite: System.Threading.Tasks.Task`1[System.Int32] ProcessScheduledTask()
	
2020-06-07 09:10:01.782 Debug TaskManager: Emby ScripterX Scheduled Task Failed after 0 minute(s) and 0 seconds
2020-06-07 09:10:01.814 Error TaskManager: Error in event handler
	*** Error Report ***
	Version: 4.4.2.0
	Command line: /app/emby/EmbyServer.dll -programdata /config -ffdetect /app/emby/ffdetect -ffmpeg /app/emby/ffmpeg -ffprobe /app/emby/ffprobe -restartexitcode 3
	Operating system: Unix 4.19.0.9
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Runtime: file:///app/emby/System.Private.CoreLib.dll
	System.Environment.Version: 3.1.2
	Processor count: 4
	Program data path: /config
	Application directory: /app/emby
	System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
	   at EmbyScripterX.EventManagers.ScripterXTaskManager._taskManager_TaskCompleted(Object sender, TaskCompletionEventArgs e)
	   at MediaBrowser.Common.Events.EventHelper.FireEventIfNotNull[T](EventHandler`1 handler, Object sender, T args, ILogger logger)
	Source: EmbyScripterX
	TargetSite: Void _taskManager_TaskCompleted(System.Object, MediaBrowser.Model.Tasks.TaskCompletionEventArgs)

Create proper documentation & wiki for Packages

Is your feature request related to a problem? Please describe.
The Packages functionality requires a proper wiki and proper documentation for its functionality and usability.

Describe the solution you'd like
A clear, concise wiki and documentation for Packages

@Slugger

Drag and Drop

if you are going to add drag and drop to the parameters section can you add " " around the non integer/number variables or just all variables which would be easier i suspect

Also

  1. can you also add a file picker dialog to pick the script file

1.1 and on basis of script file extension add "-File" , /d etc etc

  1. Make Interpreter a drop down list of supported interpreters powershell, pwsh, cmd etc

with all the above this would eliminate most of the typing and be mostly mouse driven

_onAuthenticationSuccess is never called

Describe the bug
When a user logs in successfully, the _onAuthenticationSuccess() handler from a package is never called.

To Reproduce
Steps to reproduce the behavior:

  1. Install a package with the _onAuthenticationSuccess() handler defined
  2. Trigger the event
  3. View debug logs, see that package event handler wasn't called

Expected behavior
The event handler from my package should be called.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

JsonPost() sends invalid Accept header

Describe the bug
When using ScripterX.Web.JsonPost(), the request that gets sent includes an invalid Accept header. The header being sent in the request is:

Accept: Accept application/json

It should just be:

Accept: application/json

To Reproduce
Steps to reproduce the behavior:

  1. Attempt a JsonPost() to an endpoint that enforces the Accept header content type

Endpoint will return an Invalid Media Type http error in response.

Expected behavior
Proper accept header sent in request so that the endpoint can return a response

Desktop (please complete the following information):
n/a

Smartphone (please complete the following information):
n/a

Additional context
Add any other context about the problem here.

Interpreter error

I m not sure what I m doing wrong but when I m trying to add an .sh script and choose /bin/bash interpreter I m seeing an exclamation mark.

I m seeing it whatever interpreter I choose actually.

My server is running on a raspberry with Debian
ss

Version Variable

Is your feature request related to a problem? Please describe.
As we are going through multiple versions of ScripterX at the moment

Describe the solution you'd like
Could we have a variable with the ScripterX version number - that applies to all events - don't think you need to add this to the interface UI - as likely this will only be needed occasionally and once the code is mature is likely not going to be used much.

Additional context
The reason is that when we have an issue like %item.library.name% working sometimes and not others - tracking which version did or did not work - would be a lot simpler if we had a version variable we could add to the script logs.

_onAuthenticationSuccess() does not execute

Describe the bug
The event handler does not execute and throws a stacktrace.

To Reproduce
Steps to reproduce the behavior:

  1. Install a package with this event handler
  2. Trigger the event

Expected behavior
The event handler is called and executed as expected.

Additional context

2020-06-29 04:30:04.603 Error Emby ScripterX: Error invoking function '_onAuthenticationSuccess' on package with installationId '679b7e32-79be-4330-b8c7-6dfdf992f740' failed: System.ArgumentException: Can not add property %server.name% to Newtonsoft.Json.Linq.JObject. Property with the same name already exists on object.
at Jint.Runtime.Interop.MethodInfoFunctionInstance.Invoke(MethodInfo[] methodInfos, JsValue thisObject, JsValue[] jsArguments)
at Jint.Runtime.ExpressionInterpreter.EvaluateCallExpression(CallExpression callExpression)
at Jint.Runtime.ExpressionInterpreter.EvaluateMemberExpression(MemberExpression memberExpression)
at Jint.Runtime.ExpressionInterpreter.EvaluateCallExpression(CallExpression callExpression)
at Jint.Runtime.ExpressionInterpreter.EvaluateBinaryExpression(BinaryExpression expression)
at System.Linq.Utilities.<>c__DisplayClass2_0`3.<CombineSelectors>b__0(TSource x)
at System.Linq.Enumerable.SelectListIterator`2.ToArray()
at Jint.Runtime.ExpressionInterpreter.EvaluateCallExpression(CallExpression callExpression)
at Jint.Runtime.StatementInterpreter.ExecuteExpressionStatement(ExpressionStatement expressionStatement)
at Jint.Engine.ExecuteStatement(Statement statement)
at Jint.Runtime.StatementInterpreter.ExecuteStatementList(IEnumerable`1 statementList)
at Jint.Engine.ExecuteStatement(Statement statement)
at Jint.Native.Function.ScriptFunctionInstance.Call(JsValue thisArg, JsValue[] arguments)
at EmbyScripterX.Packages.Package.invokeFunction(String function, Object[] param_objects)

Ideas for Notification Parameters in Events

Anthony you asked for ideas for variables.

This list was extracted raw from Tautulli (Plex's equivalent to ScripterX in terms of event notification)
Of course the list is enormous and would need to be viewed through the lens of what Emby provides, and your user's priorities, but it is one source of ideas.

I believes the list equally applies to conditions should they ever be introduced.

Global
{tautulli_version} The current version of Tautulli.
{tautulli_remote} The current git remote of Tautulli.
{tautulli_branch} The current git branch of Tautulli.
{tautulli_commit} The current git commit hash of Tautulli.
{server_name} The name of your Plex Server.
{server_ip} The connection IP address for your Plex Server.
{server_port} The connection port for your Plex Server.
{server_url} The connection URL for your Plex Server.
{server_platform} The platform of your Plex Server.
{server_version} The current version of your Plex Server.
{server_machine_id} The unique identifier for your Plex Server.
{action} The action that triggered the notification.
{current_year} The year when the notification is triggered.
{current_month} The month when the notification is triggered. (1 to 12)
{current_day} The day when the notification is triggered. (1 to 31)
{current_hour} The hour when the notification is triggered. (0 to 23)
{current_minute} The minute when the notification is triggered. (0 to 59)
{current_second} The second when the notification is triggered. (0 to 59)
{current_weekday} The ISO weekday when the notification is triggered. (1 (Mon) to 7 (Sun))
{current_week} The ISO week number when the notification is triggered. (1 to 52)
{datestamp} The date (in date format) when the notification is triggered.
{timestamp} The time (in time format) when the notification is triggered.
{unixtime} The unix timestamp when the notification is triggered.
{utctime} The UTC timestamp in ISO format when the notification is triggered.
Stream Details
{streams} The total number of concurrent streams.
{direct_plays} The total number of concurrent direct plays.
{direct_streams} The total number of concurrent direct streams.
{transcodes} The total number of concurrent transcodes.
{total_bandwidth} The total Plex Streaming Brain reserved bandwidth (in kbps).

(not the used bandwidth)

{lan_bandwidth} The total Plex Streaming Brain reserved LAN bandwidth (in kbps).

(not the used bandwidth)

{wan_bandwidth} The total Plex Streaming Brain reserved WAN bandwidth (in kbps).

(not the used bandwidth)

{user_streams} The number of concurrent streams by the user streaming.
{user_direct_plays} The number of concurrent direct plays by the user streaming.
{user_direct_streams} The number of concurrent direct streams by the user streaming.
{user_transcodes} The number of concurrent transcodes by the user streaming.
{user} The friendly name of the user streaming.
{username} The username of the user streaming.
{user_email} The email address of the user streaming.
{user_thumb} The profile picture URL of the user streaming.
{device} The type of client device being used for playback.
{platform} The type of client platform being used for playback.
{product} The type of client product being used for playback.
{player} The name of the player being used for playback.
{initial_stream} If the stream is the initial stream of a continuous streaming session. (0 or 1)
{ip_address} The IP address of the device being used for playback.
{stream_duration} The duration (in minutes) for the stream.
{stream_time} The duration (in time format) of the stream.
{remaining_duration} The remaining duration (in minutes) of the stream.
{remaining_time} The remaining duration (in time format) of the stream.
{progress_duration} The last reported offset (in minutes) of the stream.
{progress_time} The last reported offset (in time format) of the stream.
{progress_percent} The last reported progress percent of the stream.
{transcode_decision} The transcode decisions of the stream.
{video_decision} The video transcode decisions of the stream.
{audio_decision} The audio transcode decisions of the stream.
{subtitle_decision} The subtitle transcode decisions of the stream.
{quality_profile} The Plex quality profile of the stream. (e.g. Original, 4 Mbps 720p, etc.)
{optimized_version} If the stream is an optimized version. (0 or 1)
{optimized_version_profile} The optimized version profile of the stream.
{synced_version} If the stream is an synced version. (0 or 1)
{live} If the stream is live TV. (0 or 1)
{channel_call_sign} The Live TV channel call sign.
{channel_identifier} The Live TV channel number.
{channel_thumb} The URL for the Live TV channel logo.
{secure} If the stream is using a secure connection. (0 or 1)
{relayed} If the stream is using Plex Relay. (0 or 1)
{stream_local} If the stream is local. (0 or 1)
{stream_location} The network location of the stream. (lan or wan)
{stream_bandwidth} The Plex Streaming Brain reserved bandwidth (in kbps) of the stream.

(not the used bandwidth)

{stream_container} The media container of the stream.
{stream_bitrate} The bitrate (in kbps) of the stream.
{stream_aspect_ratio} The aspect ratio of the stream.
{stream_video_codec} The video codec of the stream.
{stream_video_codec_level} The video codec level of the stream.
{stream_video_bitrate} The video bitrate (in kbps) of the stream.
{stream_video_bit_depth} The video bit depth of the stream.
{stream_video_chroma_subsampling} The video chroma subsampling of the stream.
{stream_video_color_primaries} The video color primaries of the stream.
{stream_video_color_range} The video color range of the stream.
{stream_video_color_space} The video color space of the stream.
{stream_video_color_trc} The video transfer function of the stream.
{stream_video_dynamic_range} The video dynamic range of the stream. (HDR or SDR)
{stream_video_framerate} The video framerate of the stream.
{stream_video_full_resolution} The video resolution of the stream with scan type.
{stream_video_ref_frames} The video reference frames of the stream.
{stream_video_resolution} The video resolution of the stream.
{stream_video_scan_type} The video scan type of the stream.
{stream_video_height} The video height of the stream.
{stream_video_width} The video width of the stream.
{stream_video_language} The video language of the stream.
{stream_video_language_code} The video language code of the stream.
{stream_audio_bitrate} The audio bitrate of the stream.
{stream_audio_bitrate_mode} The audio bitrate mode of the stream. (cbr or vbr)
{stream_audio_codec} The audio codec of the stream.
{stream_audio_channels} The audio channels of the stream.
{stream_audio_channel_layout} The audio channel layout of the stream.
{stream_audio_sample_rate} The audio sample rate (in Hz) of the stream.
{stream_audio_language} The audio language of the stream.
{stream_audio_language_code} The audio language code of the stream.
{stream_subtitle_codec} The subtitle codec of the stream.
{stream_subtitle_container} The subtitle container of the stream.
{stream_subtitle_format} The subtitle format of the stream.
{stream_subtitle_forced} If the subtitles are forced. (0 or 1)
{stream_subtitle_language} The subtitle language of the stream.
{stream_subtitle_language_code} The subtitle language code of the stream.
{stream_subtitle_location} The subtitle location of the stream.
{transcode_container} The media container of the transcoded stream.
{transcode_video_codec} The video codec of the transcoded stream.
{transcode_video_width} The video width of the transcoded stream.
{transcode_video_height} The video height of the transcoded stream.
{transcode_audio_codec} The audio codec of the transcoded stream.
{transcode_audio_channels} The audio channels of the transcoded stream.
{transcode_hw_requested} If hardware decoding/encoding was requested. (0 or 1)
{transcode_hw_decoding} If hardware decoding is used. (0 or 1)
{transcode_hw_decode} The hardware decoding codec.
{transcode_hw_decode_title} The hardware decoding codec title.
{transcode_hw_encoding} If hardware encoding is used. (0 or 1)
{transcode_hw_encode} The hardware encoding codec.
{transcode_hw_encode_title} The hardware encoding codec title.
{session_key} The unique identifier for the session.
{transcode_key} The unique identifier for the transcode session.
{session_id} The unique identifier for the stream.
{user_id} The unique identifier for the user.
{machine_id} The unique identifier for the player.
Source Metadata Details
{media_type} The type of media. (movie, show, season, episode, artist, album, track, clip)
{title} The full title of the item.
{library_name} The library name of the item.
{show_name} The title of the TV series.
{episode_name} The title of the episode.
{artist_name} The name of the artist.
{album_name} The title of the album.
{track_name} The title of the track.
{track_artist} The name of the artist of the track.
{season_num} The season number. (e.g. 1, or 1-3)
{season_num00} The two digit season number. (e.g. 01, or 01-03)
{episode_num} The episode number. (e.g. 6, or 6-10)
{episode_num00} The two digit episode number. (e.g. 06, or 06-10)
{track_num} The track number. (e.g. 4, or 4-10)
{track_num00} The two digit track number. (e.g. 04, or 04-10)
{season_count} The number of seasons.
{episode_count} The number of episodes.
{album_count} The number of albums.
{track_count} The number of tracks.
{year} The release year for the item.
{release_date} The release date (in date format) for the item.
{air_date} The air date (in date format) for the item.
{added_date} The date (in date format) the item was added to Plex.
{updated_date} The date (in date format) the item was updated on Plex.
{last_viewed_date} The date (in date format) the item was last viewed on Plex.
{studio} The studio for the item.
{content_rating} The content rating for the item. (e.g. TV-MA, TV-PG, etc.)
{directors} A list of directors for the item.
{writers} A list of writers for the item.
{actors} A list of actors for the item.
{genres} A list of genres for the item.
{labels} A list of labels for the item.
{collections} A list of collections for the item.
{summary} A short plot summary for the item.
{tagline} A tagline for the media item.
{rating} The rating (out of 10) for the item.
{critic_rating} The critic rating (%) for the item.

(Ratings source must be Rotten Tomatoes for the Plex Movie agent)

{audience_rating} The audience rating (%) for the item.

(Ratings source must be Rotten Tomatoes for the Plex Movie agent)

{duration} The duration (in minutes) for the item.
{poster_url} A URL for the movie, TV show, or album poster.
{plex_url} The Plex URL to your server for the item.
{imdb_id} The IMDB ID for the movie. (e.g. tt2488496)
{imdb_url} The IMDB URL for the movie.
{thetvdb_id} The TVDB ID for the TV show. (e.g. 121361)
{thetvdb_url} The TVDB URL for the TV show.
{themoviedb_id} The TMDb ID for the movie or TV show. (e.g. 15260)
{themoviedb_url} The TMDb URL for the movie or TV show.
{tvmaze_id} The TVmaze ID for the TV show. (e.g. 290)
{tvmaze_url} The TVmaze URL for the TV show.
{musicbrainz_id} The MusicBrainz ID for the artist, album, or track. (e.g. b670dfcf-9824-4309-a57e-03595aaba286)
{musicbrainz_url} The MusicBrainz URL for the artist, album, or track.
{lastfm_url} The Last.fm URL for the album.

(Music library agent must be Last.fm)

{trakt_url} The trakt.tv URL for the movie or TV show.
{container} The media container of the original media.
{bitrate} The bitrate of the original media.
{aspect_ratio} The aspect ratio of the original media.
{video_codec} The video codec of the original media.
{video_codec_level} The video codec level of the original media.
{video_bitrate} The video bitrate of the original media.
{video_bit_depth} The video bit depth of the original media.
{video_chroma_subsampling} The video chroma subsampling of the original media.
{video_color_primaries} The video color primaries of the original media.
{video_color_range} The video color range of the original media.
{video_color_space} The video color space of the original media.
{video_color_trc} The video transfer function of the original media.
{video_dynamic_range} The video dynamic range of the original media. (HDR or SDR)
{video_framerate} The video framerate of the original media.
{video_full_resolution} The video resolution of the original media with scan type.
{video_ref_frames} The video reference frames of the original media.
{video_resolution} The video resolution of the original media.
{video_scan_type} The video scan type of the original media.
{video_height} The video height of the original media.
{video_width} The video width of the original media.
{video_language} The video language of the original media.
{video_language_code} The video language code of the original media.
{audio_bitrate} The audio bitrate of the original media.
{audio_bitrate_mode} The audio bitrate mode of the original media. (cbr or vbr)
{audio_codec} The audio codec of the original media.
{audio_channels} The audio channels of the original media.
{audio_channel_layout} The audio channel layout of the original media.
{audio_sample_rate} The audio sample rate (in Hz) of the original media.
{audio_language} The audio language of the original media.
{audio_language_code} The audio language code of the original media.
{subtitle_codec} The subtitle codec of the original media.
{subtitle_container} The subtitle container of the original media.
{subtitle_format} The subtitle format of the original media.
{subtitle_forced} If the subtitles are forced. (0 or 1)
{subtitle_location} The subtitle location of the original media.
{subtitle_language} The subtitle language of the original media.
{subtitle_language_code} The subtitle language code of the original media.
{file} The file path to the item.
{filename} The file name of the item.
{file_size} The file size of the item.
{section_id} The unique identifier for the library.
{rating_key} The unique identifier for the movie, episode, or track.
{parent_rating_key} The unique identifier for the season or album.
{grandparent_rating_key} The unique identifier for the TV show or artist.
{art} The Plex background art for the media.
{thumb} The Plex thumbnail for the movie or episode.
{parent_thumb} The Plex thumbnail for the season or album.
{grandparent_thumb} The Plex thumbnail for the TV show or artist.
{poster_thumb} The Plex thumbnail for the poster image.
{poster_title} The title for the poster image.
{indexes} If the media has video preview thumbnails. (0 or 1)
Plex Remote Access
{remote_access_mapping_state} The mapping state of the Plex remote access port.
{remote_access_mapping_error} The mapping error of the Plex remote access port.
{remote_access_public_address} The Plex remote access public IP address.
{remote_access_public_port} The Plex remote access public port.
{remote_access_private_address} The Plex remote access private IP address.
{remote_access_private_port} The Plex remote access private port.
{remote_access_reason} The failure reason for Plex remote access going down.
Plex Update Available
{update_version} The available update version for your Plex Server.
{update_url} The download URL for the available update.
{update_release_date} The release date of the available update.
{update_channel} The update channel. (Public or Plex Pass)
{update_platform} The platform of your Plex Server.
{update_distro} The distro of your Plex Server.
{update_distro_build} The distro build of your Plex Server.
{update_requirements} The requirements for the available update.
{update_extra_info} Any extra info for the available update.
{update_changelog_added} The added changelog for the available update.
{update_changelog_fixed} The fixed changelog for the available update.
Tautulli Update Available
{tautulli_update_version} The available update version for Tautulli.
{tautulli_update_release_url} The release page URL on GitHub.
{tautulli_update_tar} The tar download URL for the available update.
{tautulli_update_zip} The zip download URL for the available update.
{tautulli_update_commit} The commit hash for the available update.
{tautulli_update_behind} The number of commits behind for the available update.
{tautulli_update_changelog} The changelog for the available update.

Package event handler documented incorrectly

Describe the bug
Packages wiki says to create event handler _onAuthenticationFailed(context) so I assumed that meant to prefix every event handler with an underscore. But then my event handlers weren't called (well _package_init() is called but not _onScheduledTask()). When I renamed it to just onScheduledTask() it was then called.

To Reproduce
Steps to reproduce the behavior:

  1. Follow wiki docs for creating packages
  2. Trigger an event to call a handler in your package

Expected behavior
Handler is called

Screenshots
n/a

Desktop (please complete the following information):
n/a

Smartphone (please complete the following information):
n/a

Additional context
The wiki docs just aren't clear on how to name event handler functions. After some trial and error and the enabled debug logging, I got it figured out. I'm going with the functioning sol'n and not the wiki. I assume you'll be keeping the event handlers without the underscore? :)

Unable to install package

Describe the bug
Created a basic test package, in a newly built dev env (fresh docker install, latest docker, no media, separate from my prod server, etc., latest ScripterX installed).

To Reproduce
Steps to reproduce the behavior:

  1. Install latest Emby docker
  2. Install latest ScripterX
  3. Create a basic package following wiki instructions
  4. Attempt to install package zip

Expected behavior
Uploaded package zip is installed and deployed

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows
  • Chrome
  • 83

Smartphone (please complete the following information):
n/a

** Server Details **

  • Debian 10
  • Docker image: linuxserver/emby (latest 4.4.3)
  • latest ScripterX installed

Additional context
After the error is reported back, I can go into the docker and go to the directory it shows in the error message and it exists and my zip file has been exploded there. I can see my json and js files sitting there. So the zip was accepted and unzipped on the server, but then I get the error shown.

User disconnecting

Is your feature request related to a problem? Please describe.
Not a problem per se.
The way I have it now is, when a user starts a video it writes it to a file,
and when playback is stopped the file is cleared.
Sometimes, some of my users disconnects before stopping the video, so it never clears.

Describe the solution you'd like
A trigger for when a user disconnect.

Describe alternatives you've considered
I haven't figured out a better way to clear the file than to do it manually, but that kinda ruins the whole point of this plugin.

Additional context
emby

onLibraryScanComplete - add scan result

Is your feature request related to a problem? Please describe.
Can you add %task.result% - probably as %scan.result% to the lib scan complete event as its missing

Describe the solution you'd like
task.result exists for onScheduledTaskEnded - can this be added to lib scan complete

As a replacement for issue 4

Supression / Queueing System: onItemAdded, onItemUpdated

Is your feature request related to a problem? Please describe.
I added a new series of 2 seasons and 10 episodes per season

An event was fired for each of 1 series, 2 seasons, 20 episodes

it would be great if there was an option to slow down the event firing and aggregate changes into more meaningful parcels once a steady library state is achieved.

ie report on the top level change

In the case above - Fire once against series

3rd season with 1st three episodes added - Fire Once Against Season

3 episodes added - Fire 3 times for each episode

Multiple tracks on same album - Fire once against album.

This is even worse with itemupdated especially if its being recorded - get numerous events as it progresses - then when it gets its metadata etc etc - one i have avoided so far

The issue Anthony may have is that these events are the events Emby works with and produces normally as things change

Return of Enable ScripterX

Is your feature request related to a problem? Please describe.
In early versions of the plugin there was a checkbox to turn the plugin off

Describe the solution you'd like
Could it make a return? Would be handy to save having to delete stuff from the plugin page.

5e8de4f5be2bd_Annotation20200408154953

Cannot use ScripterX on Synology NAS

Hello,

I have a working install of Emby (4.4.3.0) on a Synology NAS. I can install ScripterX
without any problems. As soon as I open it, all available actions are greyed out and
I get heaps of Exceptions in my log that look like this:

2020-09-03 12:25:11.802 Error App: Error in IsExportType
	*** Error Report ***
	Version: 4.4.3.0
	Command line: /var/packages/EmbyServer/target/server/EmbyServer.exe -package synology -programdata /var/packages/EmbyServer/target/var -ffmpeg /var/packages/EmbyServer/target/ffmpeg/bin/ffmpeg -ffprobe /var/packages/EmbyServer/target/ffmpeg/bin/ffprobe -ffdetect /var/packages/EmbyServer/target/ffmpeg/bin/ffdetect -restartexitcode 121 -ignore_vaapi_enabled_flag
	Operating system: Unix 3.10.105.0
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: False
	Mono: 6.8.0.105 (tarball Fri Apr 10 10:40:42 UTC 2020)
	Runtime: file:///volume1/@appstore/EmbyServer/3rdparty/mono/6.8.0.105/lib/mono/4.5/mscorlib.dll
	System.Environment.Version: 4.0.30319.42000
	Processor count: 4
	Program data path: /var/packages/EmbyServer/target/var
	Application directory: /volume1/@appstore/EmbyServer/releases/4.4.3.0
	System.TypeLoadException: System.TypeLoadException: Could not load type of field 'EmbyScripterX.Packages.Package:packageEngine' (11) due to: Could not load file or assembly 'Jint, Version=0.0.0.0, Culture=neutral, PublicKeyToken=2e92ba9c8d81157f' or one of its dependencies.
	  at (wrapper managed-to-native) System.RuntimeTypeHandle.type_is_assignable_from(System.Type,System.Type)
	  at System.RuntimeTypeHandle.CanCastTo (System.RuntimeType type, System.RuntimeType target) [0x00000] in <9d3f0d4bd0fb4c1e8b6c2ac1ba1303ac>:0 
	  at System.RuntimeType.IsAssignableFrom (System.Type c) [0x00020] in <9d3f0d4bd0fb4c1e8b6c2ac1ba1303ac>:0 
	  at Emby.Server.Implementations.ApplicationHost.IsExportType (System.Type currentType, System.Tuple`2[T1,T2] i) [0x00007] in <4b2b35e458474e708c04b3533f59ad82>:0 
	Source: 
	TargetSite: 

If needed I can provide a full log file as well.

Is there maybe something I missed during, before or after install?

Thank you

MusicArtist not being included in ItemAdded

Is your feature request related to a problem? Please describe.

I added a folder for the artist Duffy which contained the Album Folder Rockferry
The folder Duffy and rockferry were picked up fine - along with all the tracks - great
Apart from the missing Library.name
I noticed that there was no event for a MusicArtist being added - there is one for Duffy being updated though - again not sure if this is Emby or just missed off your list?

Change name of OnScheduledTask

Is your feature request related to a problem? Please describe.
A suggestion - we have three scheduled Task events now - so could be a tad confusing

Describe the solution you'd like
Maybe change this to onScripterXScheduledTask to make it clearer its for the ScripterX scheduled task in the scheduled Tasks section of Emby

5ea8154aeb655_Annotation20200428123452

Additional context
I noticed you removed the description about the event - not sure if this is intentional or not as it gave a good indication of what it was for.

Some Event ideas i had a few days ago

1 Name of Task

2Time taken

3 Status - i.e. Completed/Failed/Aborted etc - if its available -> Manual (user) start rather than on a schedule

When it last ran before - if that's available after you get the event?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.