Naming files from local PLEX database

All about user-defined episode / movie / file name format expressions
snickers2k
Posts: 26
Joined: 05 Nov 2016, 15:13

Re: Naming files from local PLEX database

Post by snickers2k »

but still, i don't understand why this is not possible with filebot .. emby/plex is often the only place where stuff is organized in messed up libraries .. so converting back from plex/emby db's seems like a obvious thing to do :/

well thanks anyway
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Naming files from local PLEX database

Post by rednoah »

Why not go with the previously suggested solution though? The XML file does seem to include the file paths for each file in the library, no?
viewtopic.php?p=54468#p54468

1. Use Tautulli to export the information we need as easy-to-read XML file
2. Use custom Plain File Format to generate nice file paths based on the information in the XML file
3. Done
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Naming files from local PLEX database

Post by kim »

snickers2k wrote: 01 May 2021, 20:35 yeah i'm sorry but i found out too late that there is no filepath exported to work with :/
e.g.

Code: Select all

<location>/mnt/media/Spielshows/Denn sie wissen nicht was passiert/Denn.sie.wissen.nicht.was.passiert.S03E04.GERMAN.1080p.HDTV.x264-aWake-xpost/awa-desiwiniwapas03e04xd.mkv</location>
or

Code: Select all

...file="/mnt/media/Spielshows/Denn sie wissen nicht was passiert/Denn.sie.wissen.nicht.was.passiert.S03E04.GERMAN.1080p.HDTV.x264-aWake-xpost/awa-desiwiniwapas03e04xd.mkv"...
path changed? just search / replace = EASY!!!
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Naming files from local PLEX database

Post by rednoah »

kim wrote: 02 May 2021, 16:33 path changed? just search / replace = EASY!!!
Well, I guess Plex wouldn't be able to find / play the file it wasn't where Plex thinks it is anyway.


But even if we were to use the exported XML file from a remote server, and then run FileBot on the local Desktop, the file name alone is probably unique enough to establish a 1:1 link so we don't need to rely on an exact file path match:

Code: Select all

dom.show.season.episode.media.part.find{ it.'@file'.text().toFile().name == f.name }
e.g.

Code: Select all

{
	// find <part> element for the file at hand
	def dom = xml('/path/to/library.xml')
	def part = dom.show.season.episode.media.part.find{ it.'@file'.text().toFile().name == f.name }

	// navigate parent elements and access attributes
	def n = part.'..'.'..'.'..'.'..'.'@title'.text()
	def s = part.'..'.'..'.'..'.'@index'.text() as int
	def e = part.'..'.'..'.'@index'.text() as int
	def t = part.'..'.'..'.'@title'.text()

	// generate file name
	"${n} - S${s.pad 2}E${e.pad 2} - ${t}"
}
:idea: Please read the FAQ and How to Request Help.
Post Reply