Jump to content

Media item deleting event


Recommended Posts

Posted (edited)

In a plugin, I want to archive the underlying media file of the strm file being deleted.

The only related event I found is ILibraryManager.ItemRemoved, but this happens after the strm file is deleted, so I can’t read its content or mount path. Which event shall I subscribe that’s triggered before the strm file is actually deleted?

If such event is not available, is there a property of the strm media item for getting the real path?

Thanks!

Edited by sjtuross
Posted
7 hours ago, sjtuross said:

this happens after the strm file is deleted, so I can’t read its content or mount path. Which event shall I subscribe that’s triggered before the strm file is actually deleted?

STRM files are handled just like any other media file: Emby Server reacts to changes in the file system. When a file gets deleted from disk, Emby Server receives a file change event and acts accordingly, which means that once Emby Server starts acting, the file has already been deleted.  

In case the deletion would be executed through the Emby UI, I'm not sure whether there's an event that you could catch, but that wouldn't help you anyway, because that wouldn't allow you to cover all cases of deletion.

Did you check the Item property of the Emby SDK Reference: ItemChangeEventArgs of the Emby SDK Reference: ILibraryManager.ItemRemoved event?

Posted

If I open the strm media item in Emby UI, I can actually see the underlying path in the media info section. Does it mean this path information is stored somewhere like database? I explored ItemChangeEventArgs in a debug session, but it looks like all the path related information is about the strm itself.

Posted
Quote

Does it mean this path information is stored somewhere like database?

It's not stored in the database at this time, so currently there's no real way to do this.

We might have to add a Deleting event that triggers after the delete is requested, but before it actually happens.

Posted (edited)

Ok, looking forward to this Deleting event.

For the existing strm media item, is there Emby API to get its underlying path? or I have to read its content? Any suggestion?

Edited by sjtuross
Posted
On 9/3/2024 at 8:37 AM, sjtuross said:

Ok, looking forward to this Deleting event.

For the existing strm media item, is there Emby API to get its underlying path? or I have to read its content? Any suggestion?

You should be able to get it by looking at the MediaSources property.

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