Jump to content

New Plugin - Custom Scripting | Emby ScripterX


Anthony Musgrove

Recommended Posts

Anthony Musgrove
2 hours ago, PenkethBoy said:

Anthony

Any chance we can fix and close out github issues #12 #14 #23 #25 #26 - which have been outstanding for a few weeks for most of them

some are stopping me from using your plugin for things i want to automate

Appreciate you have been concentrating on packages but these are main core functions that need to work

Thanks

Absolutely mate, thank you for bringing it more to my attention :) Starting at the start of this list now... I'm now working on #12 (I download Mp3tag v3 to check the tags first too)

 

1779346033_musicid3tag.thumb.png.d974ebddf2a54a0761c50097bca82d70.png

  • Like 1
Link to comment
Share on other sites

Anthony Musgrove

Alrighty, for #12, it looks like its an Emby behaviour, where onItemAdded isn't called for a MusicArtist, only onItemUpdated is.  @Luke

 

This is the general logging order for when a Music library folder is added, then an Album and a bunch of songs.  You can see the onItemUpdated for a MusicArtist but an onItemAdded is never called, thus an onItemAddedComplete will never call.  So unless this is a bug, it's an emby behaviour that a MusicArtist being created doesn't trigger an onItemAdded, only an onItemUpdated.  I wonder if Luke can elaborate more on that one.

2020-06-22 20:32:07.140 Info Emby ScripterX: onMediaItemAdded: "Folder" "Music"


2020-06-22 20:32:07.161 Info Emby ScripterX: onMediaItemAddedComplete: "Folder" "Music"
2020-06-22 20:32:07.170 Info Emby ScripterX: onMediaItemUpdated: "Folder" "Music"

2020-06-22 20:32:07.196 Info Emby ScripterX: onMediaItemAdded: "CollectionFolder" "Music"

2020-06-22 20:32:07.229 Info Emby ScripterX: onMediaItemAddedComplete: "CollectionFolder" "Music"
2020-06-22 20:32:07.236 Info Emby ScripterX: onMediaItemUpdated: "CollectionFolder" "Music"

2020-06-22 20:33:55.276 Info Emby ScripterX: onMediaItemAdded: "MusicAlbum" "Breaking Benjamin - Ember (2018) [CD 320]"

2020-06-22 20:33:55.303 Info Emby ScripterX: onMediaItemAdded: "Audio" "01. Lyra"

2020-06-22 20:33:56.644 Info Emby ScripterX: onMediaItemAddedComplete: "Audio" "Lyra"

2020-06-22 20:34:08.318 Info Emby ScripterX: onMediaItemAddedComplete: "MusicAlbum" "Ember"
2020-06-22 20:34:08.329 Info Emby ScripterX: onMediaItemUpdated: "MusicAlbum" "Ember"

??
2020-06-22 20:34:08.342 Debug App: Refreshing MusicArtist Breaking Benjamin because item.RequiresRefresh() returned true
2020-06-22 20:34:08.345 Debug App: Running MusicBrainzArtistProvider for Breaking Benjamin
??

2020-06-22 20:34:13.461 Info Emby ScripterX: onMediaItemUpdated: "MusicArtist" "Breaking Benjamin"

 

Link to comment
Share on other sites

Anthony Musgrove

Alrighty!  Issue #14 is complete, i've added two new events:

 

onRecordingTimerCreated and onRecordingTimerCancelled :)

 

Recording Timer CREATED : Timer ID:"0684a592ea448fbe53bf240a44a1a4dc" - Name:"300", Date_Start:"22/06/2020 8:30:00 PM", Date_End:"22/06/2020 10:55:00 PM" 
Recording Timer CANCELLED : Timer ID:"0684a592ea448fbe53bf240a44a1a4dc" - Name:-, Date_Start:-, Date_End:- 
 

I'll release this version tonight

  • Like 1
Link to comment
Share on other sites

Anthony Musgrove

RE Issue #23, the best I can do so far is add an %was.cancelled% token to onLibraryScanComplete.  There isn't much information provided at this stage, so I'm still investigating on whether or not it is possible to get additional failedstates for library scanning.  Try using the %was.cancelled% token and let me know if its 'true' if there is a scanning error (I'm very curious on how this will behave)

 

thanks mate!was_cancelled.png.6f6664435c4b9f8505cd4935b3bbb2fb.png

 

Edited by Anthony Musgrove
Link to comment
Share on other sites

Anthony Musgrove

v3.0.4.8 now live :)

General
* Added requested [<a is="emby-linkbutton" target= '_blank' href="https://github.com/AnthonyMusgrove/Emby-ScripterX/issues/14" class="button-link emby-button">Github Feature Request#14</a>]: 
Added two new events - onRecordingTimerCreated and onRecordingTimerCancelled

* Added %was.cancelled% token to onLibraryScanComplete event (for testing to address [<a is="emby-linkbutton" target= '_blank' href="https://github.com/AnthonyMusgrove/Emby-ScripterX/issues/23" class="button-link emby-button">Github Feature Request#23</a>])

Packages
* Consequently, _onRecordingTimerCreated and _onRecordingTimerCancelled are now available for packages as
event subscriptions.

  • Like 1
Link to comment
Share on other sites

PenkethBoy
15 hours ago, Anthony Musgrove said:

Alrighty, for #12, it looks like its an Emby behaviour, where onItemAdded isn't called for a MusicArtist, only onItemUpdated is.  @Luke

 

This is the general logging order for when a Music library folder is added, then an Album and a bunch of songs.  You can see the onItemUpdated for a MusicArtist but an onItemAdded is never called, thus an onItemAddedComplete will never call.  So unless this is a bug, it's an emby behaviour that a MusicArtist being created doesn't trigger an onItemAdded, only an onItemUpdated.  I wonder if Luke can elaborate more on that one.


2020-06-22 20:32:07.140 Info Emby ScripterX: onMediaItemAdded: "Folder" "Music"


2020-06-22 20:32:07.161 Info Emby ScripterX: onMediaItemAddedComplete: "Folder" "Music"
2020-06-22 20:32:07.170 Info Emby ScripterX: onMediaItemUpdated: "Folder" "Music"

2020-06-22 20:32:07.196 Info Emby ScripterX: onMediaItemAdded: "CollectionFolder" "Music"

2020-06-22 20:32:07.229 Info Emby ScripterX: onMediaItemAddedComplete: "CollectionFolder" "Music"
2020-06-22 20:32:07.236 Info Emby ScripterX: onMediaItemUpdated: "CollectionFolder" "Music"

2020-06-22 20:33:55.276 Info Emby ScripterX: onMediaItemAdded: "MusicAlbum" "Breaking Benjamin - Ember (2018) [CD 320]"

2020-06-22 20:33:55.303 Info Emby ScripterX: onMediaItemAdded: "Audio" "01. Lyra"

2020-06-22 20:33:56.644 Info Emby ScripterX: onMediaItemAddedComplete: "Audio" "Lyra"

2020-06-22 20:34:08.318 Info Emby ScripterX: onMediaItemAddedComplete: "MusicAlbum" "Ember"
2020-06-22 20:34:08.329 Info Emby ScripterX: onMediaItemUpdated: "MusicAlbum" "Ember"

??
2020-06-22 20:34:08.342 Debug App: Refreshing MusicArtist Breaking Benjamin because item.RequiresRefresh() returned true
2020-06-22 20:34:08.345 Debug App: Running MusicBrainzArtistProvider for Breaking Benjamin
??

2020-06-22 20:34:13.461 Info Emby ScripterX: onMediaItemUpdated: "MusicArtist" "Breaking Benjamin"

 

Anthony

An idea re this missing MusicArtist

looking at the Emby Log

i see

# these events below happen after the "Album" addedcomplete has fired

Debug App: Running AudioDbArtistProvider for Roxy Music

Debug App: Running FanartArtistProvider for Roxy Music

Debug App: Running MusicBrainzImageProvider for Roxy Music

# Roxy Music is the new MusicArtist (AlbumArtist) that i have added
# After the "Debug App: Running MusicBrainzImageProvider for Roxy Music" - is when the onMediaItemUpdated fires
# could it be that we need to connect to one of the above events to see the new MusicArtist being "added" first

Probably the AudioDBArtistProvider is when the MusicArtist gets added....?

 

Thanks

Link to comment
Share on other sites

PenkethBoy
13 hours ago, Anthony Musgrove said:

RE Issue #23, the best I can do so far is add an %was.cancelled% token to onLibraryScanComplete.  There isn't much information provided at this stage, so I'm still investigating on whether or not it is possible to get additional failedstates for library scanning.  Try using the %was.cancelled% token and let me know if its 'true' if there is a scanning error (I'm very curious on how this will behave)

 

thanks mate!was_cancelled.png.6f6664435c4b9f8505cd4935b3bbb2fb.png

 

Ok - tested this

When a library scan completes was.cancelled returns "false"

If you cancel a library scan - no event is fired

 

Idea

I am now thinking that Library scan is now possibly redundant

Because

We have scheduled task start and end - which also fire when a Library scan is started and ends - also "end" has a task.result which will say "cancelled" etc

So if we could add scan.library.name to the scheduled Task start/end events than onLibraryScanComplete would be redundant

Thoughts??

Link to comment
Share on other sites

Anthony Musgrove
7 hours ago, PenkethBoy said:

Ok - tested this

When a library scan completes was.cancelled returns "false"

If you cancel a library scan - no event is fired

 

Idea

I am now thinking that Library scan is now possibly redundant

Because

We have scheduled task start and end - which also fire when a Library scan is started and ends - also "end" has a task.result which will say "cancelled" etc

So if we could add scan.library.name to the scheduled Task start/end events than onLibraryScanComplete would be redundant

Thoughts??

Absolutely mate this is a fantastic idea.  I love love love it.  So I can check if the scheduled task is a Library scan, thats an amazing idea, we can integrate it more into scheduled tasks events.

 

I'm going to look at this tonight :) :)

Link to comment
Share on other sites

Anthony Musgrove
6 hours ago, PenkethBoy said:

Recording timers working for me :)

Awesome mate:)))

Link to comment
Share on other sites

Anthony Musgrove
7 hours ago, PenkethBoy said:

Anthony

An idea re this missing MusicArtist

looking at the Emby Log

i see


# these events below happen after the "Album" addedcomplete has fired

Debug App: Running AudioDbArtistProvider for Roxy Music

Debug App: Running FanartArtistProvider for Roxy Music

Debug App: Running MusicBrainzImageProvider for Roxy Music

# Roxy Music is the new MusicArtist (AlbumArtist) that i have added
# After the "Debug App: Running MusicBrainzImageProvider for Roxy Music" - is when the onMediaItemUpdated fires
# could it be that we need to connect to one of the above events to see the new MusicArtist being "added" first

Probably the AudioDBArtistProvider is when the MusicArtist gets added....?

 

Thanks

Hmmm sir you've given me a bit more to think about with this one.. I wonder if there's some Music managers.. MmmmM! Let me look into it :)

Link to comment
Share on other sites

Anthony Musgrove
1 hour ago, Anthony Musgrove said:

Hmmm sir you've given me a bit more to think about with this one.. I wonder if there's some Music managers.. MmmmM! Let me look into it :)

Okay so what I understand of this so far, There is a plugin (AudioDb) that is an external plugin that looks up and creates the Music Artist in the emby database.  Once its created, the plugin doesn't call or report a New Item Added to the ?Library Manager? so therefore there is no on Item Added event for MusicArtist.    However, when the library manager updates the MusicArtist item, an onItemUpdated is called by the Library Manager.

So perhaps the AudioDB plugin doesn't tell the Library Manager to call an Item Added event?

 

Link to comment
Share on other sites

Anthony Musgrove

I'm currently testing using Scheduled Tasks for Library scanning, however I've ran into a problem.

If I scan my entire library, the scheduled task executes.  If I just scan one of my library folders (Movies for example), it doesn't cause a Scheduled Task to occur.

 

SchedTask START [Category: "Library"] [Name: "Scan media library"] [ID: "6330ee8fb4a957f33981f89aa78b030f"] [Result: "-"] [StartTime: ] [EndTime: ] 
SchedTask ENDED [Category: "Library"] [Name: "Scan media library"] [ID: "6330ee8fb4a957f33981f89aa78b030f"] [Result: "Completed"] [StartTime: "23/06/2020 9:10:00 PM"] [EndTime: "23/06/2020 9:10:03 PM"] 
SchedTask START [Category: "Library"] [Name: "Scan media library"] [ID: "6330ee8fb4a957f33981f89aa78b030f"] [Result: "-"] [StartTime: ] [EndTime: ] 
SchedTask ENDED [Category: "Library"] [Name: "Scan media library"] [ID: "6330ee8fb4a957f33981f89aa78b030f"] [Result: "Completed"] [StartTime: "23/06/2020 9:11:03 PM"] [EndTime: "23/06/2020 9:11:03 PM"] 

Both of the above results occured while scanning the entire library.  Between these scans I scanned JUST my movies folder, JUST my tv folder, etc..

Link to comment
Share on other sites

PenkethBoy

When you do a scan of a single library - its NOT a Scheduled Task

its doing the scan - which has no progress update - long standing issue thats never been fixed

essentially a scan of a single library is only part of the Library scan Scheduled task and i suspect bypasses a lot of code to just do the single library - also i dont think the post processing tasks after a full library scan fire either.

Link to comment
Share on other sites

PenkethBoy
3 hours ago, Anthony Musgrove said:

Okay so what I understand of this so far, There is a plugin (AudioDb) that is an external plugin that looks up and creates the Music Artist in the emby database.  Once its created, the plugin doesn't call or report a New Item Added to the ?Library Manager? so therefore there is no on Item Added event for MusicArtist.    However, when the library manager updates the MusicArtist item, an onItemUpdated is called by the Library Manager.

So perhaps the AudioDB plugin doesn't tell the Library Manager to call an Item Added event?

 

The AudioDb plugin is i believe maintained by Luke as well as the MusicBrainz plugin

So he could update these to give us the required event(s)

 

I wonder what happens when neither plugin is enabled/loaded?

Link to comment
Share on other sites

PenkethBoy

disabling the plugins - same result - no itemadded for MusicArtist - just the itemupdated event

Link to comment
Share on other sites

Anthony Musgrove

Slowly picking away at this interface rewrite.  It's coming along very robustly.  It's going to be awesome.

This isn't indicative of the code behind it, the code is going to be MUCH smarter after this rewrite.  It will be much more customisable.

:) :)

Can't wait to get this finished so you guys can make it do stuff :))))

1910389689_interfacerewriteprogress.thumb.png.dad5f3d5bba6920845c38efa782835df.png

  • Like 1
Link to comment
Share on other sites

Anthony Musgrove

Slowly but surely plugging away :)  It's coming together nicely.  Slowly integrating functionality into the flexible framework.   I'm working on it when I can as well as work :)

 

Next step is to clean and rewrite edit and delete to match the new interface,  then afterwards re-enabling the drag and drop system, and then it will be ready to beta test :)

 

ScripterX_rewrite_actions_interface_progress_2.thumb.png.c6894b7fc0224b3340f0ee9c4fa0527e.png

 

Link to comment
Share on other sites

Anthony Musgrove

Or would you prefer it with parameters and where labels, so you can see what they mean while you're not editing them? like this:-

2002787742_withparametersandwhere.thumb.png.0648b4c51dc9c68144a88d3c25755c27.png

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
neunghaha28

Help me 

Run /mnt/WD4TB/ubuntu_storage/playback using /bin/bash
%username% %device.name% %season.number% %episode.number% %series.name%
where

script playback

#!/bin/bash
echo "User: $1 Device: $2 Season: $3 Episode: $4 Show: $5" >> /mnt/WD4TB/ubuntu_storage/playback.log

output playback.log

User: neunghaha28 Device: Chrome Season: 1 Episode: 1 Show: Angel's

I play tv show Angel's Last Mission: Love.

how to fix ?

Thanks for help. 😍
Edited by neunghaha28
Link to comment
Share on other sites

xnappo

@Anthony Musgrove I apologize in advance for asking before digging in myself - but I have some free time coming up and hope you can quickly answer feasibility for a use case.

Basically would like to automate what I am doing in the post linked below.  What I need to be able to do in a nutshell is:

On library scan copy a dummy video file over to a season folder when the content provider is Netflix or Prime (or XXX) and the air date has past.  

Feasible?

 

 

 

Edited by xnappo
Link to comment
Share on other sites

PenkethBoy
9 hours ago, neunghaha28 said:

Help me 


Run /mnt/WD4TB/ubuntu_storage/playback using /bin/bash
%username% %device.name% %season.number% %episode.number% %series.name%
where

script playback


#!/bin/bash
echo "User: $1 Device: $2 Season: $3 Episode: $4 Show: $5" >> /mnt/WD4TB/ubuntu_storage/playback.log

output playback.log


User: neunghaha28 Device: Chrome Season: 1 Episode: 1 Show: Angel's

I play tv show Angel's Last Mission: Love.

how to fix ?


Thanks for help. 😍

put %series.name% in quotes e.g. "%series.name%"

  • Thanks 1
Link to comment
Share on other sites

PenkethBoy
3 hours ago, xnappo said:

@Anthony Musgrove I apologize in advance for asking before digging in myself - but I have some free time coming up and hope you can quickly answer feasibility for a use case.

Basically would like to automate what I am doing in the post linked below.  What I need to be able to do in a nutshell is:

On library scan copy a dummy video file over to a season folder when the content provider is Netflix or Prime (or XXX) and the air date has past.  

Feasible?

 

 

 

Yes - the plugin has a libscan event which will tell you when it is triggered etc

Although probably not the event i would use

rest is up to your script to figure out

Link to comment
Share on other sites

sfatula

Ok, does the following seem possible with this plugin? Essentially, for some content, I need to replace Emby dvr recordings with another tool. Let's not get into those details here, let's just say it necessary.

So, I see you have a newish onRecordingTimerCreated event. Not sure of the details, but several scenarios to do what I need:

1. I add a manual timer to Emby via the guide to record a show. I presume I can capture that event, and my program can determine it's the right channel where I need another tool to record, and set up that to happen. I need to be able to obtain the program start and end times and channel. I would then need to disable via API call Emby trying to record the channel. 

2. I add a series timer to Emby. Let's say it matches 2 episodes in the guide at present. Will I be able to see both of those by this event? 

3. Now it's a week later, and, guide is refreshed and a 3rd episode matches the series timer and needs to be recorded. I will see that episode as well via this event?

Found a bug I think. I am using OnRecordingTimerCreated. Or, are the non substituted parms simply not available perhaps? Parms are:

"%recording.channel.number%" "%recording.tuner.source%" "%recording.show.id%" "%recording.name%" "%recording.program.id%" "%recording.path%" "%recording.date.start.utc%" "%recording.date.end.utc%"
 
Simple PHP program for learning:
 
<?php
$channelNum = $argv[1];
$channelType = $argv[2];
$timerId = $argv[3];
$name = $argv[4];
$programId = $argv[5];
$showId = $argv[6];
$start = $argv[7];
$end = $argv[8];

error_log("Channel #:{$channelNum} Type:{$channelType} Timer ID:{$timerId} Name:{$name} ProgramID:{$programId} ShowID:{$showId} Start:{$start} End:{$end}");

[20-Jul-2020 17:35:30 America/Chicago] Channel #:1002 Type:%recording.tuner.source% Timer ID:%recording.show.id% Name:Pacific Blue ProgramID:1002_2020-07-20T23:00:00.0000000+00:00_m3u_7e43d9ee0ab0d4748d847e9f5bbb563e8c8d6c5c41694c9d689f5dade9b8cb21 ShowID:%recording.path% Start:7/20/2020 11:00:00 PM +00:00 End:7/21/2020 12:00:00 AM +00:00
 

Also, %recording.date.start.utc% is not shown as a valid parm with your plugin, but it does seem to work. 


 

 
 
Edited by sfatula
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...