Jump to content

New Plugin - Custom Scripting | Emby ScripterX


Anthony Musgrove

Recommended Posts

Anthony Musgrove

And there we go.

 

TV Recording START for Kidnapped: The Hannah Anderson Story to
TV Recording STOP for Kidnapped: The Hannah Anderson Story to /home/medius/media/recordings/Kidnapped The Hannah Anderson Story/Kidnapped The Hannah Anderson Story 2020_04_26_00_26_00.ts
  • Like 1
Link to comment
Share on other sites

Anthony Musgrove

I don't think so mate, I can release this one up on the catalog.  I'm just trying to get Channel Information for the recording too, 

 

so things like %channel.id%, %channel.name%, etc -- like network name, but I'll release this one as-is as v2.1.4 

  • Like 1
Link to comment
Share on other sites

Anthony Musgrove

Its now updated in the catalog :)

 

(And I've also updated GitHub, readme shows the two new Events with their parameters available too)

Edited by Anthony.Musgrove
  • Like 1
Link to comment
Share on other sites

ginjaninja

One more thing, if you check out the custom scripting features in Plex, (plugin) they have configurable conditions too, check out:

 

https://github.com/Tautulli/Tautulli-Wiki/wiki/Custom-Notification-Conditions

 

So for example, on an Action, there could be a dropdown area for 'Conditions' where :-

 

On <event> WHERE <conditions> ... Then run this Action ..

 

for example... onPlaybackStart WHERE Media Item is in particular library etc.

 

What do you think - should I be looking at that too?

 

Thank you again mate :)

 

i am not confident with powershell yet, so conditions in the ui sound good to me.

  • Like 1
Link to comment
Share on other sites

Anthony Musgrove

Got the Channel Information for the recording event too.  So after I release this next update, it will have all these available: (Needs to be checked, as some of these values are blank)

 

 Parameters: %recording.id%, %recording.program.id%, %recording.channel.id%, %recording.date.start%, %recording.name%, %recording.path%, %recording.date.end%, %recording.episode.number%, %recording.episode.title%, %recording.prepadsecs%, %recording.postpadsecs%, %recording.season.number%, %recording.series.id%, %recording.show.id%, %recording.productionyear%, %recording.channel.affiliatecallsign%, %recording.channel.callsign%, %recording.channel.type%, %recording.channel.name%, %recording.channel.number%

  • Like 1
Link to comment
Share on other sites

PenkethBoy

Hi Anthony

 

Just testing out the new recording events

EventType: RecordingEnded Recording Name: Britain's Got Talent Channel ID: 103 Start Date: 26/04/2020 11:35:00 +00:00 End Date: 26/04/2020 12:50:00 +00:00 Channel Name: ITV HD Channel Type: TV Channel Call Sign:  Channel Affiliate Call Sign: 
EventType: RecordingEnded Recording Name: Inspector Morse Channel ID: 10 Start Date: 26/04/2020 10:35:00 +00:00 End Date: 26/04/2020 12:50:00 +00:00 Channel Name: ITV3 Channel Type: TV Channel Call Sign:  Channel Affiliate Call Sign: 

Noticed a couple of things

1. The StartDate and EndDate are in UTC and not local time - i.e. should be 13:50 not 12:50

2. Could we lose the + 00:00 as when the times are correct would not be needed

3. Getting nothing for Call Sign or Affiliate Call Sign - not sure if this is because i'm using UK Terrestrial TV and its more an American thing? - not a big problem as will probably not use it :)

 

Question re Channel Type - if i was using IPTV would it show that or is it always going to be "TV" ?

 

Thanks

  • Like 1
Link to comment
Share on other sites

PenkethBoy

Could we have Tuner Type for the recording events please

{
    "Id": "4618d6cc6f134dc084e182bf7fcc847a",
    "Type": "hauppauge",
    "DeviceId": "1",
    "FriendlyName": "WinTV-dualHD",
    "ImportFavoritesOnly": false,
    "AllowHWTranscoding": true,
    "TunerCount": 1
  },
  {
    "Id": "80b81187b4f3458aae40a5f948d63844",
    "Type": "hauppauge",
    "DeviceId": "2",
    "FriendlyName": "WinTV-dualHD",
    "ImportFavoritesOnly": false,
    "AllowHWTranscoding": true,
    "TunerCount": 1
  },
  {
    "Id": "b51d55cdf2804207903aa9838d04974d",
    "Type": "hauppauge",
    "DeviceId": "3",
    "FriendlyName": "WinTV-dualHD",
    "ImportFavoritesOnly": false,
    "AllowHWTranscoding": true,
    "TunerCount": 1
  }

or 

{
    "Id": "d9169dd0a5494c8dbf1d762bcec752f8",
    "Url": "http://192.168.1.30",
    "Type": "hdhomerun",
    "DeviceId": "12314435",
    "FriendlyName": "HDHomeRun CONNECT",
    "ImportFavoritesOnly": false,
    "AllowHWTranscoding": false,
    "TunerCount": 0
  },
  {
    "Id": "dddd6c060150462a83867cb0946a6a64",
    "Url": "F:\\EmbyTest\\Tuner\\HDHomeRun.m3u",
    "Type": "m3u",
    "FriendlyName": "M3U Tuner",
    "ImportFavoritesOnly": false,
    "AllowHWTranscoding": false,
    "TunerCount": 0
  }

as examples of whats shown via the API for my tuners

 

Friendly Name would be nice as well :)

 

Thanks

  • Like 1
Link to comment
Share on other sites

PenkethBoy

 

 

Question re Channel Type - if i was using IPTV would it show that or is it always going to be "TV" ?

 

Thanks

Comes back as TV also when using a M3U tuner for IPTV - no a problem

Link to comment
Share on other sites

PenkethBoy

When an item gets updated which is "global" rather than part of a library e.g. genres and studios

 

Scripter returns the %item.library.name%

ItemUpdated Name: Romance Emby ID: 2987 Emby Item Type: Genre Emby Library: %item.library.name% Update Reason: None, ImageUpdate
ItemUpdated Name: Motorcycle racing Emby ID: 79395 Emby Item Type: Genre Emby Library: %item.library.name% Update Reason: None
ItemUpdated Name: Animation Emby ID: 80655 Emby Item Type: Genre Emby Library: %item.library.name% Update Reason: None, ImageUpdate
ItemUpdated Name: ITV1 Emby ID: 77888 Emby Item Type: Studio Emby Library: %item.library.name% Update Reason: None, ImageUpdate
ItemUpdated Name: Disney+ Emby ID: 80656 Emby Item Type: Studio Emby Library: %item.library.name% Update Reason: None

Just trying to understand if intended or not so can deal with "missing data" situations

  • Like 1
Link to comment
Share on other sites

ginjaninja

Antony what api call do you use to get the file system location for a series root [eg for a given ID]. eg return D:\TV2\Lost for lost's ID. i cant seem to find it in swagger, i can use /Items/{Id}/PlaybackInfo for a media file eg S01E01 and work it out from there but i presume there is a better way?

thanks

Link to comment
Share on other sites

Anthony Musgrove

Could we have Tuner Type for the recording events please

{
    "Id": "4618d6cc6f134dc084e182bf7fcc847a",
    "Type": "hauppauge",
    "DeviceId": "1",
    "FriendlyName": "WinTV-dualHD",
    "ImportFavoritesOnly": false,
    "AllowHWTranscoding": true,
    "TunerCount": 1
  },
  {
    "Id": "80b81187b4f3458aae40a5f948d63844",
    "Type": "hauppauge",
    "DeviceId": "2",
    "FriendlyName": "WinTV-dualHD",
    "ImportFavoritesOnly": false,
    "AllowHWTranscoding": true,
    "TunerCount": 1
  },
  {
    "Id": "b51d55cdf2804207903aa9838d04974d",
    "Type": "hauppauge",
    "DeviceId": "3",
    "FriendlyName": "WinTV-dualHD",
    "ImportFavoritesOnly": false,
    "AllowHWTranscoding": true,
    "TunerCount": 1
  }

or 

{
    "Id": "d9169dd0a5494c8dbf1d762bcec752f8",
    "Url": "http://192.168.1.30",
    "Type": "hdhomerun",
    "DeviceId": "12314435",
    "FriendlyName": "HDHomeRun CONNECT",
    "ImportFavoritesOnly": false,
    "AllowHWTranscoding": false,
    "TunerCount": 0
  },
  {
    "Id": "dddd6c060150462a83867cb0946a6a64",
    "Url": "F:\\EmbyTest\\Tuner\\HDHomeRun.m3u",
    "Type": "m3u",
    "FriendlyName": "M3U Tuner",
    "ImportFavoritesOnly": false,
    "AllowHWTranscoding": false,
    "TunerCount": 0
  }

as examples of whats shown via the API for my tuners

 

Friendly Name would be nice as well :)

 

Thanks

 

 

Done mate, I've released it on the catalogue as v2.1.6

 

Includes:-

 

%recording.tuner.friendlyname%, %recording.tuner.source%, %recording.tuner.count%, %recording.tuner.type%, %recording.tuner.url%, %recording.tuner.deviceid%

 

2020-04-27 01:57:14.553 Info Emby ScripterX: onLiveTVRecordingEnded: M3U Tuner, , 0, m3u, http://<iphidden>:9981/playlist,

 

Done with :-

%recording.tuner.friendlyname%, %recording.tuner.source%, %recording.tuner.count%, %recording.tuner.type%, %recording.tuner.url%, %recording.tuner.deviceid% 

 

Just checking over your other comments mate:)

  • Like 1
Link to comment
Share on other sites

PenkethBoy

Antony what api call do you use to get the file system location for a series root [eg for a given ID]. eg return D:\TV2\Lost for lost's ID. i cant seem to find it in swagger, i can use /Items/{Id}/PlaybackInfo for a media file eg S01E01 and work it out from there but i presume there is a better way?

thanks

you can get this from the "path" to the item via the swagger api

  • Like 1
Link to comment
Share on other sites

ginjaninja

you can get this from the "path" to the item via the swagger api

using your

$MediaUrl = $embyServerUrl + "/emby/users/" + $User.User.Id + "/items?Fields=Tags,Genres,Childcount%2CProviderIds%2CRemoteTrailers%2CDateCreated,LocalTrailerCount&Recursive=true&SortBy=SortName&SortOrder=Ascending&IncludeItemTypes=Series" + "&api_key=" + $User.AccessToken

i dont get path in the json for each series...

Link to comment
Share on other sites

PenkethBoy

Ok - dont post in this thread :)

 

-post in the API section and i will answer you there - Anthony is using c# not the API (http) and it would be best to keep this thread specific to the plugin development

  • Like 1
Link to comment
Share on other sites

Anthony Musgrove

Hi Anthony

 

Just testing out the new recording events

EventType: RecordingEnded Recording Name: Britain's Got Talent Channel ID: 103 Start Date: 26/04/2020 11:35:00 +00:00 End Date: 26/04/2020 12:50:00 +00:00 Channel Name: ITV HD Channel Type: TV Channel Call Sign:  Channel Affiliate Call Sign: 
EventType: RecordingEnded Recording Name: Inspector Morse Channel ID: 10 Start Date: 26/04/2020 10:35:00 +00:00 End Date: 26/04/2020 12:50:00 +00:00 Channel Name: ITV3 Channel Type: TV Channel Call Sign:  Channel Affiliate Call Sign: 

Noticed a couple of things

1. The StartDate and EndDate are in UTC and not local time - i.e. should be 13:50 not 12:50

2. Could we lose the + 00:00 as when the times are correct would not be needed

3. Getting nothing for Call Sign or Affiliate Call Sign - not sure if this is because i'm using UK Terrestrial TV and its more an American thing? - not a big problem as will probably not use it :)

 

Question re Channel Type - if i was using IPTV would it show that or is it always going to be "TV" ?

 

Thanks

 

Hey mate,  thank you!

 

1. The next version release (2.1.8) will have:

 

%recording.date.start%, %recording.date.end% which will yield results based on your server's timezone (locale), and it doesn't include the offset at the end:

 

2020-04-27 10:36:19.856 Info Emby ScripterX: onLiveTVRecordingStart: START StartDate: 27/4/2020 10:00:00 am   EndDate: 27/4/2020 11:00:00 am
2020-04-27 10:36:39.347 Info Emby ScripterX: onLiveTVRecordingEnded: START StartDate: 27/4/2020 10:00:00 am   EndDate: 27/4/2020 11:00:00 am
 
And also: %recording.date.start.utc%, %recording.date.end.utc% which are basically the old date.start, date.end (UTC).
 
2. Done! just needs to be released
 
3. I'm not sure what callsign and callsign affiliate are meant to be, they're just properties in the SDK that i've included but they haven't populated for me.  Perhaps @@ebr or @@Luke knows :)
Edited by Anthony.Musgrove
Link to comment
Share on other sites

Anthony Musgrove

I see 2.1.7 is out - any new features?

 

:)

 

I had issues with 2.1.6 mate (just in the catalog settings portal) so I had to skip it :) 

Link to comment
Share on other sites

Anthony Musgrove

 

Hey mate,  thank you!

 

1. The next version release (2.1.8) will have:

 

%recording.date.start%, %recording.date.end% which will yield results based on your server's timezone (locale), and it doesn't include the offset at the end:

 

2020-04-27 10:36:19.856 Info Emby ScripterX: onLiveTVRecordingStart: START StartDate: 27/4/2020 10:00:00 am   EndDate: 27/4/2020 11:00:00 am
2020-04-27 10:36:39.347 Info Emby ScripterX: onLiveTVRecordingEnded: START StartDate: 27/4/2020 10:00:00 am   EndDate: 27/4/2020 11:00:00 am
 
And also: %recording.date.start.utc%, %recording.date.end.utc% which are basically the old date.start, date.end (UTC).
 
2. Done! just needs to be released
 
3. I'm not sure what callsign and callsign affiliate are meant to be, they're just properties in the SDK that i've included but they haven't populated for me.  Perhaps @@ebr or @@Luke knows :)

 

 

I poked around in some of the available open source code for the core, and found that SchedulesDirect class sets the callsign based on the station callsign it retrieves;

 

in 

public async Task<List<ChannelInfo>> GetChannels(ListingsProviderInfo info, CancellationToken cancellationToken)

it sets:

 var channelInfo = new ChannelInfo
 {
      Id = station.stationID,
      CallSign = station.callsign,
      Number = channelNumber,
      Name = string.IsNullOrWhiteSpace(station.name) ? channelNumber : station.name
 };

and 'station' is set as:

var station = allStations.FirstOrDefault(item => string.Equals(item.stationID, map.stationID, StringComparison.OrdinalIgnoreCase));

and conversely, allStations is set as:

var allStations = root.stations ?? Enumerable.Empty<ScheduleDirect.Station>();

and root.stations is set as :

var root = await _jsonSerializer.DeserializeFromStreamAsync<ScheduleDirect.Channel>(response).ConfigureAwait(false);

_logger.LogInformation("Found {ChannelCount} channels on the lineup on ScheduleDirect", root.map.Count);
_logger.LogInformation("Mapping Stations to Channel");

the (response) variable above looks to be the result of an API call:

Url = ApiUrl + "/lineups/" + listingsId,

Scrap that, this is for SchedulesDirect an API service:

private const string ApiUrl = "https://json.schedulesdirect.org/20141201";

and it looks like callsign isn't utilised in the XmlTv listings class.  In the open source version anyway.

 

 

If that helps :)

Edited by Anthony.Musgrove
Link to comment
Share on other sites

PenkethBoy

Anthony

 

Was testing yesterday and now have ScripterX talking to a "master" Powershell script for a live recording - which generates a Toast notification on recording start and end - then on end calls my Post processing PS script to process with ComSkip then re-encode the ts file to a H265 mkv with chapters from comskip via my nvidia Gpu using NVENC - all seamless now :)

 

5ea67d1d94177_Annotation20200427073115.j

 

Still messing with the format a bit but basically works a treat

 

Do you have a high quality logo without the bottom white section i could use for the image in the toasts?

  • Like 1
Link to comment
Share on other sites

Anthony Musgrove

Anthony

 

Was testing yesterday and now have ScripterX talking to a "master" Powershell script for a live recording - which generates a Toast notification on recording start and end - then on end calls my Post processing PS script to process with ComSkip then re-encode the ts file to a H265 mkv with chapters from comskip via my nvidia Gpu using NVENC - all seamless now :)

 

5ea67d1d94177_Annotation20200427073115.j

 

Still messing with the format a bit but basically works a treat

 

Do you have a high quality logo without the bottom white section i could use for the image in the toasts?

 

 

That looks absolutely amazing mate, and I am so so so glad to hear it's running smoothly, hehe.  It's been a journey so far, and so much more left to implement!  I'll grab a better quality image for you :)

 

 

Update:   I've got a higher quality thumb image on the github repo at https://github.com/AnthonyMusgrove/Emby-ScripterX/blob/master/Images/_cat_thumb.png

 

:) <3

 

Thank you so so so much!

Edited by Anthony.Musgrove
  • Like 1
Link to comment
Share on other sites

Anthony Musgrove

v2.1.8 Released on catalog:

 

Added

onScheduledTaskStart: %task.category%, %task.name%, %task.id%

onScheduledTaskEnded: %task.id%, %task.category%, %task.result%, %task.name%, %task.start.time%, %task.end.time%, %task.start.time.utc%, %task.end.time.utc%

 

 

:)

  • Like 1
Link to comment
Share on other sites

Anthony Musgrove

 

thanks for the new version
 
the problem on my raspberry is still there
 
with /bin/bash i get
 
2020-04-19 17:42:18.874 Error Emby ScripterX: Error executing script '/home/emby_scripts/test.sh Worlds Collide': /bin/bash: /opt/emby-server/lib/libc.so.6: version `GLIBC_2.28' not found (required by /bin/bash)
with /usr/bin/bash i get this error
 
2020-04-19 17:42:49.691 Debug PlaystateService: ReportPlaybackStopped PlaySessionId: 
2020-04-19 17:42:49.692 Info SessionManager: Playback stopped reported by app Emby for Android Mobile 3.1.19 playing Worlds Collide. Stopped at 16000 ms
2020-04-19 17:42:49.695 Info HttpServer: HTTP Response 204 to 192.168.178.107. Time: 9ms. http://192.168.178.22:8096/emby/Sessions/Playing/Stopped
2020-04-19 17:42:49.711 Error SessionManager: Error in event handler
*** Error Report ***
Version: 4.4.2.0
Command line: /opt/emby-server/system/EmbyServer.dll -programdata /var/lib/emby -ffdetect /opt/emby-server/bin/ffdetect -ffmpeg /opt/emby-server/bin/ffmpeg -ffprobe /opt/emby-server/bin/ffprobe -restartexitcode 3 -updatepackage emby-server-deb_{version}_armhf.deb
Operating system: Unix 4.19.97.7
64-Bit OS: False
64-Bit Process: False
User Interactive: True
Runtime: file:///opt/emby-server/system/System.Private.CoreLib.dll
System.Environment.Version: 3.1.2
Processor count: 4
Program data path: /var/lib/emby
Application directory: /opt/emby-server/system
System.ComponentModel.Win32Exception: System.ComponentModel.Win32Exception (2): No such file or directory
   at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at EmbyScripterX.Plugin.execute_action(EmbyScripterXAction nAction, String parameters)
   at EmbyScripterX.ScripterXController._sessionManager_PlaybackStopped(Object sender, PlaybackStopEventArgs e)
   at MediaBrowser.Common.Events.EventHelper.<>c__DisplayClass1_0`1.<QueueEventIfNotNull>b__0()
Source: System.Diagnostics.Process
TargetSite: Boolean ForkAndExecProcess(System.String, System.String[], System.String[], System.String, Boolean, Boolean, Boolean, Boolean, UInt32, UInt32, UInt32[], Int32 ByRef, Int32 ByRef, Int32 ByRef, Boolean, Boolean)
/usr/bin/python3 also dont working
 
it would be nice if you could fix that or tell me what I'm doing wrong
 

 

 

Hi lex; I am currently looking into this issue. While I don't have a raspberry pi here to test with, I have just installed Rasbian buster in a virtual machine. 

 

Could you please confirm for me that your pi is running buster?

 

5ea804afdeadf_raspberrypibuster.png

 

Also just confirm for me that you're using Emby Server for Debian on your Pi? 

 

I'll evaluate and get back to you!

Edited by Anthony.Musgrove
Link to comment
Share on other sites

Anthony Musgrove

So far my testing on Raspberry Pi buster (only in Vmware - not on the actual device) ScripterX is working as intended.

 

5ea80ef0adaa7_raspberrypiworking01.png

 

I'm hoping that others out there with a raspberry pi installation of Emby can test Scripter-X for me too, just to confirm that it works.  I know that Vmware I have to use the amd64bit architecture rather than the arm architecture, so I'd love to get some more feedback on the issue so we can see if its specific to your installation or overall on the arm architecture.

 

Kindest regards :)

  • Like 1
Link to comment
Share on other sites

PenkethBoy

Hi Anthony

 

A suggestion - we have three scheduled Task events now - so could be a tad confusing

 

5ea8154aeb655_Annotation20200428123452.j

 

Maybe change this to onScripterXScheduledTask and move it to the bottom (currently) of the list - to sits beside the other onSch tasks so all together?

 

Another question - initially the list of events was in Alphabetical order or the order you created them - as more are added they are getting jumbled up - would it be possible to order them - or give us the option to drag them into an order we would like to have - e.g. i might not use all the events so might like to have my "used" events at the top in some order i would want and have all the unused ones at the bottom - would something like that be possible? or maybe two groups of events - live and not ordered by event name - or....... :)

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...