Jump to content

Recommended Posts

Posted
8 minutes ago, TMCsw said:

You would think so, but I have found that running command lines in ScripterX to be more trouble then it's  worth, instead it's much better to launch a shell script...

But first you may not be using the right parameters in scripterX:

lets' say the following file is being processed  "/mnt/rec/TV Series/SD/Alice (1976)/Season 01/Alice (1976) - S01E01 - Pilot.ts"

  %item.name% or %recording.name% will simply give you:

Pilot 

while %item.path% or %recording.path% will give you the full file path/name:

/mnt/rec/TV Series/SD/Alice (1976)/Season 01/Alice (1976) - S01E01 - Pilot.ts

but this can/will cause a problem if you don't put the parameter in quotes ("") (as spaces will make it look like many parameter's instead of just one or some characters like "(" will get interpreted as special directives instead of plain characters)

so use "%item.path%" or "%recording.path%" to pass the full path/file to the script

so try this (or similar):

image.thumb.png.305290fb6a9d5afe774b16738bd5eca5.png

where: /home/tmc/bin/btest (or similar) contains:

#!/bin/bash

touch /tmp/"$(basename "${1}")"
## OR (but not both as it will just do the same twice) ##
touch /tmp/"${1##*/}"

Also NOTE: Linux permissions apply as always!

And NOTE: the directory /tmp has a sticky bit too!

Amazing, that worked. Thank you. So at least now I know it will work.

 

Now I need to learn enough about bash scripting to get the second image, the actual item I wanted to trigger off to work, as the touch was just the simplified test I was trying to get to work when I couldn't get comskip to run successfully.

 

Thank you for your assistance in helping me prove that Scripter-X was actually working with my emby install.

Posted

Hint: xx.shell contains

#!/bin/bash

</path/to/comskip>/comskip --ini="<path>/whatever.ini" --threads=1 "${1}"

image.thumb.png.69d40da1cfbe3fc0dd39f53c3d2add7d.png

  • Like 1
Posted

Thank you, extremely appreciated.

  • Thanks 1
rbjtech
Posted (edited)
7 hours ago, TMCsw said:

You would think so, but I have found that running command lines in ScripterX to be more trouble then it's  worth, instead it's much better to launch a shell script...

But first you may not be using the right parameters in scripterX:

lets' say the following file is being processed  "/mnt/rec/TV Series/SD/Alice (1976)/Season 01/Alice (1976) - S01E01 - Pilot.ts"

  %item.name% or %recording.name% will simply give you:

Pilot 

while %item.path% or %recording.path% will give you the full file path/name:

/mnt/rec/TV Series/SD/Alice (1976)/Season 01/Alice (1976) - S01E01 - Pilot.ts

but this can/will cause a problem if you don't put the parameter in quotes ("") (as spaces will make it look like many parameter's instead of just one or some characters like "(" will get interpreted as special directives instead of plain characters)

so use "%item.path%" or "%recording.path%" to pass the full path/file to the script

so try this (or similar):

image.thumb.png.305290fb6a9d5afe774b16738bd5eca5.png

where: /home/tmc/bin/btest (or similar) contains:

#!/bin/bash

touch /tmp/"$(basename "${1}")"
## OR (but not both as it will just do the same twice) ##
touch /tmp/"${1##*/}"

Also NOTE: Linux permissions apply as always!

And NOTE: the directory /tmp has a sticky bit too!

Yep - my examples above show the same - put fields with spaces in quotes - pretty normal practice for scripting in any OS.

@Anthony Musgrove

I think this highlights my earlier point about having some EXAMPLES on a wiki type support page.

If people are not used to scripting in their OS - then the concept of passing parameters/variables into the OS will stop Scripter-X being useful.

I guess we now have examples on Windows/Batch/CMD,   now we have /bin/Bash 

I'll look into powershell - but I suspect that it's the param function - just assign as many as you need to get the values into the PS script.

param(
[string]$a
)

Write-Host $a

Having useful examples for all of the different types in a Wiki would be good ... ;)

image.png.78e2611bacc32f8da48fd41828a3fd18.png

 

 

 

Edited by rbjtech
  • 1 month later...
Posted

I have been trying to add a new configuration and have ran into a problem.  When I try to drag items down in a similar way a show below it will not allow me to do so, instead a red circle with an X through it appears.  I seem to recall it working fine previously but it has been some time since I configured it originally.  I am sure it is user error.  Any help is appreciated!

 

Thanks

 

Scratchpad_v234.thumb.png.a68d7c40b6126ac1ea72e095c603c408.png

waldo1985
Posted

It would be nice to run a script when Emby starts and when any plugin is updated? its that possible? Or Emby doesn't have an API for that?

scott46953
Posted

For those using script x for comskip or commercial skip plug in,, I found it much better to uninstall all that from the server.  Instead use a program called MceBuddy, paid version.. It comes with comskip, however I use the donater version of comskip for accelerated performance.  MCE buddy has everything you need to integrate with emby server.  It watches the record folder for new recordings, then it checks the internet corrects any in correction of the file name and season/episode number, corrects the file name, removes the commercials, saves the file back, saves space. On a 6 TB drive I saved almost 1.7 TB 🙂 if anybody's interested or has trouble with settings, they are found with quick Google search, but feel free to ask question or PM me.:-):-) no more server hangs, no more buffering, no more needs to restart server to keep it running properly. 

 

  • Disagree 1
  • 3 weeks later...
Posted

Hi all,

Would like some help as I don't spot the issue myself...

I'd like to use ScripterX to control some automation at home, and I create a bash script that sends HTTP requests to my home automation system. Below is "EmbyPlay.sh"

 script:

#!/bin/bash
curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "ON" "10.1.x.x:8081/rest/items/Emby_Office_Play"
curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d ""$1"" "10.1.x.x:8081/rest/items/Emby_Office_MediaType" 

I have given the permission to the script, and it also works when I run it. Essentially the script send post request to 2 endpoints to inform playback starts with the media type as parameter.

Below is how I configure in GUI:

image.thumb.png.b67526295b28757f611c8bdd95615dfc.png

In emby log I can see the following when playback starts:

2024-08-15 20:38:48.236 Info Emby ScripterX: 2e9a4b73-def3-47ba-850e-1dfeb661b406: Executing with substituted tokens: Movie
2024-08-15 20:38:48.236 Info Emby ScripterX: onPlaybackStart: Movie

However the script doesn't seem to run for some reason, and I don't see any error in emby log. I'm running Emby on my NAS based on Linux.  I must be blind and missed something obvious, maybe somebody can point out?

I also noticed there is an action called "web.post", doesn't anyone have an example how it works? I tried to looked for here (https://github.com/AnthonyMusgrove/Emby-ScripterX/tree/master/Beta) without luck.. Thank you in advance!

  • 1 month later...
GavinCampbell
Posted
On 8/15/2024 at 2:57 PM, somy said:

However the script doesn't seem to run for some reason, and I don't see any error in emby log. I'm running Emby on my NAS based on Linux.  I must be blind and missed something obvious, maybe somebody can point out?

Was having a similar issue.  Looks like curl does not work in the scripterx environment.  I was trying to do a curl delete and finally was able to get my script to output the curl errors.

I had to convert my script to use an nc workaround but I have a more complicated script that I don't know what I'm going to do with.  This use to work until recently.

Hopefully one day it can be enabled again.

 

 

  • 2 weeks later...
Ilicitano81
Posted
On 7/21/2024 at 7:31 PM, KeithA said:

I have been trying to add a new configuration and have ran into a problem.  When I try to drag items down in a similar way a show below it will not allow me to do so, instead a red circle with an X through it appears.  I seem to recall it working fine previously but it has been some time since I configured it originally.  I am sure it is user error.  Any help is appreciated!

 

Thanks

 

Scratchpad_v234.thumb.png.a68d7c40b6126ac1ea72e095c603c408.png

Yes, the same thing happens to me

  • 1 month later...
danielromerohn
Posted

@Antonio MusgroveHi sir.   Can I use your plugin to make it so that every time a new device logs in it forces backdrops to be enabled, and also to sort the libraries in descending order of addition date?

Sincerely....

  • 3 weeks later...
Posted

@Anthony MusgroveI am looking for a way to notify me when my schedule task for Refreshing my Guide for live TV takes less than 30 seconds to complete.  This tells me that there is an issue with the guide data that I need to intervene.  Thank you in advance for your time. 

  • 5 weeks later...
Posted (edited)

Hello everyone,

I am trying to user ScripterX to get information out of Emby to my OpenHAB home automation.
Unfortunately there is no way to drag&drop any of the items to create rules.

As described by KeithA and also confirmed by Ilicitano81 only red X appears and won't let me drop anything as shown in the attached screenshot.

I tried all possible browser with and without private tabs / adblocker / script blocker but it doesnt want to work.

I am using Uptodate Emby Server 4.8.10.0 with ScripterX 5.0.0.5. 

2025-01-03 08_47_45-Scripter-X → Actions - Vivaldi.png

Edited by 3agle3ye
Posted
15 hours ago, 3agle3ye said:

Hello everyone,

I am trying to user ScripterX to get information out of Emby to my OpenHAB home automation.
Unfortunately there is no way to drag&drop any of the items to create rules.

As described by KeithA and also confirmed by Ilicitano81 only red X appears and won't let me drop anything as shown in the attached screenshot.

I tried all possible browser with and without private tabs / adblocker / script blocker but it doesnt want to work.

I am using Uptodate Emby Server 4.8.10.0 with ScripterX 5.0.0.5. 

2025-01-03 08_47_45-Scripter-X → Actions - Vivaldi.png

Unfortunately you will have to type them in manually but if you get the syntax right it will work  ...

Posted
7 hours ago, TMCsw said:

Unfortunately you will have to type them in manually but if you get the syntax right it will work  ...

Yes ... tried that already ... as the condition field is not a text field on my browsers this will not work.
And i need that field to have only one user (the one on my living room tv) starting the scripts so my home automation can recognize which media type is running and setup the sound system and light accordingly.

The parameters field of course can be filled manually.

 

Posted
16 hours ago, 3agle3ye said:

Yes ... tried that already ... as the condition field is not a text field on my browsers this will not work.

Guess your right, just tried again this isn't working any more @Anthony Musgrove

  • 1 month later...
DistractedDad
Posted
On 1/14/2024 at 11:59 PM, Anthony Musgrove said:

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


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

 

Kindest regards,

Anthony

Hi Anthony,

I'm also experiencing this Newtonsoft error.  My Emby version is 4.8.10.0 and my ScripterX version is 5.0.0.5.  I'm running Emby via a very simple Docker Compose config using the "emby/embyserver" image.  Any suggestions as to what to try next?

2025-02-07 01:57:14.980 Error App: Error running postscan task
     *** Error Report ***
     Version: 4.8.10.0
     Command line: /system/EmbyServer.dll -programdata /config -ffdetect /bin/ffdetect -ffmpeg /bin/ffmpeg -ffprobe /bin/ffprobe -restartexitcode 3
     Operating system: Linux version 6.8.0-45-generic (buildd@lcy02-amd64-115) (x86_64-linux-gnu-gcc-13 (Ubuntu 13.2.0-23ubuntu4) 13.2.0, GNU ld (GNU Binutils for Ubuntu) 2.
     Framework: .NET 6.0.31
     OS/Process: x64/x64
     Runtime: system/System.Private.CoreLib.dll
     Processor count: 4
     Data path: /config
     Application path: /system
     System.IO.FileNotFoundException: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.

     File name: 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
        at EmbyScripterX.Core.ScripterXEventContext.getTemplate_substituteTokens(String template_contents, Boolean jsonSafe)
        at EmbyScripterX.Core.ScripterXEventContext.ProcessWeb(String method)
        at EmbyScripterX.Core.ScripterXEventContext.Process(EmbyScripterXAction withAction)                                                                                                          at EmbyScripterX.ScripterXPostLibraryScanController.ProcessPostLibraryScan(Boolean was_cancelled)
        at EmbyScripterX.ScripterXPostLibraryScanController.Run(IProgress`1 progress, CancellationToken cancellationToken)
        at Emby.Server.Implementations.Library.LibraryManager.RunPostScanTasks(IProgress`1 progress, IDirectoryService directoryService, CancellationToken cancellationToken)                     Source: EmbyScripterX
     TargetSite: System.String getTemplate_substituteTokens(System.String, Boolean)

 

scott46953
Posted

Did you look to see if that file was in the folder? If not, why not just add the file? 

I have moved from Android to Windows back to Android then I moved it to Linux and then back to Windows. 

Each time I just copied all the files and moved them over. However this has been several years ago, I did not experience any issues or at least anything major that I can even remember. Oh I did was install it on the system, went to the current rank system copied all the files and then copied it to the system that I wanted to run on.

Each time was a success.  😜 

Surely that's all you need to do with this file if it's missing, find a version that has the file that you need and copy it directly to the folder and then it resides in.  If it's a file that doesn't come with the server on an install, you may have to add the appropriate plugin to get the file. 

What's awesome makes me think that that file may also come with another plugin if that's the case just need to find a plug-in that adds that file.  However I'm not ran into this direct issue your having. But just thought I'd give you some ideas.

Posted
On 1/3/2025 at 5:50 PM, 3agle3ye said:

Hello everyone,

I am trying to user ScripterX to get information out of Emby to my OpenHAB home automation.
Unfortunately there is no way to drag&drop any of the items to create rules.

As described by KeithA and also confirmed by Ilicitano81 only red X appears and won't let me drop anything as shown in the attached screenshot.

I tried all possible browser with and without private tabs / adblocker / script blocker but it doesnt want to work.

I am using Uptodate Emby Server 4.8.10.0 with ScripterX 5.0.0.5. 

2025-01-03 08_47_45-Scripter-X → Actions - Vivaldi.png

Sadly still doesn't work, you can only modify an existing text based variable.
The biggest thing I miss from Plex to Emby was Tautulli.

  • 1 month later...
Posted (edited)

HI.

I read a lot from forum but don't know still how to do.

I want to run a script (which update my watcharr (self hosted watchlist) database with watched status).

If it is not workable, it is also ok if the script runs after every onMediaItemUpdated!.

I don't have any restriction. Just to run on every update (OR after media stopped and wathced more then 80% )

SO i went to Emby Scripter-X → Actions >>>onMediaItemUpdated >>>> RUN /nas/....../watcharr.sh    using bin/bash >> I thinnk that this should be enough.
But nothing happend. 
(Emby is in docker container)

.sh contain: 

#!/bin/bash

python3 /nas/Kodi/EMBY/EmbySync/EmbySync.py



In log i see:
 

"

025-03-11 16:34:55.015 Info Emby ScripterX: onMediaItemUpdated:

2025-03-11 16:34:55.020 Info Emby ScripterX: 593acf61-89**********************6184: Executing with substituted tokens:

2025-03-11 16:34:55.020 Info Emby ScripterX: onMediaItemUpdated:

2025-03-11 16:34:55.065 Info Emby ScripterX: 593acf*************************6184: Executing with substituted tokens:

2025-03-11 16:34:55.065 Info Emby ScripterX: onMediaItemUpdated:

"

 

Thanks

 

Edited by shummo
  • 2 weeks later...
Anthony Musgrove
Posted

Hey guys!  Just letting you know that I am currently working on getting the plugin updated to align with the latest emby server, including repairing draggable functionality etc.

 

Will keep you updated!  :)

  • Like 2
Posted
1 hour ago, Anthony Musgrove said:

Hey guys!  Just letting you know that I am currently working on getting the plugin updated to align with the latest emby server, including repairing draggable functionality etc.

 

Will keep you updated!  :)

Perfect, thank you very much. 

Anthony Musgrove
Posted

 

Hey @Luke  / Emby Dev Team


Could I please get some dev advice regarding the following:

The draggable/sortable JS has stopped working since javascript code isn't being called in the .html page of the configuration; eg

originally I would hook into the following (in actions.html):   on('pageinit'), on('pageshow'), and I'd be able to reference to that individual page using 'this', and all would be fine (parents etc) (please see example 1).  However I have found that javascript at this level/in the html files isn't called any longer, and I've had to hook into 'viewshow' in the scripterx_actions.js;  eg please see example 2 below.  The issue then lies in that the view is passed to the javascript functions, and no longer is a page object, so I am assuming here that everything becomes orphaned. Could you please confirm if we can still use pageinit/pageshow, and how else would I do this?

 

Thank you, 

Anthony

 

Example 2:  (the new method)

        view.addEventListener('viewshow', function (e) {
            mainTabsManager.setTabs(this, scripterx_getTabIndex("actions"), scripterx_getTabs);

            get_scripterx_css(this, '.pluginConfigurationPage');
            ApiClient.loadActions(this);

        });

 

Example 1:  (the original method)

                $('.ScripterXActionsConfigurationPage').on('pageinit', function (event) {

                    var page = this;

                    Dashboard.showLoadingMsg();

                    get_scripterx_css(page, '.pluginConfigurationPage');

                    loadActions(page);

                    Dashboard.hideLoadingMsg();

                }).on('pageshow', function (event) {

                    Dashboard.showLoadingMsg();

                    var page = this;

                    Dashboard.hideLoadingMsg();
                });
 

 

 

 

 

mickle026
Posted

@Anthony Musgrove

Take a look at how I am doing it and see if it helps

This is the JS for one of my plugins
 

                    page.addEventListener('beforeunload', function (event) {
                        LoadPage();
                        ResizeTextArea();
                    });

                    page.addEventListener('unload', function (event) {
                        LoadPage();
                        ResizeTextArea();
                    });

                    page.addEventListener('popstate', function (event) {
                        LoadPage();
                        ResizeTextArea();
                    });

                    page.addEventListener('hashchange', function () {
                        LoadPage();
                        ResizeTextArea();
                    });

                    page.querySelectorAll('a').forEach(link => {
                        link.addEventListener('click', function (event) {
                            const href = link.getAttribute('href');
                            if (href && href.startsWith('configurationpage')) {
                                // Prevent default behavior
                                event.preventDefault();

                                // Call LoadPage directly within the click handler
                                LoadPage();

                                // Optionally, manually update the URL
                                // page.history.pushState({}, '', link.getAttribute('href'));
                            }
                        });
                    });

                    page.addEventListener('pageshow', function (event) {
                        if (event.persisted) {
                            LoadPage();
                            ResizeTextArea();
                        } else {
                            LoadPage();
                            ResizeTextArea();
                        }
                    });

This ensures the page is re-loaded from any event and the JS still works even in the 3 cached versions by the browser when 1 or 2 go inactive

ConvertM3UVodsToSTRMS.js

Posted
10 hours ago, Anthony Musgrove said:

 

Hey @Luke  / Emby Dev Team


Could I please get some dev advice regarding the following:

The draggable/sortable JS has stopped working since javascript code isn't being called in the .html page of the configuration; eg

originally I would hook into the following (in actions.html):   on('pageinit'), on('pageshow'), and I'd be able to reference to that individual page using 'this', and all would be fine (parents etc) (please see example 1).  However I have found that javascript at this level/in the html files isn't called any longer, and I've had to hook into 'viewshow' in the scripterx_actions.js;  eg please see example 2 below.  The issue then lies in that the view is passed to the javascript functions, and no longer is a page object, so I am assuming here that everything becomes orphaned. Could you please confirm if we can still use pageinit/pageshow, and how else would I do this?

 

Thank you, 

Anthony

 

Example 2:  (the new method)

        view.addEventListener('viewshow', function (e) {
            mainTabsManager.setTabs(this, scripterx_getTabIndex("actions"), scripterx_getTabs);

            get_scripterx_css(this, '.pluginConfigurationPage');
            ApiClient.loadActions(this);

        });

 

Example 1:  (the original method)

                $('.ScripterXActionsConfigurationPage').on('pageinit', function (event) {

                    var page = this;

                    Dashboard.showLoadingMsg();

                    get_scripterx_css(page, '.pluginConfigurationPage');

                    loadActions(page);

                    Dashboard.hideLoadingMsg();

                }).on('pageshow', function (event) {

                    Dashboard.showLoadingMsg();

                    var page = this;

                    Dashboard.hideLoadingMsg();
                });
 

 

 

 

 

Example 2 looks good, but where are you doing it from?

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...