Naming files from local PLEX database

All about user-defined episode / movie format expressions
Post Reply
MaxNZ
Posts: 1
Joined: 07 Oct 2017, 12:46

Naming files from local PLEX database

Post 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
User avatar
rednoah
The Source
Posts: 19156
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Naming files from local PLEX database

Post 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
:idea: Please read the FAQ and How to Request Help.
snickers2k
Posts: 18
Joined: 05 Nov 2016, 15:13

Re: Naming files from local PLEX database

Post 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?)
devster
Posts: 388
Joined: 06 Jun 2017, 22:56

Re: Naming files from local PLEX database

Post 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.
I only work in black and sometimes very, very dark grey. (Batman)
snickers2k
Posts: 18
Joined: 05 Nov 2016, 15:13

Re: Naming files from local PLEX database

Post 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
devster
Posts: 388
Joined: 06 Jun 2017, 22:56

Re: Naming files from local PLEX database

Post 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.
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 19156
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Naming files from local PLEX database

Post 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)
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 388
Joined: 06 Jun 2017, 22:56

Re: Naming files from local PLEX database

Post 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).
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 19156
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Naming files from local PLEX database

Post 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/
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 388
Joined: 06 Jun 2017, 22:56

Re: Naming files from local PLEX database

Post 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.
I only work in black and sometimes very, very dark grey. (Batman)
snickers2k
Posts: 18
Joined: 05 Nov 2016, 15:13

Re: Naming files from local PLEX database

Post by snickers2k »

hey @devster , did you manage to get this working?
User avatar
rednoah
The Source
Posts: 19156
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Naming files from local PLEX database

Post by rednoah »

I've got additional thoughts on the topic. Doing everything within FileBot using Java / Groovy code is probably tricky, and hard to re-use with different 3rd party tools (thus there'll be less of a developer community).


It's probably easier to write some sort of local Python web service (Python so you can use Plex APIs which are mostly available in Python) and then have your custom format do HTTP web requests (with some identifying information, i.e. file name) and then have your web service respond with the desired file path computed with your own Python code interfacing with Plex.


e.g. do HTTP request and get response text

Code: Select all

"http://www.example.org/index.html".toURL().getText('UTF-8')
:idea: Please read the FAQ and How to Request Help.
Post Reply