Recent build changes

Talk about the Ultimate Question of Life, The Universe, and Everything
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: Recent build changes

Post by devster »

Definitely docs on how the mediainfo used for bindings.
Possibly convenience methods for Language and multiple audios.
Right now I'm doing:

Code: Select all

{ def _lang = any{ au["Language"] }{ video.first()["Language"] }
  net.filebot.Language.findLanguage(_lang).ISO3.upperInitial() }
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Recent build changes

Post by rednoah »

1.
MediaInfo changes quite often, so the MediaInfo fields that various bindings are based on are subject to change. I'll see about better documentation, but it'll focus on purpose and possible values, rather than implementation details. That being said, implementation details are and remain available in the public API documentation.


2.
{audioLanguages} is available in recent releases, though it's based on MediaInfo audio stream languages only. Language is on my list of public API classes already, since Language objects are returned by various format bindings.

:?: I've never seen a video stream with Language defined. Is that a thing? Different video streams for different locales?
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: Recent build changes

Post by devster »

rednoah wrote: 11 Jul 2019, 09:15 1.
MediaInfo changes quite often, so the MediaInfo fields that various bindings are based on are subject to change. I'll see about better documentation, but it'll focus on purpose and possible values, rather than implementation details. That being said, implementation details are and remain available in the public API documentation.
The link you provided is more than sufficient. That's how we noticed the changes in mediainfo from v17 to v18 so I'd say it's useful to have.
rednoah wrote: 11 Jul 2019, 09:15 2.
{audioLanguages} is available in recent releases, though it's based on MediaInfo audio stream languages only. Language is on my list of public API classes already, since Language objects are returned by various format bindings.
{audioLanguages} does do Languages but not different audio formats. Most of my movies are BD rips, which means there are commentary tracks with lower audio quality, hence the "convenience". Kim already has a way to extract all audio streams and various info, it's doable.
rednoah wrote: 11 Jul 2019, 09:15 :?: I've never seen a video stream with Language defined. Is that a thing? Different video streams for different locales?
There are files for which a mediainfo language field is set for video but not for audio, for some reason. No idea why they do it, but it comes from the encoders most likely.
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Recent build changes

Post by rednoah »

2.
Strange. If you could make a separate thread and dump the raw MediaInfo tables for these files, that would be appreciated (or maybe even sample files, a few seconds will do). Then I can see about adding a filter to the built-in bindings to ignore commentary tracks.

I've added a new script to make it easy to dump MediaInfo tables:

Code: Select all

filebot -script fn:mediainfo .
:arrow: https://github.com/filebot/scripts/blob ... nfo.groovy

:idea: Same as doing find . -type f -exec mediainfo {} + but works on Windows too.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Recent build changes

Post by kim »

ALL of this a min. must have ( MUST be able to use any path (string), params, Locale and Cache)

net.filebot.web.OpenSubtitlesHasher.* ( computeHash() )
net.filebot.Cache.getCache()

TheTVDB.requestJson()
TheTVDB.getEpisodeList()
TheTVDB.getSeriesInfo()
TheTVDB.resolveImage()
TheTVDB.getArtwork()

TheMovieDB.properties.configuration.images.secure_base_url
TheMovieDB.getArtwork()
TheMovieDB.getAlternativeTitles()
TheMovieDB.request()
TheMovieDB.getMovieInfo()
TheMovieDB.resolveImage()

OMDb.request()

TVmaze.request()

FanartTV.getArtwork()

+ any already in a script
e.g. MediaInfo.snapshot()

and to be sure it still will work:
File.metadata
_args.order
instanceof MultiEpisode
.nameWithoutExtension

my script is 1600 lines atm so I maybe forgeting something
Last edited by kim on 11 Jul 2019, 17:35, edited 1 time in total.
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Recent build changes

Post by rednoah »

Do you happen to have a GitHub repository? Then I could add it to my integration tests to make sure it "compiles" at the very least.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Recent build changes

Post by kim »

No, I do not
but here is an old "cutdown" version
viewtopic.php?f=4&t=5451

I'm working on a new version with more stuff, but this takes a long time
Last edited by kim on 11 Jul 2019, 17:41, edited 1 time in total.
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Recent build changes

Post by rednoah »

No worries. I'll at the TheTVDB / TheMovieDB / etc client classes to the public API list.

Fortunately, most of it is already public API and generally not subject to change:
* https://www.filebot.net/docs/api/net/fi ... a.io.File)
* https://www.filebot.net/docs/api/net/fi ... web.Movie)
* ...
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Recent build changes

Post by kim »

when will it be added ?
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Recent build changes

Post by rednoah »

You mean comprehensive docs in general, cause that will take time... or are you asking about something more specific?

What specific TheTVDB / TheMovieDB features do you need? Because I'd rather implement public API for whatever information you might need, via extension methods similar to Movie.alternativeTitles, rather than giving you direct access to the client classes (which are subject to change, and may become inaccessible in the future due to JMS module restrictions at runtime, or possibly ahead-of-time compilation if GraalVM works out).

i.e. you share the code where you use these generic API access methods?

Code: Select all

TheTVDB.requestJson()
TheTVDB.resolveImage()

Code: Select all

TheMovieDB.properties.configuration.images.secure_base_url
TheMovieDB.request()
TheMovieDB.resolveImage()
:arrow: I'd rather implement code for all the requirements you (or others) might have, and then make it available via Movie class extension methods, so you don't need to do the plumbing yourself.



EDIT:

I've added the requested classes to the docs:
https://www.filebot.net/docs/api/net/fi ... lient.html
https://www.filebot.net/docs/api/net/fi ... lient.html

:idea: Since the methods aren't even public in the internal API, they won't show up in the docs, so just click on any public method to see the source, and then scroll to what you are interested in. Naturally, this is a bad solution. Best to write proper public API.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Recent build changes

Post by kim »

That looks like most of it, but not all e.g.

net.filebot.web.OpenSubtitlesHasher.* ( computeHash() )
net.filebot.Cache.getCache()
MediaInfo.snapshot()

The problem with this is you have all the power, e.g. you will not support episode in amc/htpc viewtopic.php?f=6&t=3660#p20471

Can you give me some samples of "subject to change" ?
(to me "restrictions" sounds like I can't do all I need = less Filebot)
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Recent build changes

Post by rednoah »

kim wrote: 05 Aug 2019, 18:24 The problem with this is you have all the power, e.g. you will not support episode in amc/htpc viewtopic.php?f=6&t=3660#p20471
Well, TheTVDB / TheMovieDB API is not infinite, and FileBot will implement as much as necessary. It makes sense to implement more of it, so that I can expose it as stable public API to you via scripting.


Note that I have already introduced public API for this particular use case, i.e. Episode.getInfo() allows you to get per-episode information in both format and scripting:

Code: Select all

filebot -list --q Firefly --format "{episode} => {episode.info.director} | {episode.info.writer} | {episode.info.overview}"

Using internal API is possible by nature of Groovy, not because it's wise, and maybe at the time no better option was available, and so now we're stuck with having lots of code that relies on internal APIs, and I'm stuck having to worry about unexpectedly breaking things whenever I refactor things (which means I will avoid refactoring code) because I have absolutely no idea what is being used and what isn't.


I once changed the name space from net.sf.filebot.* to just net.filebot.* and that broke all formats that used internal API. I accidentally broke lots of formats because constructs like {{vc} + {ac}} (an accidental feature I wasn't even aware of) stopped working. MediaInfo related code keeps breaking for corner cases all the time, since MediaInfo changes behaviour with each version.


TL;DR If you use internal API, do so at your own risk, don't blame me if things break. That's what internal API means. It's probably gonna be fine, but it might not. Since I don't know what you're doing, I cannot tell you what might break.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Recent build changes

Post by rednoah »

Code: Select all

net.filebot.web.OpenSubtitlesHasher.* ( computeHash() )
net.filebot.Cache.getCache()
MediaInfo.snapshot()
I don't have public API for these because I don't have a use case yet. You can provide one.


:idea: There is File.getMediaCharacteristics() but that's either a MediaInfo object or a FFProbe object. (I've added implementing classes for MediaInfo and FFProbe to the docs, though I wouldn't strictly call them public API. I've just added them for your convenience. Use at your own risk.)


:idea: MediaInfo.snapshot() is meant for debugging if you don't know what raw MediaInfo properties there are. It is likely best to use getMediaInfo(file, "{vf}") if you need something specific so that you can use the usual format bindings (which typically try various MediaInfo fields to make it work regardless of underlying libmediainfo version).


:idea: IDK what you use Cache for. Depending on how you use it, a public Cache interface might make sense, or more API interfaces so you don't need to worry about the Cache yourself.


:idea: OpenSubtitlesHasher, AFAIK, it's only useful for OpenSubtitles search requests, and FileBot already implements those. I'd be curious what you use it for, so I can think about a good way of exposing it (or void the need to access it directly in the first place).




TL;DR These things should have been done properly from the beginning, with clearly defined public interfaces, rather than just accessing internal classes directly. That was my fault. Advanced custom scripting just wasn't a priority 3-4 years ago, and these kludgy solutions were just kinda there.




EDIT:

Note that the timing for these "restrictions" is not random. The whole point of Java 9 / 10 / 11 is modularization, which means properly defining and strictly enforcing at runtime all the dependencies within a system. Once Java 8 support is no longer necessary, it will be dropped, and with a proper Java 11 port comes proper modularization and clearly defined access restrictions between modules (which Groovy can't just ignore since the JVM natively enforces them). Things will break. If I have known use cases (i.e. test cases) then I will notice the issue and fix the issue. If not, then backwards compatibility issues will go unnoticed.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Recent build changes

Post by kim »

If Filebot's "public API" does not provide access to EVERYTHING e.g. thetvdb's api does for series, episode, artwork...
I need an alternative like TheTVDB.requestJson, same goes for every other api/data.

Code: Select all

{episode}
e.g. cant use, because missing info:
filename (thumb)
imdbId
dvdSeason
dvdEpisodeNumber

this is the min. ref. https://kodi.wiki/view/NFO_files
I use this plus more in my nfo's

Code: Select all

MediaInfo.snapshot()
You do know you use it in the htpc ?
https://github.com/filebot/scripts/blob ... roovy#L256

Code: Select all

getMediaInfo(file, "{vf}")
Again I need access to EVERYTHING like MediaInfo.snapshot() does

Cache:
I use Cache for any resource that does not use Cache
e.g.

Code: Select all

net.filebot.Cache.getCache('IMDbData_JSON', net.filebot.CacheType.Weekly).computeIfAbsent(IMDbId) {}
OpenSubtitlesHasher:
I use

Code: Select all

computeHash(inputFile)
e.g. fast way to find duplicates files

I have no problem with things breaking, as long as it's possible for me to fix.
(also a good way to learn code)
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Recent build changes

Post by rednoah »

1.
I have to think about better EpisodeInfo API support, because ideally you shouldn't need to know TheTVDB / TheMovieDB / TVmaze / etc API details to use that. I'll look into it.


2.
In the meanwhile, I've added these extension methods. I've added GroovyObjectSupport to make it easier to navigate the MediaInfo data structure.

Code: Select all

def f = '/path/to/file' as File

// Get Format property of Video Stream #0
println f.mediaInfo.Video[0].Format

// Iterate audio streams
f.mediaInfo.Audio.each{ 
	println it.StreamKindID
	println it.Format
}

Code: Select all

f.hash 'moviehash'  // OpenSubtitles Movie Hash
f.hash 'crc32'
f.hash 'md5'
f.hash 'sha256'

EDIT:

Added artwork extension methods:

Code: Select all

{episode.seriesInfo.artwork}
(tentatively) Added extension methods for raw json objects:

Code: Select all

{episode.seriesInfo.raw}

Code: Select all

{episode.info.raw}
(currently only implemented for TheTVDB)
:idea: Please read the FAQ and How to Request Help.
Post Reply