Episode Metadata From Within Script

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
wtchappell
Posts: 1
Joined: 15 Sep 2013, 07:22

Episode Metadata From Within Script

Post by wtchappell »

There's all this wonderful information that rename() is willing to populate into a new filename based on format - e.g., episode number, special number, part number, actors, director, etc.

How do I get access to the object that has this information in my script? I see that there are functions for parsing out a few of these pieces of information from the name of the file, but there isn't anything for others - like telling if a file is a special.
User avatar
rednoah
The Source
Posts: 23936
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Episode Metadata From Within Script

Post by rednoah »

rename() is way too complicated and that nice metadata is only available after lots of processing.

If xattr is enabled then rename() will store primary metadata via xattr. So after rename() you can read the information via File.xattr.metadata (JSON String) or File.metadata (FileBot Episode/Movie Object).

To get extended metadata like director and actors you'd have to further hook into internal APIs.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 23936
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Episode Metadata From Within Script

Post by rednoah »

The latest SVN revision makes this easier. Like so:

Code: Select all

def e = '''{"@type":"net.sourceforge.filebot.web.Episode","seriesName":"Firefly","seriesStartDate":{"year":2002,"month":9,"day":20},"season":1,"episode":1,"title":"Serenity","absolute":1,"special":null,"airdate":{"year":2002,"month":12,"day":20},"series":{"@type":"net.sourceforge.filebot.web.TheTVDBSearchResult","seriesId":78874,"name":"Firefly","aliasNames":[]}}'''
def m = '''{"@type":"net.sourceforge.filebot.web.MoviePart","partIndex":1,"partCount":2,"year":2009,"imdbId":-1,"tmdbId":19995,"name":"Avatar","aliasNames":[]}'''

e = e.jsonToObject()
m = m.jsonToObject()

println e.mediaBinding.name
println m.mediaBinding.name

def f = /path/ as File
println f
println f.mediaBinding.name
println f.mediaBinding.fileName
:idea: Please read the FAQ and How to Request Help.
Post Reply