[REQ] Artwork Scripting Change

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
part timer
Posts: 181
Joined: 09 May 2012, 23:35

[REQ] Artwork Scripting Change

Post by part timer » 30 Jul 2012, 06:05

I don't have the skills to pull something like this off, so I'm wondering if you could add it into the tmdb artwork scripts for xbmc and others I'm sure. Maybe if you wanted ### tagged out by default in case people don't want it, but I think it's a nice feature.

1. Change the backdrops that come from tmdb to fanart.jpg or <moviename>-fanart.jpg. The first naming works if movies are kept in separate folders, which I'm guessing most people do. The second option actually works in all environments, so technically it is superior for compatibility, but doesn't look quite as clean and nice. I'll let you think about that one. The other reason I think like that, is that I actually do have different versions of the same movie in the same folder, so for me they just all use the same generic fanart.jpg instead of each having their own.

Anyways,

2. Download the best choice of fanart, which I'm sure it currently does, as the filename chosen from part 1. Download all of the fanarts(backdrops) for that movie including the one just downloaded into 'extrathumbs/thumbN.jpg' subfolder of the current movie folder where N starts at 1 and changes incrementally by one up to however many there are. This is nice when you want to change your fanart later on with xbmc, nice and easy to switch to another high quality version.

3. When downloading the poster that it chooses save it as folder.jpg and movie.tbn, I actually add the third poster.jpg in for mine as well. The folder.jpg gets used for windows and I'm sure other programs when looking in an explorer type view. Depending on which skin you are using for xbmc apparently it doesn't always get used there.

I think these would be some nice enhancements for the current scripting.


reference with lots of example structures:
http://forum.xbmc.org/showthread.php?tid=59281

Discussion on why folder.jpg won't display as movie poster in some skins at least:
http://forum.xbmc.org/showthread.php?tid=133102

Another example from me:
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\[SD] [340p] [DVDRip] [XviD] [MP3] [DUQA] SomeMovie([2009].PREMIERE.DVDRIP.XVID.[Eng]-DUQA).avi
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\[SD] [340p] [DVDRip] [XviD] [MP3] [DUQA] SomeMovie([2009].PREMIERE.DVDRIP.XVID.[Eng]-DUQA).nfo
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb1.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb10.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb11.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb12.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb13.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb14.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb15.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb16.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb17.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb2.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb3.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb4.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb5.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb6.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb7.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb8.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\extrathumbs\thumb9.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\fanart.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\folder.jpg
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\movie.tbn
T:\Media\SomeMovie [2009] [Rated PG-13] [Voted 7.0] [IMDB tt0xxyyzz ]\poster.jpg
Thanks for considering it.


PS. As for the nfo it is awesome that filebot can put that together but if you are using it with xbmc, the problem is that it takes the nfo in the folder as the authority and instead of going to the internet to fill in the gaps of missing information, simply leaves out any information that isn't in that nfo file.

When you have time is it possible you could take a look at this site to see all of the fields in the xbmc nfo's:
http://wiki.xbmc.org/index.php?title=Im ... _nfo_Files
although <filenameandpath> I don't have in any of my nfo's

That's actually the reason I went back to wanting to use Ember, it grabs it all and makes my library more filled out on the xbmc.
This means that nfo's override the scraper setting. I.e. a directory is set to use the imdb scraper but you have a German movie in it. Simply create a nfo for that movie with the ofdb link in it and you are sorted!
So maybe throwing in the movie url from imdb or tmdb at the bottom of the nfo like in the examples below would be a good thing, that way it could grab the missing details.
Video nfo files containing a mix of XML and URL
You can also create nfo files that contain both XML data and an URL. This is useful for instance, if you want the entry in your database to have another name than the one officially provided by the scraper, for the movie to sort differently or the movie to be a part of a movie set.

Example:
<movie>
<title>Sin City (Recut, Extended, Unrated)</title>
<runtime>147 min.</runtime>
</movie>
http://www.imdb.com/title/tt0401792/


<movie>
<title>Star Wars (1977 Original Theatrical Release)</title>
<runtime>121 min.</runtime>
<set>Star Wars Saga</set>
<sorttitle>Star Wars1</sorttitle>
</movie>
http://www.imdb.com/title/tt0076759/

By default the xml entry is added to the scraped entry in the database and may result in some duplicates. If you want to completely override the scraped result you need to set a clear attribute for the relevant xml tag in the nfo file.

Example:
<movie>
<genre clear="true">Action</genre>
<genre>Horror</genre>
<genre>Thriller</genre>
<director clear="true">Frank Miller</director>
<director>Robert Rodriguez</director>
<director>Quentin Tarantino</director>
</movie>
http://www.imdb.com/title/tt0401792/

Currently supported tags for the clear attribute are genre, director, studio, actor, credits and artist for Music Videos.
Thanks again

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [REQ] Artwork Scripting Change

Post by rednoah » 30 Jul 2012, 10:17

1. I don't care about flat file structure. Besides, the artwork scripts only work a movie folder structure anyway.

1. and 3. Added lots of that stuff already over the past few weeks. It's in the SVN but won't be online till the next major release where everything will break for people using older versions.

Right now I'm using the naming conventions from here:
=> http://wiki.xbmc.org/index.php?title=Ad ... Filenaming

2. Not gonna add that. That'd just be encouraging people to waste time trying different backdrops when all of them are really good anyway. Besides, the one you get is the most popular one anyhow.

3. With the latest SVN rev/script I add everything I get from TheMovieDB v3 API. I'll just add some links if it helps, but as xml elements, everything else would be just wrong.

I don't add mediainfo data right (codec, lang, etc) now. Doesn't XBMC grab that stuff by itself if it's not in the NFO?
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: [REQ] Artwork Scripting Change

Post by part timer » 30 Jul 2012, 11:41

rednoah wrote:1. I don't care about flat file structure. Besides, the artwork scripts only work a movie folder structure anyway.
Ok, so I guess fanart.jpg it is then
rednoah wrote:1. and 3. Added lots of that stuff already over the past few weeks. It's in the SVN but won't be online till the next major release where everything will break for people using older versions.
Ok, again, hopefully using the new naming mentioned, cool.
rednoah wrote:Right now I'm using the naming conventions from here:
=> http://wiki.xbmc.org/index.php?title=Ad ... Filenaming
Probably a good idea, since it is setup for xbmc
rednoah wrote:2. Not gonna add that. That'd just be encouraging people to waste time trying different backdrops when all of them are really good anyway. Besides, the one you get is the most popular one anyhow.
Maybe, but the whole point for me is that it's automated, so it saves the time of checking later, if you don't quite like that one. It could be getting it for you at 3am or something so it's just kind of like caching it to me to save you time for you when you do want to look. I personally would be getting them anyways, so would rather just get them up front. For me, that's one of those things I was hoping you could add (since I have no idea how) and then if you wanted comment it out, so only those that want to use it can use it.
rednoah wrote:3. With the latest SVN rev/script I add everything I get from TheMovieDB v3 API. I'll just add some links if it helps, but as xml elements, everything else would be just wrong.
Well, yeah, if everything that can be scraped is added then that's nice. Before there were things that filebot could get that were not in the nfo, so you just wouldn't get that info about the movie.
rednoah wrote:I don't add mediainfo data right (codec, lang, etc) now. Doesn't XBMC grab that stuff by itself if it's not in the NFO?
You don't need to because xbmc will grab it, but my initial thought was that I wished it was included. Otherwise xbmc takes a minute or two to read the file and populate the fields. Just one more thing that filebot could do automated that xbmc wouldn't have to. Then I think once xbmc figures out that data, I'm pretty sure it puts it in it's database so it doesn't need to figure it out next time. Thinking about it right now though, with my setup of sometimes having multiple movie versions in one folder I guess I wouldn't want this included because then it would probably tell me all of the versions had the same mediainfo because it would read it the first time and not bother to get a new nfo each time.

Well again, depending on how you are naming your nfos. If you are calling them movie.nfo then this wouldn't work for me, but if you call them <matching file name>.nfo which doesn't break anything then that works. If I can have everything spoon fed to my xbmc, so it doesn't have to do it, it makes my experience of sitting down in front of the tv just a little bit nicer and smoother.

Maybe what I would wish for then would be to have an input block at the top and have defaults for those that don't want to customize, but let people remove the # to add support of the stuff they want (extrathumbs fanart, fanart naming convention, nfo naming, utorrent labels for tv and movies to take more guess work out of it).

Something like:
# How much fanart to download:
favorite choice
# all (saved as extrathumbs/thumbN.jpg)

# Fanart naming
fanart.jpg
# <movie file>-fanart.jpg

# nfo naming
movie.nfo
# <movie file>.nfo

# uTorrent Movie and TV labels
# If uTorrent label starts with the following don't try to guess what it is (comma separated)
# TV episodes
# ~TV
# Movies
# ~Movies, ~Couch Potato
# Anime
# ~Anime
# Something you want filebot to ignore and not process
# ~Music, ~Other Stuff, ~Ebooks maybe

#Email setup info for sending confirmations of new stuff added to library

I know I would love something like that. I'm sure lots of people could figure out how to customize it for themselves, but I also think this might lessen your load a bit. Do it the first time, and then after that you don't really have to, for every time someone asks you to afterwards. It's just done already.

Those are my thoughts, not that you asked for them ;)

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [REQ] Artwork Scripting Change

Post by rednoah » 30 Jul 2012, 17:08

* Forcing movie/series/anime mode makes sense. Added support for that.
* Out of the box email support. Done.
* Putting MediaInfo data into the .nfo files. Because I can.


As for TMDb info that's not included in the .nfo, send me that stuff.
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: [REQ] Artwork Scripting Change

Post by part timer » 29 Sep 2012, 06:59

So tonight I thought I would try the standalone artwork script out, because sometimes ember gives me hassles and it downloads TONS and TONS of covers, when I'm generally happiest with whatever is the main on tmdb. But I got a problem. And a question that still lingers for me.

1. I copy and pasted how to run the script from the top of the script and substituted my directory, but I got this instead of what I wanted.

Code: Select all

IllegalArgumentException: java.io.FileNotFoundException: lib\htpc
FileNotFoundException: C:\Program Files\FileBot\Temp\High
java.io.FileNotFoundException: C:\Program Files\FileBot\Temp\High
        at Script2$_run_closure15.doCall(Script2.groovy:22)
        at Script2$_run_closure16_closure71.doCall(Script2.groovy:23)
        at Script2$_run_closure16.doCall(Script2.groovy:23)
        at Script2$_run_closure19.doCall(Script2.groovy:27)
        at Script3.run(Script3.groovy:11)
        at net.sourceforge.filebot.cli.ScriptShell$1.run(Unknown Source)
        at net.sourceforge.filebot.cli.ScriptShell.evaluate(Unknown Source)
        at net.sourceforge.filebot.cli.ScriptShell.runScript(Unknown Source)
        at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)

        at net.sourceforge.filebot.Main.main(Unknown Source)
Failure (░_░)
2. I still really would like all of the fanart downloaded for each movie. The most popular can be called fanart, but I'd still like the rest in a subfolder in that movie directory called extrathumbs and each fanart named thumb1.jpg, thumb2.jpg, etc, etc. If others don't want it, it could be off by default and anybody else that does could call it as artwork=yes, extrathumbs=yes or something. I know for me it would be much nicer and I could change out the ones I want with ember instead of going online, manually searching, looking, downloading the image, changing it. It's a lot more streamlined to change it with ember after.

Glad to have me back annoying you, right? Don't answer that ;)

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [REQ] Artwork Scripting Change

Post by rednoah » 29 Sep 2012, 07:13

The logic for grabbing artwork is in lib/htpc.groovy so it can be included in different scripts. You'll need to download both artwork script + dependencies if you wanna run it completely local. It's possible to have local startup script but then include an online script, e.g. include('fn:lib/htpc')

If you don't need to modify anything just run with fn:name syntax and it'll work out of the box:
http://filebot.sourceforge.net/forums/v ... 4&t=5#p205
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: [REQ] Artwork Scripting Change

Post by part timer » 29 Sep 2012, 07:20

That's what I tried.

filebot -script fn:artwork.tmdb M:\Video\Movies Temp\High Res\Abraham Lincoln vs. Zombies [2012] [Voted 3] [IMDB tt2246549 ]

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [REQ] Artwork Scripting Change

Post by rednoah » 29 Sep 2012, 08:51

SPACE is argument separator, you need to use "..." if the argument has spaces. You should do some basic tutorial on how to use the cmdline. :P

Code: Select all

filebot -script fn:artwork.tmdb "M:\Video\Movies Temp\High Res\Abraham Lincoln vs. Zombies [2012] [Voted 3] [IMDB tt2246549]"
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: [REQ] Artwork Scripting Change

Post by part timer » 29 Sep 2012, 09:10

Yes, you are probably right, although my memory is very short. For future events though you may want to include the quote marks in the first line of the scripts to prevent other people from repeating the same mistake. I'm sure someone else is bound to fall for it, especially when it's late at night and copy and paste is so appealing, and I'm assuming that having the quotes there even if there are no spaces wouldn't hurt anything.

Thank you btw.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: [REQ] Artwork Scripting Change

Post by part timer » 29 Sep 2012, 09:19

Alrighty, I guess I should have tried it out again before posting, but I do get a shorter amount of errors now.

Tried

Code: Select all

filebot -script fn:artwork.tmdb "M:\Video\Movies Temp\High Res2\Click  [2006]  [Rated PG-13]  [Voted 7]  [IMDB tt0389860 ]"
and got

Code: Select all

IllegalArgumentException: java.io.FileNotFoundException: lib\htpc
Movie not found: Click  [2006]  [Rated PG-13]  [Voted 7]  [IMDB tt0389860 ]
Done ?(?????)?
I noticed in the script it doesn't have the fn with the include, but then maybe it doesn't need it. I don't know. Maybe my version is too old. I think the last one I installed was 2.6something. Maybe that could do it?

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [REQ] Artwork Scripting Change

Post by rednoah » 29 Sep 2012, 09:30

It'll work with 3.0 then.
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: [REQ] Artwork Scripting Change

Post by part timer » 29 Sep 2012, 11:02

I was hesitant. I like what I have going with the version I have. I generally don't like upgrading any software until I need to. Guess I'll try it.

Back to my number 2 question tho, (If I knew how to modify the script just for myself I would of course, but it's out of my league, and others might like it too)

part timer wrote: 2. I still really would like all of the fanart downloaded for each movie. The most popular can be called fanart, but I'd still like the rest in a subfolder in that movie directory called extrathumbs and each fanart named thumb1.jpg, thumb2.jpg, etc, etc. If others don't want it, it could be off by default and anybody else that does could call it as artwork=yes, extrathumbs=yes or something. I know for me it would be much nicer and I could change out the ones I want with ember instead of going online, manually searching, looking, downloading the image, changing it. It's a lot more streamlined to change it with ember after.
And the original request from 2 months ago.
part timer wrote: 2. Download the best choice of fanart, which I'm sure it currently does, as the filename chosen from part 1. Download all of the fanarts(backdrops) for that movie including the one just downloaded into 'extrathumbs/thumbN.jpg' subfolder of the current movie folder where N starts at 1 and changes incrementally by one up to however many there are. This is nice when you want to change your fanart later on with xbmc, nice and easy to switch to another high quality version.
As always,

Thank you so much

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: [REQ] Artwork Scripting Change

Post by part timer » 29 Sep 2012, 11:23

I uninstalled 2.64 and installed 3 and the script does run now, but it can't find any of my movies :(.

I'm assuming it's because of all the extra data in the folder name. Is there a way to get the query to reduce the clutter when searching or use the nfo that's in each folder to help it find the match?

Given the folder naming I have in place, how do I get the script to run? It would probably have run before the folders were all renamed, but we're past that now.

Thanks in advance.

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [REQ] Artwork Scripting Change

Post by rednoah » 29 Sep 2012, 11:34

Well, what about the actual filenames, are they usable? In anycase you'll have to modify the script.

Find that one:

Code: Select all

def query = _args.query ?: dir.name
Replace with that:

Code: Select all

def query = detectMovie(videos[0], false) as String
* Also make sure you change include('lib/htpc') to include ('fn:lib/htpc') for running a local script but including the online lib/htpc code.

* Just quickly writing this from memory, haven't tested anything, but should be something like that.
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: [REQ] Artwork Scripting Change

Post by part timer » 29 Sep 2012, 21:28

Yes, that new code did work for the folder I was trying, thank you! I haven't tried it on more yet, because it isn't quite set up the way I'd like yet. I was hoping you could help me with that.
I commented out a few pieces I don't want and nothing seems to be broken so that's good.

1. I want poster.jpg to be saved more than once. I'd like 'poster.jpg', 'folder.jpg', 'movie.tbn' so I tried tons and tons of trial and error and eventually I got it to work. I'm sure for some it would have been really obvious, but I tried a lot of different things that I thought might work, until i found the one that does. All it ended up being was 2 extra lines.

Instead of this at the end:

Code: Select all

fetchMovieArtwork(movieDir['poster.jpg'], movieInfo, 'posters', locale.language)

I used this:

Code: Select all

fetchMovieArtwork(movieDir['poster.jpg'], movieInfo, 'posters', locale.language)
fetchMovieArtwork(movieDir['folder.jpg'], movieInfo, 'posters', locale.language)
fetchMovieArtwork(movieDir['movie.tbn'], movieInfo, 'posters', locale.language)

***edit*** This works, but it's probably downloading the same cover 3 times, so there is probably a better way where it can be downloaded once and then saved as 3 files, but I don't know how.

Man it's hard wandering around in the dark.

2. I really don't know yet if I'm going to be able to figure out how to save the extra fanarts as extrathumbs. Little help? I did the easy ones (not easy to me) ;)


As a side note even with just one movie folder I get a

Code: Select all

SocketTimeoutException: Read timed out
error probably half of the times I've tried this or more, so I don't know how this is going to go once I try run it on a folder of 60+ movies. **found this and it seems to help for me too** http://filebot.sourceforge.net/forums/v ... ?f=8&t=238

**edit**
Ok, well, using the obvious does work

adding:

Code: Select all

fetchMovieArtwork(movieDir['extrathumbs/thumb1.jpg'], movieInfo, 'backdrops', locale.language)
But again I don't know yet how to add that where thumb1 only exists when there is more than one fanart and to sequentially name them from there and choose a different fanart for each. hmmmmm..
Last edited by part timer on 30 Sep 2012, 10:16, edited 1 time in total.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: [REQ] Artwork Scripting Change

Post by part timer » 30 Sep 2012, 09:33

I'm definately in over my head here, but I feel like I'm making progress. VERY SLOW progress, but ahead of where I started.

I've changed

Code: Select all

def selection = [language, 'en', null].findResult{ l -> artwork.find{ (l == it.language || l == null) && it.category == category } }
to this

Code: Select all

def selection = [language, 'en', null].findResults{ l -> artwork.findAll{ (l == it.language || l == null) && it.category == category } }
So now I'm getting a list of the urls as selection, but I still don't know how to save each url in that list yet.
I can do

Code: Select all

return selection.url.each{ println "******: $it" }
****edit**** dammit, after 5+hrs on this, I realized that artwork was for the posters as well, I like only getting one result, so starting over with the fanart this time. Frustrating.

and it will show me the url's comma separated. Now, how do I save each of those urls as the picture files in this order, fanart.jpg, extrathumbs/thumb1.jpg, extrathumbs/thumb2.jpg, etc.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: [REQ] Artwork Scripting Change

Post by part timer » 30 Sep 2012, 10:44

I'm giving up for now, I need some sleep

But I was thinking something like this:

Code: Select all

if (fanart.sizes() == 1) {
	return fanart.url.saveAs(outputFile)}
        return fanart.url.each().saveAs(outputFile)
which I think would act normal if only one fanart found but if more than one would save the extras

and then do this

Code: Select all

def thumbs = (1..xfan)
def xfan = fanart.sizes().minus1


        	fetchMovieArtwork(movieDir['fanart.jpg'], movieInfo, 'backdrops', locale.language)
        	fetchMovieArtwork(movieDir['extrathumbs/thumb$thumbs.jpg'], movieInfo, 'backdrops', locale.language)

but it's not that simple unfortunately

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [REQ] Artwork Scripting Change

Post by rednoah » 30 Sep 2012, 15:21

Basically these are the main interfaces that'll give you a list of artwork/banners:

Code: Select all

TheTVDB.getBanner(series, filters)

Code: Select all

TheMovieDB.getArtwork(movieId)

Code: Select all

FanartTV.getSeriesArtwork(seriesId)

Code: Select all

FanartTV.getMovieArtwork(movieId)
Now this is internal stuff so there is no internal common interface or usage, just check out htpc.groovy for example usage. You can probably get where you want with only FanartTV.*

e.g.

Code: Select all

FanartTV.getMovieArtwork(12345).each{ it.url.saveAs(...) }
:idea: Please read the FAQ and How to Request Help.

maortal
Posts: 31
Joined: 16 Dec 2012, 11:18

Re: [REQ] Artwork Scripting Change

Post by maortal » 16 Dec 2012, 11:30

i wanna start of with saying rednoah you rock man! great app!
i just got that filebot yesterday i never heard of it before.. and i tried utorrent-postprocess and was amazed how easy that was... and then i got to the point that i wanted to get all the backdrops to be listed nicely with picture changed when i'm in media center so i started digging up and saw "part timer" requested the same thing.. so since i didnt find any solution myself i started checking out the htpc.groovy code to modify it
so heres what needs to be done incase someone wants to get all backdrops

first you need to add this function to the htpc.groovy file

Code: Select all

def fetchMovieBackdrops(outputFile, movieInfo, language) {
	// select and fetch artwork
	def artwork = TheMovieDB.getArtwork(movieInfo.id as String)
	def selection = [language, 'en', null].findResults{ l -> artwork.findAll{ (l == it.language || l == null) && it.category == 'backdrops' } }
	if (selection == null) {
		println "Backdrops not found: $outputFile"
		return null
	}
	selection.url.each{
		def tmp=it
			if (tmp != null){
				x=1
				tmp.each(){
					outputFilen="backdrops" + x.toString() + ".jpg"
					x++
					println "Fetching $outputFilen => $it"
					it.saveAs(outputFile[outputFilen])	
				}
			}
		}
	}
now find the function fetchMovieArtworkAndNfo which is located also in htpc.groovy and replace it with this

Code: Select all

def fetchMovieArtworkAndNfo(movieDir, movie, movieFile = null, locale = _args.locale) {
	_guarded {
		def movieInfo = TheMovieDB.getMovieInfo(movie, locale)
		// fetch nfo
		fetchMovieNfo(movieDir['movie.xml'], movieInfo, movieFile)
		
		// fetch series banner, fanart, posters, etc
		fetchMovieArtwork(movieDir['folder.jpg'], movieInfo, 'posters', locale.language)
		fetchMovieBackdrops(movieDir, movieInfo, locale.language)
		fetchMovieFanart(movieDir['clearart.png'], movieInfo, 'movieart', null, locale)
		fetchMovieFanart(movieDir['logo.png'], movieInfo, 'movielogo', null, locale)
	}
}

//note that i remove the cd images and all kind of artworks which i found irrelevent for me.. also poster.jpg changed to folder.jpg
and thats it you're done... you can use utorrent-postprocess again and when it will call the function fetchMovieArtworkAndNfo and it will call the new function that saves all backdrops
keep in mind that it was my first trial working with groovy so my syntax might not be the smartest and elegant but it works...
probably that same thing could've been done in one line of code :)

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [REQ] Artwork Scripting Change

Post by rednoah » 16 Dec 2012, 13:31

Seems like this might be popular. Added this to htpc and utorrent-postprocess so now you can just enable it via:

Code: Select all

--def artwork=y backdrops=y
:idea: Please read the FAQ and How to Request Help.

maortal
Posts: 31
Joined: 16 Dec 2012, 11:18

Re: [REQ] Artwork Scripting Change

Post by maortal » 16 Dec 2012, 13:52

lol i knew there must be an iterator with incrementing indexes! but i was too lazy to look for it lol :)
great job..

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [REQ] Artwork Scripting Change

Post by rednoah » 31 Dec 2012, 11:08

Due to popular request: Replaced the original search-by-foldername logic with FileBots movie detection logic in the artwork.tmdb script.
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: [REQ] Artwork Scripting Change

Post by part timer » 09 Jan 2013, 07:43

Thank you guys for adding the extra backdrops downloading. I love it. I've tested and customized, but I haven't used it full force yet to know 100%. So far though my testing seems like it's going to be awesome.

I changed mine a bit to match up with the way ember manages the extra backdrops (in case anyone else uses it too, kind of a no-brainer though now that all the hard work was already done, but still).

Code: Select all

	selection.eachWithIndex{ s, i ->
		def outputFile = new File(outputFolder, "thumb${(i+1)}.jpg")
		println "Fetching $outputFile => $s"
		if (_args.conflict == "skip" && !outputFile.exists()) {
	    s.url.saveAs(outputFile)
and

Code: Select all

fetchAllMovieArtwork(movieDir['extrathumbs'], movieInfo, 'backdrops', locale.language)
So all of the extra backdrops go into the folder extrathumbs and numbered thumb1.jpg through to the end and it won't overwrite if it's already there. Loving it. Keeping custom scripts is a little daunting though. Nice once it's set up, but making changes and testing and testing, sheesh.

Anyways, thank you guys so much!!

**Looking at it again, I really have to go back and clean it up, but for right now it works and I don't want to break it just to make it cleaner and proper.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: [REQ] Artwork Scripting Change

Post by part timer » 09 Jan 2013, 07:55

Now that that has been added, thank you again, I'm going to ask about another request I had months ago as well. Right now I still get a lot of timeouts for some reason, even with a very fast connection. To try and get around that I changed my script so that it actually retries to download artwork 9 times in the same script. One of my problems though is that I keep 3 different filenames for the covers. I like poster.jpg, folder.jpg and movie.tbn (all the same cover image). The problem with that though is that it actually downloads the same file all 3 times and if it times out it might try almost 30 times to do it. What I want instead is to download it once and then copy it to the other two names so it's downloading once and not 3 times. I don't know how to do this. I've googled for hours. I've changed the script over and over while googling for hours. I just can't make it work for me and do a simple copy operation.

Please help

I know the following code should be written cleaner but it works without hassles. I had to add the extra steps for skipping files because originally it was an all or nothing thing. If all the files were there it would skip, but if only one was missing it would try to fetch them all. So instead of that I made it check for each individual file instead.
Right now it's like this:

Code: Select all

		// fetch series banner, fanart, posters, etc
	if (_args.conflict == "skip" && !movieDir.hasFile{it =~ /movie.tbn$/}) {
	    fetchMovieArtwork(movieDir['movie.tbn'], movieInfo, 'posters', locale.language)
	}

	if (_args.conflict == "skip" && !movieDir.hasFile{it =~ /poster.jpg$/}) {
	    fetchMovieArtwork(movieDir['poster.jpg'], movieInfo, 'posters', locale.language)
	}
	
	if (_args.conflict == "skip" && !movieDir.hasFile{it =~ /folder.jpg$/}) {
	    fetchMovieArtwork(movieDir['folder.jpg'], movieInfo, 'posters', locale.language)
	}
But I wish I knew how to change it so it was

Code: Select all

if directory has none of the 3
-then fetch movie.tbn
-and after copy it to poster.jpg and folder.jpg
Once I have that I should be able to tweak it myself by adding

Code: Select all

if directory has movie.tbn but not folder and not poster copy to those. If it has movie and folder but not poster copy to poster, etc, etc, etc
And unfortunately every combination in between so that even if it fails or whatever happens, as long as there is one it will just copy it to the other 2 and not download. It's a really simple request, but putting it into place seems like a lot hassle. Just be nice to have.

Thanks for reading this guys.

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [REQ] Artwork Scripting Change

Post by rednoah » 09 Jan 2013, 08:50

For copying all the **/poster.jpg as **/folder.jpg I have something:
http://filebot.sourceforge.net/forums/v ... &t=5#p2100

e.g. Duplicate each poster.jpg as folder.jpg:

Code: Select all

filebot -script fn:replace --action copy --def "e=poster.jpg" "r=folder.jpg" /path/to/files
:idea: Please read the FAQ and How to Request Help.

Post Reply