Jump to content

API call timing


foleys

Recommended Posts

Hello,

I'm having what appears to be a timing issue with a powershell script. My script works, so I don't see merit in posting the code to be picked apart, but of course I'm willing to go down that path if that's what is best. The basic concept is that I replace a movie on my hard drive and then make some API calls to emby to ensure the new version of the movie gets put back into the same collections as the replaced movie. My script moves the original movie out of an emby monitored folder, moves the new movie to replace the original movie, and then I call the emby library refresh API to find the new movie. The replacement movie will always have a different directory and filename. I loop until I can get the ID of the new movie from emby, and then I add that new movie ID to the collection(s). If I add the new movie to a collection immediately after the new movie is added into emby, then it does not seem to stick. I even have subsequent code to get the items in the collection to verify that the movie exists, and it does, but it disappears shortly after. If I add a 5 second sleep directly before the API call that adds the new movie to the collection, then it seems to work consistently every time. Obviously I could just keep the sleep, but this seems like a bug.

Thanks!

Link to comment
Share on other sites

HI, this is just a guess, but you're probably adding it to the collection before the initial metadata download has completed. That metadata download process is going to update collection information for the new movie.

Link to comment
Share on other sites

If that's the case, is there a way to know that emby is done messing with the new movie, so I can perform my actions? I would have thought just having access to the movie ID would be enough.

Link to comment
Share on other sites

On 10/18/2022 at 4:59 PM, foleys said:

If that's the case, is there a way to know that emby is done messing with the new movie, so I can perform my actions? I would have thought just having access to the movie ID would be enough.

Assuming you're polling the api on an interval, then you could check for the presence of internet metadata. For example, see if any ProvderIds are populated, and don't modify the collections until they are.

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