PenkethBoy 2063 Posted May 24, 2020 Share Posted May 24, 2020 Anthony Re the above - see this post from earlier in this thread - as it looks like a similar issue - that i dont think you fixed - or you did not confirm it as being fixed https://emby.media/community/index.php?/topic/84816-new-plugin-custom-scripting-emby-scripterx/?p=869537 An idea - is the call to the interpreter expecting the pwsh process to terminate (complete) within a short timescale and if not - gets hung up - from looking at my emby logs the hang happens in approx 1 second? 1 Link to comment Share on other sites More sharing options...
PenkethBoy 2063 Posted May 24, 2020 Share Posted May 24, 2020 (edited) Ok - have been doing a few tests This is using a direct powershell script (no proxy script) - that runs via the onLibScanComplete event as its easy to initiate So i added a call to the plugin config i.e. testhang - which i added a Start-Sleep event of initially 5 seconds This results in two issues (might be others but these will do for now) 1. No other ScripterX events occur during this sleep period 2. This sleep period also stops anything being logged to the Emby log also Below are some snippets of the two logs - in this case i have added a 50 second sleep so the sleep period is more obvious The Emby Log 2020-05-24 17:39:17.273 Info Emby ScripterX: onLibraryScanComplete: -EventType "LibScanComplete" -ScanDur "00:00:05.1263171" -ScanDays "0" -ScanHours "0" -ScanMins "0" -ScanSecs "5" -ScanLibName "root" -ScripterVersion "2.3.7.0" 2020-05-24 17:39:17.864 Info Emby ScripterX: onLibraryScanComplete: -EventType "testhang" -ScripterVersion "2.3.7.0" 2020-05-24 17:40:08.458 Debug App: Running post-scan task TvdbPrescanTask 2020-05-24 17:40:08.459 Debug App: Running post-scan task ArtistsPostScanTask 2020-05-24 17:40:08.466 Debug App: Running post-scan task GenresPostScanTask My ScripterX log [24/05/2020 17:39:17.658] - EventType: LibScanComplete Library Name: root Scan Duration: 00:00:05.1263171 Scan Duration Days: 0 Scan Duration Hours: 0 Scan Duration Minutes: 0 Scan Duration Seconds: 5 ScripterX: 2.3.7.0 [24/05/2020 17:39:18.281] - UNKNOWN - EventType: testhang ScripterX: 2.3.7.0 [24/05/2020 17:40:08.309] - UNKNOWN - EventType: testhang Sleep for 50 seconds over ScripterX: 2.3.7.0 [24/05/2020 17:40:08.922] - EventType: ItemUpdated Name: Pop Emby ID: 1339 Emby Item Type: MusicGenre Update Reason: None, ImageUpdate ScripterX: 2.3.7.0 [24/05/2020 17:40:09.466] - EventType: ItemUpdated Name: Indie Rock Emby ID: 1346 Emby Item Type: MusicGenre Update Reason: None, ImageUpdate ScripterX: 2.3.7.0 [24/05/2020 17:40:10.382] - EventType: ItemUpdated Name: Rock Emby ID: 1349 Emby Item Type: MusicGenre Update Reason: None, ImageUpdate ScripterX: 2.3.7.0 As i hope you can see both "hang" at 17:39:18 ish for 50 seconds - I can see the pwsh process is idle for that time and no other pwsh process fire until the sleeping one finishes I guess this is because you wait for an event to finish before firing off the next - but the events should not be linked to another finishing And another side effect is that when we send a post to Emby via the script called directly by the plugin - this hangs emby/plugin and makes the situation worse - although i dont know why it hangs on a post event - maybe something else is causng that and we are only seeing it with a post or a script that takes a period of time [edit] - also while the sleep is happening the progress bar on the lib scan task aslo does not update - as mentioned in my previous post Edited May 24, 2020 by PenkethBoy 1 Link to comment Share on other sites More sharing options...
PenkethBoy 2063 Posted May 24, 2020 Share Posted May 24, 2020 i tested a script called directly from the plugin - which does not do any POST back to emby - just a long series of Gets to produce a report this also just hangs after a second or two So POST is not the direct issue - but that any script that takes long the x period of time just hangs - i.e. the process is idle and even leaving it for a minute or two nothing further happens 1 Link to comment Share on other sites More sharing options...
Anthony Musgrove 195 Posted May 25, 2020 Author Share Posted May 25, 2020 Thank you for this feedback guys. I think I know what the hanging issue is. Can you download and test BETA 238 from: https://github.com/AnthonyMusgrove/Emby-ScripterX/tree/master/Beta Note.. Packages is in the interface, but isn't functional yet, so just ignore it. Its just to see if it addresses the hanging issue Thank you 1 Link to comment Share on other sites More sharing options...
PenkethBoy 2063 Posted May 25, 2020 Share Posted May 25, 2020 Anthony Just tested the beta plugin and the hang appears to have been fixed Also notice that multiple pwsh process now run at same time so each is a separate process I have three scripts being fired for one event and they all occur - and they run in "parallel" now So for me from initial testing it appears to be fixed Thanks Link to comment Share on other sites More sharing options...
ginjaninja 533 Posted May 27, 2020 Share Posted May 27, 2020 Hi Anthony, has something changed in the last few versions with ScripterX aggregating tv remove events 'onmediaitemremoved'? When i remove a single episode, its logged as an episode removal but if i remove a season, i only see a season remove event...i thought i used to see the season and all the episode remove events, but i may be imagining it. not necessarily a problem, but just wanted to check if the behaviour is newish / intentional. Link to comment Share on other sites More sharing options...
PenkethBoy 2063 Posted May 27, 2020 Share Posted May 27, 2020 i see the same when removing an album it only has a remove album event - this is not new always been like this from my experience this is an emby thing i suspect i.e. it only notifies the top level item not all the sub items being removed Link to comment Share on other sites More sharing options...
ginjaninja 533 Posted May 27, 2020 Share Posted May 27, 2020 i see the same when removing an album it only has a remove album event - this is not new always been like this from my experience this is an emby thing i suspect i.e. it only notifies the top level item not all the sub items being removed thanks for confirming Link to comment Share on other sites More sharing options...
spaceman07 8 Posted May 28, 2020 Share Posted May 28, 2020 hello.. sorry if this has been asked before.. can i use python scripting with the plugin? Link to comment Share on other sites More sharing options...
Anthony Musgrove 195 Posted May 28, 2020 Author Share Posted May 28, 2020 hello.. sorry if this has been asked before.. can i use python scripting with the plugin? Thats okay, and absolutely you can! In the interpreter, just place the path to your python executable. The script should just specify the path to your python script - then the same, parameters are simply passed to your script, conditions are checked (if any are configured) before it submits to python Link to comment Share on other sites More sharing options...
Anthony Musgrove 195 Posted May 28, 2020 Author Share Posted May 28, 2020 Hi Anthony, has something changed in the last few versions with ScripterX aggregating tv remove events 'onmediaitemremoved'? When i remove a single episode, its logged as an episode removal but if i remove a season, i only see a season remove event...i thought i used to see the season and all the episode remove events, but i may be imagining it. not necessarily a problem, but just wanted to check if the behaviour is newish / intentional. I'll check these out mate I'll have to add them to Github Issues so I can keep track Link to comment Share on other sites More sharing options...
Anthony Musgrove 195 Posted May 28, 2020 Author Share Posted May 28, 2020 The packages interface is coming together nicely, and is almost ready for a new release. Packages will have much more power to script with too, for example, exposing things such as Item Finder, User management etc, all from your javascript code. It's going to really shape the future direction of the Packages side of Scripter X thank you all you're all awesome! Link to comment Share on other sites More sharing options...
ginjaninja 533 Posted May 28, 2020 Share Posted May 28, 2020 Dont know if any one else would find this useful, a power shell logger which logs all parameters dynamically as you change ScripterX parameters. ie anything you add to ScripterX parameters gets added to the log. (i got bored of keeping the two in sync during development/testing) #Generic ScripterX logger [CmdletBinding()] param( [parameter(ValueFromRemainingArguments=$true)] $allscripterxparams ) $LogCSV = "$PSScriptRoot\Log.CSV" #$true/$false - clears the log if the ScripterX parameters are different to log, otherwise new paramters will be truncated $clearlogonheaderchange=$true $logparams = [Ordered]@{} #add some of your own parameters if you wish $now = (Get-Date) $logparams['DateTime'] = $Now #Enumerate parameters into key/value pairs. $allscripterxparams | ForEach-Object { if ($_ -match '^-') { #New parameter $lastvar = $_ -replace '^-' $logparams[$lastvar] = $null } else { #Value $logparams[$lastvar] = $_ } } <# #can still enumerate the parameter keys/values if you wish to code more functionality foreach($key in $logparams.keys) {Write-Host = "$key, $($logparams[$key])"} #$logparams.Username #> #Remove parameters if you dont want them logged #$logparams.remove('id') #Clear log if log headers do not match ScripterX parameters if ((test-path $logcsv) -and ($clearlogonheaderchange)) { $currentlog = import-csv -Path $LogCSV $csvheaders = $currentlog[0].psobject.properties.name #convert to strings so like objects can match $csvheaders = $csvheaders -join "," $currentparams=$logparams.Keys -join "," if ($csvheaders -ne $currentparams) {Clear-Content $logcsv} } #Convert to psobject for ExportCSV New-Object PSObject -property $logparams | Export-Csv -Path $LogCSV -Append -NoTypeInformation -Force 1 Link to comment Share on other sites More sharing options...
Anthony Musgrove 195 Posted May 29, 2020 Author Share Posted May 29, 2020 (edited) Emby Scripter-X version 3.0 (up on the catalog now!) 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: - 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. Edited May 29, 2020 by Anthony.Musgrove 1 Link to comment Share on other sites More sharing options...
PenkethBoy 2063 Posted May 29, 2020 Share Posted May 29, 2020 Hi Anthony looks interesting can you please look at resolving the outstanding issues on github before you add more functionality so we dont have errors/issues in the core of the plugin thats stopping me using it for somethings i want to try and test Thanks Link to comment Share on other sites More sharing options...
Anthony Musgrove 195 Posted June 1, 2020 Author Share Posted June 1, 2020 Hi Anthony looks interesting can you please look at resolving the outstanding issues on github before you add more functionality so we dont have errors/issues in the core of the plugin thats stopping me using it for somethings i want to try and test Thanks Absolutely mate thank you for the feedback ive added a changelog in the plugin interface its self to make it easier to track the issues once they've been implemented or resolved too 1 Link to comment Share on other sites More sharing options...
reneboulard 30 Posted June 2, 2020 Share Posted June 2, 2020 I been playing around with the plugin, it is most interesting and powerfull. I use emby as a PVR. My media library are shows and movies been recorded over the last few years. I process the recording with a postprocessing script. However some of the action must be done by hand since emby just send the path of the file to the postprocessing script. I process the recordings differently if the are Movies, Series, News, Kids or Sports. I could use the "onLiveTVRecordingEnded" call of Emby-ScripterX to acheive better result, if additionnal information was available to my script. Those information are available in Emby EPG and could be passed as parameters, they are : IsMovie, IsSeries, IsNews, IsKids and IsSports. Is it possible to add those to the "onLiveTVRecordingEnded" call. This is the way I process recording : Movies - I run comskip, cut commercial and run Hanbrake. Series - I run Handbrake News and Sports - I do nothing since they are erased after been watched Kids movies and Series are moved to separate libraries. Handbrake setting are different for Movies, Series and Kids Thank you for your help 1 Link to comment Share on other sites More sharing options...
Anthony Musgrove 195 Posted June 2, 2020 Author Share Posted June 2, 2020 I been playing around with the plugin, it is most interesting and powerfull. I use emby as a PVR. My media library are shows and movies been recorded over the last few years. I process the recording with a postprocessing script. However some of the action must be done by hand since emby just send the path of the file to the postprocessing script. I process the recordings differently if the are Movies, Series, News, Kids or Sports. I could use the "onLiveTVRecordingEnded" call of Emby-ScripterX to acheive better result, if additionnal information was available to my script. Those information are available in Emby EPG and could be passed as parameters, they are : IsMovie, IsSeries, IsNews, IsKids and IsSports. Is it possible to add those to the "onLiveTVRecordingEnded" call. This is the way I process recording : Movies - I run comskip, cut commercial and run Hanbrake. Series - I run Handbrake News and Sports - I do nothing since they are erased after been watched Kids movies and Series are moved to separate libraries. Handbrake setting are different for Movies, Series and Kids Thank you for your help Absolutely mate, I will add these this evening! I'm just finishing up the new Email Notifications plugin, and then I'll release a new version with all these included!, I'll reply to this thread once I've released it! Link to comment Share on other sites More sharing options...
Anthony Musgrove 195 Posted June 2, 2020 Author Share Posted June 2, 2020 @reneboulard Thank you so much for your feedback by the way, it is so very much appreciated as is everyone's feedback! I've added the requested tokens for you to Live TV recordings, just update to the latest version in the Emby Catalog v3.0.2 Link to comment Share on other sites More sharing options...
reneboulard 30 Posted June 2, 2020 Share Posted June 2, 2020 Absolutely mate, I will add these this evening! I'm just finishing up the new Email Notifications plugin, and then I'll release a new version with all these included!, I'll reply to this thread once I've released it! Thank you, will look forward to the added feature and make use of it. I will be able to have much simplier postprocessing script and reduce manual processing of media file. 1 Link to comment Share on other sites More sharing options...
Anthony Musgrove 195 Posted June 3, 2020 Author Share Posted June 3, 2020 (edited) Good afternoon guys, I hope everyone is well! Please see updated release today, v3.0.3 on the Plugin catalog; Introduced Email ability for Actions: v3.0.3General* Added ability to send an email using Actions. To do this, use the following configuration:Run [script] = server=smtp.server.host:smtp.port;fromname=My Emby Server;from=myservers@email.address;to=recipient@email.address;subject=My mail subject;auth=mysmtpauthusername:mysmtpauthpassword;ignorecertificate=falseUsing [interpreter] = either smtp or smtp:secure (smtp:secure will use SSL, where as smtp will not)[Parameters] = email body NOTE: You can omit auth= section and it will not use Authentication, you can omit ignorecertificate=false if you want it to be false, ignorecertificate=true will ignore SSL certificate errors, which comes in handy when you're using a self-signed ssl certificate on your own mail server, etc. Example: Send an email when somebody fails to authenticate to your emby server:[script]: server=mail.gmail.com:465;fromname=%server.name%;from=sender@gmail.com;to=recipient@gmail.com;subject=Authentication Failure;auth=mygmail@email.address:myGmAiLpAsSwoRd;ignorecertificate=false[using]: smtp:secure[parameters]: Device %device.name% failed to authenticate from %device.remote.ipaddress% using username: %username%, password: %password%Which yields an email that appears like the following:Device Firefox failed to authenticate from 192.168.1.124 using username: Anthony, password: fakePasSWoRd! Edited June 3, 2020 by Anthony.Musgrove Link to comment Share on other sites More sharing options...
Anthony Musgrove 195 Posted June 3, 2020 Author Share Posted June 3, 2020 And now currently working on a more mouse-driven actions interface Link to comment Share on other sites More sharing options...
@lex 2 Posted June 3, 2020 Share Posted June 3, 2020 hey anthony can you add onBeforePlaybackStart? i need to send a WOL Package to my fileserver for some files greetings @@lex 1 Link to comment Share on other sites More sharing options...
Anthony Musgrove 195 Posted June 4, 2020 Author Share Posted June 4, 2020 (edited) Hey lex, would this work in your use case? OnPlaybackStart -> pause playback -> send your WOL Package and wait for response -> resume play Edited June 4, 2020 by Anthony.Musgrove Link to comment Share on other sites More sharing options...
@lex 2 Posted June 4, 2020 Share Posted June 4, 2020 Unfortunately not because OnPlaybackStart don't fire before playback has really started emby webhook triggers also to late Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now