Page 1 of 1

Naming files from local PLEX database

Posted: 07 Oct 2017, 12:52
by MaxNZ
Hi,

I have flex database fully populated with correct data for each movie/show. However, file names are all out of wack, so I wanted to use Filebot to rename files based on existing Flex database. So when renaming files I'd like Filebot to lookup my local PLEX database instead of online one.. How can this be done? Thanks

Re: Naming files from local PLEX database

Posted: 07 Oct 2017, 22:05
by rednoah
There is no built-in support.

It's perfectly possible though, by writing a custom format that somehow talks to the database and gives you the correct file path based on that. You'd need some Java/Groovy skills for that.

If you could export your database into an easy-to-read file then it'd be much easier:
viewtopic.php?f=8&t=5373

Re: Naming files from local PLEX database

Posted: 21 Aug 2019, 11:09
by snickers2k
@rednoah, this would be a huge feature request. I'm missing this feature for Years now... :/

I guess many of us fixing incorrect matches directly in Plex. But the original filename is still not appropriate. This is a huge Problem.

(Maybe it could be even useful (especially for cloud-users) to use the Plex-db completely, instead of xattr, to lower hits?)

Re: Naming files from local PLEX database

Posted: 21 Aug 2019, 18:40
by devster
Plex matching doesn't need to be fixed if filename is correct, it's a bit of a chicken-n-egg scenario.
Also the request is non-trivial, as searching the Plex DB using the available API for the file name doesn't return a result.

Re: Naming files from local PLEX database

Posted: 22 Aug 2019, 13:24
by snickers2k
Thats true. But i personally have bad expierence without "-non-strict" mode, since there is not always a Year in the title. For example without -non-strict, Title "Baywatch" , without the Year it's doing nothing because of not being able to differentiate "Baywatch Nights". -non-strict is oppurtunistic enough to match "Baywatch".

But this can fail - and it does.

Another thing would be this example: "Noch.Drei.Maenner.noch.ein.Baby.1987.German.AC3D.DL.720p.WebHD.mkv". Filebot is not able to match this, altough i don't know why, because tmdb can find this title. But anyways, Plex had no Problem to recognize.
So being able to get those information from Plex directly would be great.

This is exactly what i'm looking for, but only embedded in filebot: https://github.com/rieck/perplex

Re: Naming files from local PLEX database

Posted: 22 Aug 2019, 22:54
by devster
The script queries an sqlite3 DB.
I think you might be better off exporting it to another format and try using that to rename your files.
rednoah might be able to help more with this.

Re: Naming files from local PLEX database

Posted: 23 Aug 2019, 03:17
by rednoah
If you could rename the information you need via Groovy, either from the sqlite3 db directly or some text file, then you can use generic file mode, and assemble the destination file name with your own custom code:
viewtopic.php?f=3&t=2072

e.g. if you could write *.nfo files for each movie / episode files, then that would make writing custom formats easy (e.g. similar to the examples listed in the post above)

Re: Naming files from local PLEX database

Posted: 23 Aug 2019, 07:47
by devster
Kodi exports to nfo files, Plex unfortunately doesn't (natively).
Can FileBot script query an sqlite db without any additional dependencies?
If querying is possible, the process could be much simpler, as the DB should contain a line with the precise file name and path, and Plex has an API to update the DB afterwards).

Re: Naming files from local PLEX database

Posted: 23 Aug 2019, 09:23
by rednoah
devster wrote:
23 Aug 2019, 07:47
Can FileBot script query an sqlite db without any additional dependencies?
Not sure. Probably not though, since FileBot doesn't use sqlite internally. The JRE or Groovy runtime might include some sort of built-in API though.

@Grab should work in scripts to retrieve and load additional dependencies at Groovy runtime:
:arrow: http://docs.groovy-lang.org/latest/html ... grape.html
:arrow: http://www.octodecillion.com/groovy-with-sqlite/

Re: Naming files from local PLEX database

Posted: 23 Aug 2019, 10:01
by devster
I'll try, this could actually lead to some pretty interesting formats.
Dynamic class loading is one of the things that won't work with GraalVM though.