AnthonyMusgrove / Emby-ScripterX

Run custom external application or script (batch/bash/powershell/php/python/node.js/custom) on various events within the Emby Server.
https://emby-scripterx.com
78 stars 6 forks source link

onItemRemoved - %item.library.* not available #2

Closed AnthonyMusgrove closed 4 years ago

AnthonyMusgrove commented 4 years ago

Describe the bug When using onItemRemoved, %item.library.*% tokens are not substituted for values

To Reproduce Steps to reproduce the behavior:

  1. Create an onItemRemoved action using any %item.library.* tokens as parameters
  2. Check Emby Log for output for onItemRemoved; Info Emby ScripterX: onItemRemoved: REMOVED 12111 "The Simpsons S23X01 2 Maggie Simpson in The Longest Daycare - Copy" "D:\Media\Movies\The Simpsons S23X01 2 Maggie Simpson in The Longest Daycare - Copy.mp4" "%item.library.name%"

Expected behavior %item.library.name% should be substituted for its correct value, in this case 'Movies'

Screenshots n/a

AnthonyMusgrove commented 4 years ago

After researching this issue, it was simply due to the fact that after an item was deleted, its parent was null, so therefore not being able to reference to its parent item/object, preventing ScripterX from tracing the parent back to a VirtualFolder (or library).

The issue has now been rectified - the core event from librarymanager explicitly provides the deleted item's parent as a parameter of the event arguments; which is now utilised correctly.

I've tested both Movies and TV content types, and ScripterX is now able to trace back to the VirtualFolder for all types of media, please see output below:

onItemAdded: 2020-04-23 16:03:38.866 Info Emby ScripterX: Output from script '/c D:\embyscripts\media.bat ADDED 12113 "The Simpsons S23X01 2 Maggie Simpson in The Longest Daycare - Copy" "D:\Media\Movies\The Simpsons S23X01 2 Maggie Simpson in The Longest Daycare - Copy.mp4" "Movies"'

onItemRemoved 2020-04-23 16:13:17.550 Info Emby ScripterX: onItemRemoved: REMOVED 12115 "Death Has a Shadow" "D:\Media\TV\Family Guy\S01\S01E01 - Death Has A Shadow - Copy.avi" "TV"