Jump to content
Anthony Musgrove

New Plugin - Custom Scripting | Emby ScripterX

Recommended Posts

Anthony Musgrove
Posted (edited)

Good evening all, 

 

I am extremely happy to present to you - Emby Scripter-X version 3.0 (up on the catalog now!)

 

5ed0b938393f4_EmbyScripterX_v300Logo.png

 

The major change in this version is -- Packages -- !

 

This gives you the opportunity to develop packages for Scripter X for others to install and use.   And very soon, there will be a Packages catalog available that you'll be able to search for, and install community packages, straight from your Emby Administration Console.

 

A package is written in Javascript.   A Package requires 3 things - 1)  a PackageInfo.json file, 2) a Package.js file, and 3) both these files zipped up together in a .ZIP file.

 

PackageInfo.json provides vital information about your package to ScripterX.  It's format is as follows :-

{
	"Id":			"scripterx.package.example",
	"Name":  		"Example Package",
	"Description":	"An example package for the ScripterX package system.",
	"Author":		"Anthony Musgrove",
	"Email":		"anthony@emby-scripterx.info"
}

Package.js is the javascript file for your package - where all your code exists.    This is the fun bit.

 

Some important things to know about your script:

 

When your package is initialised by ScripterX (on installation, and on server startup), a function in your Package.js is executed.  It is called _package_init():

function _package_init() {
     //do something here on package startup
}

- Your script can subscribe to ANY of the ScripterX events, by adding a function with the name _EventName, for example, if you wish to subscribe your package to the onAuthenticationFailed event, you'd simply enter:

function _onAuthenticationFailed(context)
{
      //do something here when someone fails to authenticate to emby.
}

*** Note, the parameter for these functions is context, which is the context of the event call.  It contains all the information regarding token values, etc, that you have full access to.   For example, to get the username of the attempted failed authentication, you could use :-

function _onAuthenticationFailed(context)
{
      var attempted_username = context.Token("%username%").value;
}

Same goes for any of the other events, events being:

onAuthenticationFailed, onAuthenticationSuccess, onLibraryScanComplete, onMediaItemAdded, onMediaItemRemoved, onMediaItemUpdated,
onPlaybackStart, onPlaybackStopped, onScheduledTask, onSessionEnded, onSessionStarted, onCameraImageUploaded, onLiveTVRecordingStart,
onLiveTVRecordingEnded, onScheduledTaskStart, onScheduledTaskEnded,  onMediaItemAddedComplete, onPlaybackProgress

To log output from your package to the Emby server log, you can utilise the ScripterX.Log functions, they are :-

ScripterX.Log.Info("Add an Info log entry to emby server log.");
ScripterX.Log.Error("Add an Error log entry to emby server log.");

If you need timers, ScripterX has timers.   You can simply create, delete, start, restart or stop a timer by using the following Timers commands :

 

Create a timer that only elapses once, but can be restarted manually after its elapsed, by using .createOnce:

ScripterX.Timers.createOnce("myTimer", 5000, "tmrMyTimer_Elapsed", null); 

or, create a timer that elapses every interval, without having to be restarted, by using .createRepeating:

ScripterX.Timers.createRepeating("myRepeatingTimer", 10000, "tmrMyRepeatingTimer_Elapsed", null);

When your timer elapses, it will call the function set in as your callback.  For example, when my timer elapses, it will call the following function:

function tmrMyTimer_Elapsed(timer_name, timer_interval, objects)
{
   //do something here when my timer elapses, the timer's name is given here too.
   //timer name is needed to start, stop, restart, delete etc.
} 

ScripterX supports webhook posts right from your javascript, you can perform a webhook post by using the ScripterX.Web functions, for example, in my _onPlaybackStart function, I want to post to a webhook every time someone starts playing a movie or TV show on my server, I can do this by:

function _onPlaybackStart(context)
{
	/* Send a webhook when (someone) plays (something) */
	var api_url = "https://myapi.url.com";
	
	var playback_info = {};
	
	playback_info.itemId = context.Token("%item.id%").value;
	playback_info.itemName = context.Token("%item.name%").value;
	
	playback_info.userName = context.Token("%username%").value;
	playback_info.deviceName = context.Token("%device.name%").value;

	playback_info.serverName = context.Token("%server.name%").value;
	
	playback_info.memo = playback_info.userName + " is playing " + playback_info.itemName + " on device " + playback_info.deviceName + " from server " + playback_info.serverName; 
	
	ScripterX.Web.Post(api_url, JSON.stringify(playback_info));
} 

- Once you've created your Package zip file for distribution, you can install it on your Emby server by using the Emby Scripter-X package installer interface, as shown below:

 

5ed0bded47053_sxPackagesInterface.png

 

 

While you're testing your package, you don't have to keep uninstalling and reinstalling your package to test and debug.  Simply install your package ONCE, then navigate to your Emby data directory, find ScripterX, then find Packages, then find the folder labelled with your package's assigned installationId.  Inside this directory, you'll notice Package.js.  Make changes directly to this file, then go back into your Emby administration panel and click the 'Reload' icon next to your package listed in your 'Installed Packages' panel.  The reload icon is next to the uninstall/delete icon.   If you wish to uninstall a package, simply click the trashbin, then confirm by clicking 'Really Uninstall?' 

 

 

There is MUCH, MUCH more to come, but for now this will get people going.   There are other function groups that I am going to implement including Library searching and Item manipulation, User manipulation and searching, among many, many other functionality. 

 

Please enjoy, and as always, any comments, feedback, suggestions are MUCH MUCH appreciated.

 
Emby ScripterX  (github: https://github.com/AnthonyMusgrove/Emby-ScripterX)
 
 

5ec23e0c36877_onMediaItemAddedComplete.p

 

Project/Product Website:  https://www.emby-scripterx.info/
 
Version v2.3.4 now up on the Emby Plugin Catalog & GitHub with changes.
 
Events supported:
 
On Authentication Failed, On Authentication Success, On Playback Start, On Playback Stopped, On Session Started, On Session Ended, On Media Item Added, On Media Item Updated, On Media Item Removed, on Scripter-X Scheduled Task, on Library Scan Completed, On Camera Image Uploaded, on Live TV Recording Start, on Live TV Recording EndedonScheduledTaskStart, onScheduledTaskEnded, onPlaybackProgress, onMediaItemAddedComplete
 

For tokens available, please see GitHub readme, or check out the Actions interface in the plugin - you can find the plugin in the Emby Server Catalog, under 'General'.

 

ChangeLog

 

Changes for 2.3.4:

Major core rewrite

Added conditions (drag and drop) Rewrote token parser and added contexts Added event onPlaybackProgress (which supports transcoding detection) Added event onMediaItemAddedComplete which is called virtually, after an onMediaItemAdded + Meta Data (or timeout of 40 seconds, whichever comes first) Added IP address tokens for Authentication events Various other modifications and changes

 

Changes for 2.3.1:

%item.library.name%, %item.library.type% issue resolved
Added confirmation on delete for actions (theme friendly)
Remove 'Global Tokens' section in Actions interface (they're listed now for each event)
 
5eb6a89cad2f3_Confirm_Delete.png

 

Changes for 2.3.0:

Variables are now case-insensitive, refactoring a lot of the interface code (Prototype-to-production), cleaning interface, addressed various GitHub issues.

 

Changes for 2.2.9:

Progressively from v2.2.6, functionality to enable or disable events individually, many more tokens (please see GitHub tokens list or the Actions interface), global tokens (server version, uptime, etc), more item tokens (for example, season number, episode number, item meta (imdb id, tmdb id, whatever you wish), season meta, series meta, plus plenty more!

 

Changes for 2.2.5:

Aesthetics on Actions Interface (enlarged textboxes for script and interpreter, better alignment of add buttons)

 

Changes for 2.2.4:

Progessively from v2.2.0 to v2.2.4, integration with a sortable library, actions user interface customisation and remembering custom order within browser local storage.  

 

Changes for 2.2.0:

Now theme friendly and compatible, changes with theme selection correctly.

 

Changes for 2.1.9:

Redesign Events/Actions interface for less clutter

Please ignore the 'Advanced' tab, It won't be there in the next catalog release, its just used for debug at this stage.

 

Changes for 2.1.7, 2.1.6, 2.1.5, 2.1.4:

Progressive changes to implement Live TV Recording Events.  'Emby Scripter-X DVR Manager' was implemented in the codebase to handle all Live TV events, tokens and logging.

 

Changes for 2.1.3:

 

Addressed bug with %item.library.*% tokens with respect to onItemRemoved event. (see https://github.com/AnthonyMusgrove/Emby-ScripterX/issues/2 for info!)

 

Changes for 2.1.2:

 

Added new event - onCameraImageUploaded.  This event is triggered when a user uploads an image to the Emby Server via the 'Camera Upload' functionality within the various Emby Apps.  Tokens supported are as above.  Below is an image of the event on the Actions page, along with an image of a sample batch script and output:

 

5e9eeabfb5e82_onCameraImageUploaded.png

 

5e9eeacbda051_onCameraImageUploaded_Outp

 

 

Changes for 2.1.1:

Actions now utilises the entire available interface space; so editing and viewing are much easier.
Some input validation added for Interpreter and Script
Some cosmetic modifications :- on adding new action, delete/trash button is now changed to 'X' so it indicates 'remove this unsaved action'.  Once a new action is saved, the 'X' icon will change to a 'trash/delete' icon, signifying 'delete this action from the server'.
 

Changes for 2.1.0:

Bug fix for " in script name, parameters, interpreter.

various other bugs, interface bug fixes
very stable at this stage.
 
Changes for 2.0.0:
Redesign Interfaces, add Actions interface, Community interface (as tabs)
Redesign core
Allow multiple script actions for each event
 

Changes for 1.0.0.8 - Various updates/changes: 
Addressed issues with having to supply entire path to interpreter.  
Implemented better way to detect OS platform (IsWindows() IsLinux() IsOSX())
Powershell.exe, cmd.exe, /bin/bash or a custom executable is now supported
 
Examples now:
using powershell.exe as interpreter:
-File "D:\embyscripts\ScripterX-test.ps1" -Name %item.name% -ID %item.id% -Type %item.type% -LibName %item.library.name%
 
using cmd.exe as interpreter:
/s /c D:\embyscripts\test.bat AuthFail %username% %user.id% %device.id% %device.name%
 
using /bin/bash
/home/medius/scripts/test.sh AuthOK %username%
 
Changes for 1.0.0.7: 

on Library Scan Completed :

D:\embyscripts\test.bat Library Scan Complete!

 
Library Scan Complete! 
 

 

Changes for 1.0.0.6:

%item.update.reason% :

 

Media Item Updated "1917" "D:\Media\Movies\1917.2019.1080p.BluRay.x264.AAC5.1-[YTS.MX] - Copy.mp4" (Update Reason: MetadataEdit) 
 
‪D:\embyscripts\test.bat Media Item Updated "%item.name%" "%item.path%" (Update Reason: %item.update.reason%)
 
1.0.0.5 additions:  %series.id%, %series.name%, %season.id%, %season.name% :
 
PlaybackStart ItemID: 593 - Name: "Brian: Portrait of a Dog" - Path: "D:\Media\TV\Family Guy\S01\S01E07 - Brian - Portrait Of A Dog.avi" - Username: Anthony - DeviceName: Firefox - ItemType: item type: Episode - LibraryName: TV - LibraryContentType: tvshows (seriesname: Family Guy) (season: Season 1) 
 
‪D:\embyscripts\test.bat PlaybackStart ItemID: %item.id% - Name: "%item.name%" - Path: "%item.path%" - Username: %username% - DeviceName: %device.name% - ItemType: item type: %item.type% - LibraryName: %item.library.name% - LibraryContentType: %item.library.type% (seriesname: %series.name%) (season: %season.name%)
 
README is on Github.  Comments/Feedback/Suggestions are GREATLY appreciated.
 
 
On Scheduled Task:
 
A field now exists to specify a script to run as a scheduled task - you'll now see under 'Scheduled Tasks -> Application' an Emby ScripterX Scheduled Task.
 
No tokens are yet available to this field - need feedback/suggestions/comments on what should be available to specify as parameters/tokens.
 

Edited by Anthony.Musgrove
  • Like 11

Share this post


Link to post
Share on other sites
Luke

Great stuff, thanks !

  • Like 1

Share this post


Link to post
Share on other sites
TeamB
Posted (edited)

@@Luke now do this as a delete action :-)

Edited by TeamB
  • Like 1

Share this post


Link to post
Share on other sites
Anthony Musgrove

Hi Luke, @@ebr, I just read your howto on how to publish to the catalog; could I please request the following :-

 

First, request a developer id from the MB team by sending a PM to ebr or posting in the dev forum that you are ready to publish.

 

Thank you!

Share this post


Link to post
Share on other sites
rechigo

This is neat, could you possibly add an event for when application updates are pending? 

 

Good luck getting it onto the catalog though, lol

  • Like 2

Share this post


Link to post
Share on other sites
PenkethBoy

Hi - this looks great

 

One thing - you have - %item.mediatype% - which in some cases is not available and e.g. "Video" is very generic. A Movie and Episode would appear the "same" as both video.

 

So could you add %item.type% as its more useful for determining what got added

 

e.g. Adding an album - type will = musicalbum and does not have a mediatype

 

similar for boxsets, libraries, seasons, extras etc etc

 

Hopefully an easy addition

  • Like 1

Share this post


Link to post
Share on other sites
Anthony Musgrove

Hi - this looks great

 

One thing - you have - %item.mediatype% - which in some cases is not available and e.g. "Video" is very generic. A Movie and Episode would appear the "same" as both video.

 

So could you add %item.type% as its more useful for determining what got added

 

e.g. Adding an album - type will = musicalbum and does not have a mediatype

 

similar for boxsets, libraries, seasons, extras etc etc

 

Hopefully an easy addition

 

 

Absolutely, and thank you very much for your suggestions.  This is now complete - I'll upload the new version of the plugin to GitHub.

 

I've added: %item.content.type% and %item.library.name%  -- this references to the collection type of the library that contains the media in question.  

 

So my examples below, I have some movies in the Movies collection, which has a collection type of movies, and TV episodes in my TV folder which is of the collection type tvshows (specified when setting up a collection/library) :) 

 

PlaybackStart "The Son Also Draws" "D:\Media\TV\Family Guy\S01\S01E06 - The Son Also Draws.avi" Anthony Firefox (content type: tvshows) (library name: TV) 
PlaybackStart "1917" "D:\Media\Movies\1917.2019.1080p.BluRay.x264.AAC5.1-[YTS.MX].mp4" Anthony Firefox (content type: movies) (library name: Movies) 
 
PlaybackStop "1917" "D:\Media\Movies\1917.2019.1080p.BluRay.x264.AAC5.1-[YTS.MX].mp4" Anthony Firefox (content type: movies) (library name: Movies) 
PlaybackStop "The Son Also Draws" "D:\Media\TV\Family Guy\S01\S01E06 - The Son Also Draws.avi" Anthony Firefox (content type: tvshows) (library name: TV) 
 
 
I've also updated the configuration interface to reflect the revised item fields ..
 
5e8dbe8115fae_v1001configurationscreen.p

Share this post


Link to post
Share on other sites
PenkethBoy

Shouldn't the content type for playing an episode be  "Episode" not TVshows?

 

Also the Emby Type for a Movie is Movie not Movies

 

What i am trying to get at is it needs to be the same type emby returns in any json for each "Type" which is a field in the Json

1. to be consistent

2. so any script can read the value as is rather than having to translate

 

Thanks again :) 

  • Like 1

Share this post


Link to post
Share on other sites
Anthony Musgrove

Shouldn't the content type for playing an episode be  "Episode" not TVshows?

 

Also the Emby Type for a Movie is Movie not Movies

 

What i am trying to get at is it needs to be the same type emby returns in any json for each "Type" which is a field in the Json

1. to be consistent

2. so any script can read the value as is rather than having to translate

 

Thanks again :)

 

Thank you again mate, I'll look into this now :)

Share this post


Link to post
Share on other sites
Anthony Musgrove

Thank you again mate, I'll look into this no

 

Shouldn't the content type for playing an episode be  "Episode" not TVshows?

 

Also the Emby Type for a Movie is Movie not Movies

 

What i am trying to get at is it needs to be the same type emby returns in any json for each "Type" which is a field in the Json

1. to be consistent

2. so any script can read the value as is rather than having to translate

 

Thanks again :)

 

 

 

I've found these values:

 

 (dbg1: - MediaBrowser.Controller.Entities.Movies.Movie) 

(dbg1: - MediaBrowser.Controller.Entities.TV.Episode) 

 

Found with item.GetType().ToString()  ... so I can take the info from this :)

Share this post


Link to post
Share on other sites
Anthony Musgrove

There we go! 

 

PlaybackStart "1917" "D:\Media\Movies\1917.2019.1080p.BluRay.x264.AAC5.1-[YTS.MX].mp4" Anthony Firefox (item type: Movie) (library content type: movies) (library name: Movies) 
 
PlaybackStart "A Hero Sits Next Door" "D:\Media\TV\Family Guy\S01\S01E05 - A Hero Sits Net Door.avi" Anthony Firefox (item type: Episode) (library content type: tvshows) (library name: TV) 
 


Achieved with:
 
‪D:\embyscripts\test.bat PlaybackStart "%item.name%" "%item.path%" %username% %device.name% (content type: %item.content.type%) (library name: %item.library.name%)
 
 
uploading version 1.0.0.2 to GitHUB now :)

Share this post


Link to post
Share on other sites
PenkethBoy

Cool - that should cover things like photos and books etc as well if you ask for the type each time

 

Thanks

  • Like 1

Share this post


Link to post
Share on other sites
Anthony Musgrove

Cool - that should cover things like photos and books etc as well if you ask for the type each time

 

Thanks

 

Not a problem at all!  It will cover any type of media that triggers any of these conditions :)

Share this post


Link to post
Share on other sites
Anthony Musgrove

Added more functionality - added an 'onScheduledTask':

 

5e8dd5f9396a2_EmbyScripterX_ScheduledTas

 

 

Scheduled Task listing under 'Scheduled Tasks -> Application', where you can schedule it to any interval available:

 

5e8dd6209386a_EmbyScripterX_ScheduledTas

 

And script & output:

 

5e8dd63403931_EmbyScripterX_ScheduledTas

 

I would like some suggestions as to what system parameters, etc that should be available to the onScheduledTask - ie, which tokens should be available, what functionality would you like to see here with this?

 

Thank you!

Share this post


Link to post
Share on other sites
@lex
hello
 
i get this error:
 
Error Emby ScripterX: Error running script : /bin/bash: /opt/emby-server/lib/libc.so.6: version `GLIBC_2.28' not found (required by /bin/bash)

System:

Raspberry Pi 4 Model B with Raspbian Buster
emby 4.4.2.0
ScripterX 1.0.0.2
 
ldd --version shows 
ldd (Debian GLIBC 2.28-10+rpi1) 2.28
i am not a linux expert  :(
 
is this is a bug or what i'm doing wrong
 
greetings @@lex

Share this post


Link to post
Share on other sites
Anthony Musgrove

 

hello
 
i get this error:
 
Error Emby ScripterX: Error running script : /bin/bash: /opt/emby-server/lib/libc.so.6: version `GLIBC_2.28' not found (required by /bin/bash)

System:

Raspberry Pi 4 Model B with Raspbian Buster
emby 4.4.2.0
ScripterX 1.0.0.2
 
ldd --version shows 
ldd (Debian GLIBC 2.28-10+rpi1) 2.28
i am not a linux expert  :(
 
is this is a bug or what i'm doing wrong
 
greetings @@lex

 

 

G'day Lex,

 

This is a great question -- I checked out https://www.circuitbasics.com/how-to-write-and-run-a-shell-script-on-the-raspberry-pi/ and it seems that bash is supported on Raspberry pi.

 

I'd follow this guide, create a bash script on your raspberry pi and try to execute it - see if you get the same error on the command line.

 

Let me know how you go! :) 

Share this post


Link to post
Share on other sites
PenkethBoy
Posted (edited)

Getting this error in the logs on Win10

2020-04-08 15:18:35.168 Info HttpServer: HTTP GET http://192.168.1.56:8096/emby/Plugins/3c96f5bc-4182-4b86-b05d-f730f2611e45/Thumb?maxWidth=401&tag=1. UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36
2020-04-08 15:18:35.171 Error HttpServer: Error processing request
	*** Error Report ***
	Version: 4.5.0.5
	Command line: F:\EmbyCore\system\EmbyServer.dll -noautorunwebapp
	Operating system: Microsoft Windows NT 6.2.9200.0
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Runtime: file:///F:/EmbyCore/system/System.Private.CoreLib.dll
	System.Environment.Version: 3.1.3
	Processor count: 8
	Program data path: F:\EmbyCore\programdata
	Application directory: F:\EmbyCore\system
	System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
	   at Emby.Server.Implementations.HttpServer.FileWriter.SetContentResponseHeaders(Nullable`1 reportedTotalContentLength, CancellationToken cancellationToken)
	   at Emby.Server.Implementations.HttpServer.HttpResultFactory.GetStaticResult(IRequest requestContext, StaticResultOptions options)
	   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: Emby.Server.Implementations
	TargetSite: Void MoveNext()
	
2020-04-08 15:18:35.171 Info HttpServer: HTTP Response 500 to 192.168.1.56. Time: 3ms. http://192.168.1.56:8096/emby/Plugins/3c96f5bc-4182-4b86-b05d-f730f2611e45/Thumb?maxWidth=401&tag=1
2020-04-08 15:18:36.633 Info HttpServer: HTTP GET http://192.168.1.56:8096/emby/Plugins/f11d0c04-e2b1-6445-ae12-b6f2e4c6b2de/Configuration. UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36
2020-04-08 15:18:36.634 Info HttpServer: HTTP Response 200 to 192.168.1.56. Time: 1ms. http://192.168.1.56:8096/emby/Plugins/f11d0c04-e2b1-6445-ae12-b6f2e4c6b2de/Configuration

On accessing the plugin in Emby Gui

 

with version .2 and .3

Edited by PenkethBoy
  • Like 1

Share this post


Link to post
Share on other sites
@lex
Posted (edited)

G'day Lex,

 

This is a great question -- I checked out https://www.circuitbasics.com/how-to-write-and-run-a-shell-script-on-the-raspberry-pi/ and it seems that bash is supported on Raspberry pi.

 

I'd follow this guide, create a bash script on your raspberry pi and try to execute it - see if you get the same error on the command line.

 

Let me know how you go! :)

 

dear Anthony
 
thanks for your quick reply
 
my testscript runs without any error
 
edit:
found a hint
the emby debian armhf images are shipped with the 2.25 lib... thats the "problem"
 
i hope this info is useful for you
Edited by @lex

Share this post


Link to post
Share on other sites
PenkethBoy
Posted (edited)

Ok not sure whats wrong but your plugin is generating errors in emby when an item is added - I might be misunderstanding what it needs.

 

My settings

5e8de4f5be2bd_Annotation20200408154953.j

and

5e8de5057ca39_Annotation20200408154958.j

 

all the rest are blank

 

if i run the script locally - it works

5e8de57470165_Annotation20200408155148.j

and log file created by test.bat

 

5e8de59ba1f63_Annotation20200408155154.j

which is correct

 

But does not work in Emby

 

I get these sorts of errors - e.g. Void execute_call_cmd(System.String)?

2020-04-08 15:42:35.450 Info LibraryMonitor: HomeVid (F:\EmbyTest\HomeVid) will be refreshed.
2020-04-08 15:42:35.588 Info Emby ScripterX: onItemAdded: F:\Video\Test.bat "-Name A Glimpse Of The Future Through An Augmented Reality Headset - Meron Gribetz -ID 38259c25-80f9-72c6-ee40-0d77afd1a506 -Type Folder -LibName Home videos & photos"
2020-04-08 15:42:35.628 Info Emby ScripterX: onItemAdded: F:\Video\Test.bat "-Name A Glimpse Of The Future Through An Augmented Reality Headset - Meron Gribetz -ID e220c930-78fb-6ee8-b399-f6f21b6bdb19 -Type Video -LibName Home videos & photos"
2020-04-08 15:42:35.675 Debug App: Running FolderImageProvider for F:\EmbyTest\HomeVid\A Glimpse Of The Future Through An Augmented Reality Headset - Meron Gribetz
2020-04-08 15:42:35.677 Info Emby ScripterX: onItemUpdated: 
2020-04-08 15:42:35.677 Error App: Error in ItemUpdated event handler
	*** Error Report ***
	Version: 4.5.0.5
	Command line: F:\EmbyCore\system\EmbyServer.dll -noautorunwebapp
	Operating system: Microsoft Windows NT 6.2.9200.0
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Runtime: file:///F:/EmbyCore/system/System.Private.CoreLib.dll
	System.Environment.Version: 3.1.3
	Processor count: 8
	Program data path: F:\EmbyCore\programdata
	Application directory: F:\EmbyCore\system
	System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
	   at EmbyScripterX.ScripterXController.execute_call_cmd(String call_cmd)
	   at EmbyScripterX.ScripterXController._libraryManager_ItemUpdated(Object sender, ItemChangeEventArgs e)
	   at Emby.Server.Implementations.Library.LibraryManager.UpdateItems(List`1 items, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken)
	Source: EmbyScripterX
	TargetSite: Void execute_call_cmd(System.String)
	
2020-04-08 15:42:35.679 Debug App: Running FFProbeProvider for F:\EmbyTest\HomeVid\A Glimpse Of The Future Through An Augmented Reality Headset - Meron Gribetz\A Glimpse Of The Future Through An Augmented Reality Headset - Meron Gribetz.mkv
2020-04-08 15:42:35.679 Info MediaProbeManager: ProcessRun 'ffprobe' Execute: F:\EmbyCore\system\ffprobe.exe -i file:"F:\EmbyTest\HomeVid\A Glimpse Of The Future Through An Augmented Reality Headset - Meron Gribetz\A Glimpse Of The Future Through An Augmented Reality Headset - Meron Gribetz.mkv" -threads 0 -v info -print_format json -show_streams -show_chapters -show_format -show_data
2020-04-08 15:42:35.791 Debug MediaProbeManager: ProcessRun 'ffprobe' Started.
2020-04-08 15:42:35.838 Info MediaProbeManager: ProcessRun 'ffprobe' Process exited with code 0
2020-04-08 15:42:35.846 Info App: ProcessRun 'extract-multi-image' Execute: F:\EmbyCore\system\ffmpeg.exe -f matroska -threads 4 -skip_list 8,300,600 -i file:"F:\EmbyTest\HomeVid\A Glimpse Of The Future Through An Augmented Reality Headset - Meron Gribetz\A Glimpse Of The Future Through An Augmented Reality Headset - Meron Gribetz.mkv" -an -sn -vsync 0 -f image2 "F:\EmbyCore\programdata\cache\temp\c9afa12fc2b84a0f91ee8270411b06d7\img_%05d.jpg"
2020-04-08 15:42:35.959 Debug App: ProcessRun 'extract-multi-image' Started.
2020-04-08 15:42:36.221 Info App: ProcessRun 'extract-multi-image' Process exited with code 0
2020-04-08 15:42:36.466 Debug App: Running VideoNfoProvider for F:\EmbyTest\HomeVid\A Glimpse Of The Future Through An Augmented Reality Headset - Meron Gribetz\A Glimpse Of The Future Through An Augmented Reality Headset - Meron Gribetz.mkv
2020-04-08 15:42:36.468 Debug LibraryMonitor: New file refresher created for F:\EmbyTest\HomeVid\A Glimpse Of The Future Through An Augmented Reality Headset - Meron Gribetz\A Glimpse Of The Future Through An Augmented Reality Headset - Meron Gribetz.nfo
2020-04-08 15:42:36.470 Info Emby ScripterX: onItemUpdated: 
2020-04-08 15:42:36.470 Error App: Error in ItemUpdated event handler
	*** Error Report ***
	Version: 4.5.0.5
	Command line: F:\EmbyCore\system\EmbyServer.dll -noautorunwebapp
	Operating system: Microsoft Windows NT 6.2.9200.0
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Runtime: file:///F:/EmbyCore/system/System.Private.CoreLib.dll
	System.Environment.Version: 3.1.3
	Processor count: 8
	Program data path: F:\EmbyCore\programdata
	Application directory: F:\EmbyCore\system
	System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
	   at EmbyScripterX.ScripterXController.execute_call_cmd(String call_cmd)
	   at EmbyScripterX.ScripterXController._libraryManager_ItemUpdated(Object sender, ItemChangeEventArgs e)
	   at Emby.Server.Implementations.Library.LibraryManager.UpdateItems(List`1 items, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken)
	Source: EmbyScripterX
	TargetSite: Void execute_call_cmd(System.String)
	

If i remove the path to cmd.exe - so the textbox is blank

 

i get 

 

2020-04-08 16:00:34.878 Error Emby ScripterX: Invalid interpreter path, please include the full path.

 

My understanding is that the path to cmd.exe is not needed in windows (win10 in this case) as its on the path variable - so not sure why its need??

 

Same would apply to powershell which is ultimately what i want to use so a simple

 

powershell -command "& F:\videos\ScripterX-test.ps1 -Name %item.name% -ID %item.id% -Type %item.type% -LibName %item.library.name%" - should work also - but currently does not - hence i reverted to a bat file for testing

 

(-Name, -ID etc are just parameters that the test powershell script understand - which is called by the bat file)

 

So hopefully its something simple :)

Edited by PenkethBoy
  • Like 1

Share this post


Link to post
Share on other sites
PenkethBoy

A minor issue - the %item.id% is returning a GUID rather than the item ID (database ID)

 

Info Emby ScripterX: onItemAdded: F:\Video\Test.bat "-Name A Robot That Eats Pollution  Jonathan Rossiter -ID 1c716d01-8165-07c3-cc89-8741a7d815d3 -Type Folder -LibName Home videos & photos"

 

should be

 

Info Emby ScripterX: onItemAdded: F:\Video\Test.bat "-Name A Robot That Eats Pollution  Jonathan Rossiter -ID 46594 -Type Folder -LibName Home videos & photos"

  • Like 1

Share this post


Link to post
Share on other sites
Anthony Musgrove

Thank you for the feedback guys, I'll look into these issues now :)

Share this post


Link to post
Share on other sites
Anthony Musgrove

 

dear Anthony
 
thanks for your quick reply
 
my testscript runs without any error
 
edit:
found a hint
the emby debian armhf images are shipped with the 2.25 lib... thats the "problem"
 
i hope this info is useful for you

 

 

Thank you for this info!  Perhaps @@Luke can shed some light on this - maybe there's an alternative way to reference to bash interpreter on the pi? 

Share this post


Link to post
Share on other sites
Anthony Musgrove

Getting this error in the logs on Win10

2020-04-08 15:18:35.168 Info HttpServer: HTTP GET http://192.168.1.56:8096/emby/Plugins/3c96f5bc-4182-4b86-b05d-f730f2611e45/Thumb?maxWidth=401&tag=1. UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36
2020-04-08 15:18:35.171 Error HttpServer: Error processing request
	*** Error Report ***
	Version: 4.5.0.5
	Command line: F:\EmbyCore\system\EmbyServer.dll -noautorunwebapp
	Operating system: Microsoft Windows NT 6.2.9200.0
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Runtime: file:///F:/EmbyCore/system/System.Private.CoreLib.dll
	System.Environment.Version: 3.1.3
	Processor count: 8
	Program data path: F:\EmbyCore\programdata
	Application directory: F:\EmbyCore\system
	System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
	   at Emby.Server.Implementations.HttpServer.FileWriter.SetContentResponseHeaders(Nullable`1 reportedTotalContentLength, CancellationToken cancellationToken)
	   at Emby.Server.Implementations.HttpServer.HttpResultFactory.GetStaticResult(IRequest requestContext, StaticResultOptions options)
	   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: Emby.Server.Implementations
	TargetSite: Void MoveNext()
	
2020-04-08 15:18:35.171 Info HttpServer: HTTP Response 500 to 192.168.1.56. Time: 3ms. http://192.168.1.56:8096/emby/Plugins/3c96f5bc-4182-4b86-b05d-f730f2611e45/Thumb?maxWidth=401&tag=1
2020-04-08 15:18:36.633 Info HttpServer: HTTP GET http://192.168.1.56:8096/emby/Plugins/f11d0c04-e2b1-6445-ae12-b6f2e4c6b2de/Configuration. UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36
2020-04-08 15:18:36.634 Info HttpServer: HTTP Response 200 to 192.168.1.56. Time: 1ms. http://192.168.1.56:8096/emby/Plugins/f11d0c04-e2b1-6445-ae12-b6f2e4c6b2de/Configuration

On accessing the plugin in Emby Gui

 

with version .2 and .3

 

Thankyou for this info mate - I can't reproduce this one and the plugin GUID that appears to of caused the issue is 3c96f5bc-4182-4b86-b05d-f730f2611e45, which isn't the scripterx, could you please try clearing your browser cache and trying it again? Just for curiosity - because I'm not sure which plugin refers to GUID 3c96f5bc-4182-4b86-b05d-f730f2611e45

Share this post


Link to post
Share on other sites
Anthony Musgrove

A minor issue - the %item.id% is returning a GUID rather than the item ID (database ID)

 

Info Emby ScripterX: onItemAdded: F:\Video\Test.bat "-Name A Robot That Eats Pollution  Jonathan Rossiter -ID 1c716d01-8165-07c3-cc89-8741a7d815d3 -Type Folder -LibName Home videos & photos"

 

should be

 

Info Emby ScripterX: onItemAdded: F:\Video\Test.bat "-Name A Robot That Eats Pollution  Jonathan Rossiter -ID 46594 -Type Folder -LibName Home videos & photos"

 

Thank you for this feedback!  I've fixed this issue:

 

%item.id% now reflects to the correct ID - this was achieved with:

 

‪D:\embyscripts\test.bat PlaybackStart ItemID: %item.id% - Name: "%item.name%" - Path: "%item.path%" - Username: %username% - DeviceName: %device.name% - ItemType: item type: %item.type% - LibraryName: %item.library.name% - LibraryContentType: %item.library.type%

 

 
PlaybackStart ItemID: 593 - Name: "Brian: Portrait of a Dog" - Path: "D:\Media\TV\Family Guy\S01\S01E07 - Brian - Portrait Of A Dog.avi" - Username: Anthony - DeviceName: Firefox - ItemType: item type: Episode - LibraryName: TV - LibraryContentType: tvshows 
PlaybackStop ItemID: 593 - Name: "Brian: Portrait of a Dog" - Path: "D:\Media\TV\Family Guy\S01\S01E07 - Brian - Portrait Of A Dog.avi" - Username: Anthony - DeviceName: Firefox - ItemType: item type: Episode - LibraryName: TV - LibraryContentType: tvshows 
PlaybackStart ItemID: 662 - Name: "1917" - Path: "D:\Media\Movies\1917.2019.1080p.BluRay.x264.AAC5.1-[YTS.MX].mp4" - Username: Anthony - DeviceName: Firefox - ItemType: item type: Movie - LibraryName: Movies - LibraryContentType: movies 
PlaybackStop ItemID: 662 - Name: "1917" - Path: "D:\Media\Movies\1917.2019.1080p.BluRay.x264.AAC5.1-[YTS.MX].mp4" - Username: Anthony - DeviceName: Firefox - ItemType: item type: Movie - LibraryName: Movies - LibraryContentType: movies 
 
Thankyou so much for all your help so far!  This is greatly appreciated!

Share this post


Link to post
Share on other sites
Anthony Musgrove

Added: %series.id%, %series.name%, %season.id%, %season.name% 

 

If Item type is Episode, these tokens are available, if its a movie, it will ignore these tokens - any suggestions/comments/feedback on this is welcome.  I can also have it set these variables to a particular value if the item isn't an episode, for example, if it were a movie, %sseason.name% etc can be set to 'None' or 'NotAnEpisode' or 'Movie' ?  Any feedback welcome!

 

5e8e7d37dacef_ScripterX_Logo_1005.png

 

Eg:

TV Episode:

PlaybackStart ItemID: 593 - Name: "Brian: Portrait of a Dog" - Path: "D:\Media\TV\Family Guy\S01\S01E07 - Brian - Portrait Of A Dog.avi" - Username: Anthony - DeviceName: Firefox - ItemType: item type: Episode - LibraryName: TV - LibraryContentType: tvshows (seriesname: Family Guy) (season: Season 1) 
PlaybackStart ItemID: 593 - Name: "Brian: Portrait of a Dog" - Path: "D:\Media\TV\Family Guy\S01\S01E07 - Brian - Portrait Of A Dog.avi" - Username: Anthony - DeviceName: Firefox - ItemType: item type: Episode - LibraryName: TV - LibraryContentType: tvshows (seriesname: Family Guy) (season: Season 1) 
 
 
Movie: (see how %series.name, %season.name% are not resolved? thats because they don't exist, this is what I'm asking about - if you'd like them set to a default value etc)
PlaybackStart ItemID: 652 - Name: "1917" - Path: "D:\Media\Movies\1917.2019.1080p.BluRay.x264.AAC5.1-[YTS.MX] - Copy.mp4" - Username: Anthony - DeviceName: Firefox - ItemType: item type: Movie - LibraryName: Movies - LibraryContentType: movies (seriesname: %series.name%) (season: %season.name%) 
PlaybackStart ItemID: 652 - Name: "1917" - Path: "D:\Media\Movies\1917.2019.1080p.BluRay.x264.AAC5.1-[YTS.MX] - Copy.mp4" - Username: Anthony - DeviceName: Firefox - ItemType: item type: Movie - LibraryName: Movies - LibraryContentType: movies (seriesname: %series.name%) (season: %season.name%) 
 

Share this post


Link to post
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...