Jump to content

ILibraryPostScanTask any way to tell what changed?


Recommended Posts

HawkXP71
Posted

When a task is called after the scan has finished, is there anyway to tell what changed in the last scan?

For each library, were items added/removed? 

Is there access to this data anywhere?

HawkXP71
Posted

WHile I couldnt find a solution on my own, I was able to do the following.

 

Added a method to get the latest movie or episode added.  Note, If you need it to work for music as well, just add that to the IncludeItemTypes

        public BaseItem? GetLastMovieOrEpisodeAdded()
        {
            var query = new InternalItemsQuery
            {
                IsFolder = false,
                OrderBy = new[] { new ValueTuple<string, SortOrder>( ItemSortBy.DateCreated, SortOrder.Descending ) },
                IsVirtualItem = false,
                IncludeItemTypes = new[] { "Movie", "Episode" },
                Recursive = true,
                Limit = 50
            };

            var items = _embyInterfaces!._libraryManager!.GetItemList( query );
            foreach( var item in items )
            {
                if( item.DateCreated.DateTime == DateTime.MinValue )
                    continue;
                return item;
            }
            return null;
        }

Note, I get more than 1, purely because I want to make sure DateCreated is valid, I am convinced this is 100% unnecessary :) but I have no proof.
 

When my task runs, I store the DateCreated of the last item added in my plugin's database.

When the task gets run after the media scan,  it compares the stored last item added date with the current one.  If the library returns a more recent date, it runs the analysis (which updates the database).  If not, it ends, since no analysis is necessary for the plugin.

 

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