I’ve been working on code for my agent that will download trailers and subtitles for a video then automatically move the video, trailer, and subtitles into an appropriately named folder using the naming convention and file structure plex recommends these extras. After digging into the existing plex code I was able to achieve this once I saw that I could call media.all_parts()[0].file in the update method of my agent to know where the file being processed for metadata is located.
My goal now is to find a way to point plex to the new location of the video file so I can avoid the refresh scan plex automatically does to find the file once it realizes the file was moved. The issue with this refresh for me is that if it often locks up mid refresh and inevitably crashes the server(this crash was already happening back when I was manually doing what I wrote the code to do). My first thought to point plex to the new video location after I moved it in code was to set media.all_parts()[0].file to the new location, but it ended up not being that simple. Can I get some input from a dev on what I would need to do to correctly move the file in code?