Custom databases via --db db.groovy

All your suggestions, requests and ideas for future development
Post Reply
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Custom databases via --db db.groovy

Post by devster »

Is it currently possible or would it be feasible to have *.groovy files as arguments to the --db option?
This would make the database support easier to extend (e.g. I'm interested in IMVDb which is niche but has an official API).
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Custom databases via --db db.groovy

Post by rednoah »

Sorry, not supported.
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: Custom databases via --db db.groovy

Post by devster »

I've seen quite a few posts requesting niche databases to be added, like SetList.fm, something for books, comics, and alternative TV/movie DBs.
I realise adding support for all would be completely unfeasible, but would a pluggable DB be feasible?
Scripts would just have to perform requests to an API (likely with personal keys) and return a flexible structure (?) to FileBot for further processing.
Maybe this could be considered as a feature request for v5?
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Custom databases via --db db.groovy

Post by rednoah »

Well, the main reason we don't have support for niche databases isn't APIs, those can be implemented in a day or two. The problem is support for niche content types. FileBot has no way of identifying and matching "books" or "comics" or even "music" for that matter.


That being said, if you use --db file then you could effectively write your own "agent" as part of your own custom --format expression. You have the file name, file attributes, MediaInfo, etc. The rest is up to your code.


e.g. you can create your own web service that transforms original file name to desired file name and then have your plain file format just refer to that:

Code: Select all

{	
	def url = new URL("https://postman-echo.com/get?fn=${fn}")
	def json = new groovy.json.JsonSlurper().parse(url)
	return json.args.fn
}
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: Custom databases via --db db.groovy

Post by devster »

Good enough for me.
I’ll try and report, but this way I’d be missing a lot of the name processing and cleaning that Fb does, right?
Any way or docs to take advantage of it before querying?

Also I’d better hope the first result is the one I want as no refinement will be made on query results, right?
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Custom databases via --db db.groovy

Post by rednoah »

devster wrote: 06 Jun 2020, 18:39 I’ll try and report, but this way I’d be missing a lot of the name processing and cleaning that Fb does, right?
What kind of cleaning and processing are you looking for in the context of books and comics? You can write all your code in a big local format, but I don't think FileBot has much to offer in this context.

devster wrote: 06 Jun 2020, 18:39 Also I’d better hope the first result is the one I want as no refinement will be made on query results, right?
My example is just an example. It's raw Groovy code. As simple as possible. Send HTTP request. Parse result as JSON. Select JSON element. No more. No less. No magic. ;)
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: Custom databases via --db db.groovy

Post by devster »

Cleaning would be for names such as:

Code: Select all

Packing_for_Mars__The_Curious_Science_of_Life_in_the_Void.epub # replace _ with space and multiple _ with -
'Revival By Stephen King [pdf epub mobi azw3 pdb]' # remove formats
'[REQ] James S A Corey - The Expanse Series - book 4 Cibola Burn (epub and azw3)' # remove initial [REQ] and formats
'Manuali delle giovani marmotte - Vol. 2 Vol. 3 Vol. 5 Vol. 6 Vol. 7 Vol. 8 Vol. 9' # remove Vol.
I believe some of this is already done by FB.
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Custom databases via --db db.groovy

Post by rednoah »

Well, String.space() is a built-in helper that you can use. The rest is tricky, because it's rather specific to books, so the existing Movie / Episode specific code won't help much here. Besides, isn't each of those uses cases just a simple regex one-liner? Checking through the FileBot API for potentially useful functions will take much longer, and probably work less well, when you can easily write the code yourself in a few minutes.

e.g.

Code: Select all

/[ ._]+/
/\[.+?\]/
/Vol\D*\d+/
:idea: Please read the FAQ and How to Request Help.
Post Reply