Hmmm…Looked at your code, but…
I really doubt, that the local bif file will make it to the database…
PMS is hardcoded to only look in the origen path for a bif file…
So why the Analyze stuff ?
And if correct, then token, plex.tv stuff etc is also not needed 
/T