Convert Plex log file string /library/metadata/XXXX to filepath

I’m making a python script that parses Plex log file events, and I need to get the filepath of the media file that is referenced in certain log entries.

The logs contain this string…:

/library/metadata/XXXX <-- a number

… and I would like to somehow fetch the location of the actual media file of that number.

how2do?

It takes several interactions with the database to convert.

The path of least resistance is:

There’s a lot of code to look thru here. Do you happen to know which modules demonstrate the lookup?

Also, does the python PlexAPI not have this ability?

I do not follow third party apps.
I happen to know WebTools because I helped Dane22 (a ninja) with the Synology installation package creation.

I don’t know if this is what you are looking for, but there is no direct way to convert that to the path. However, with that, you can call up the XML for that item. It’s the same call made when using the “get info”/“View XML” functions from Plex Web. That XML will then have the path you can parse out.

Solution. Use the python PlexAPI fetchItem method…

https://python-plexapi.readthedocs.io/en/latest/modules/base.html#plexapi.base.PlexObject.fetchItem

If an int is passed in, the key will be translated to /library/metadata/. This allows fetching an item only knowing its key-id.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.