Jump to content

How to check if the underlying media file is modified?


Recommended Posts

sjtuross
Posted (edited)

I tried using this method https://dev.emby.media/reference/pluginapi/MediaBrowser.Controller.Entities.BaseItem.html#MediaBrowser_Controller_Entities_BaseItem_HasDateModifiedChanged_System_DateTimeOffset_

The problem is that if I do library scan after media file is modified, this method returns false. But if I don't do library scan, it returns true as expected.

var file = directoryService.GetFile(item.Path);
item.HasDateModifiedChanged(file.LastWriteTimeUtc));

 

Edited by sjtuross
Posted

Hi, that's all there is. It returns false after the library scan because the database is up to date with changes in the file. 

sjtuross
Posted
11 hours ago, Luke said:

Hi, that's all there is. It returns false after the library scan because the database is up to date with changes in the file. 

Got it. So basically it compares database with filesystem. From plugin standpoint, is there any way to get such change event or information?

Posted
7 hours ago, sjtuross said:

Got it. So basically it compares database with filesystem. From plugin standpoint, is there any way to get such change event or information?

In realtime, no. There is the ItemUpdated event on librarymanager that you can subscribe to. You'll get notified when the core server becomes aware of the change.

sjtuross
Posted
20 hours ago, Luke said:

In realtime, no. There is the ItemUpdated event on librarymanager that you can subscribe to. You'll get notified when the core server becomes aware of the change.

Thanks for the suggestion! I tried subscribing to the ItemUpdated event, and it does get triggered for the modified item. However, the UpdateReason is set to "None | MetadataImport | MetadataDownload", which seems to indicate a standard metadata refresh. This makes it difficult to determine if the underlying file itself has been modified.

Posted

ItemUpdated is still the closest option though. We just need to add more information to the event about what changed.

  • Thanks 1

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