RuudBurger/CouchPotatoServer — pull request #3158 by Boehemyth (2014-04-24 20:40:40+00:00)
Title: Support for downloading extra artwork from fanart.tv

resolves #1023

This PR adds two new features:
1. It adds support for downloading extra artwork from fanart.tv as discussed in #1023)
2. It adds an option to the XBMC notifier to run the ArtworkDownloader addon.

### Extra Artwork
New image types include:
* clearart
* discart
* extrathumbs
* extrafanart
* logo
* banner
* landscape (16:9 Thumb)

There are a couple things that should be noted:
1. Only English images are downloaded.
2. The fanart image is now downloaded from Fanart.tv if it can find one, otherwise it uses TMDB like it used to. This is because the images on Fanart.tv are sometimes higher resolutions & quality, but the opposite is rarely true.
3. Since multiple extrathumbs and extrafanarts are downloaded into a subdirectory, subdirectories are now supported for metadata file names. The subdirectories will be automatically created if they don't exist.
4. Bluray discart will always be preferred over DVD. Ideally, it would prefer DVD versions for SD quality movies, but I couldn't find an easy way to determine the quality from within the plugin. I suspect major changes would be needed to the plugin system in general in order to get this to work. If a user cares about the distinction, the best work-around is to not download these in Couchpotato and run the Artwork Downloader addon from within XBMC (or automatically via the next feature).
5. A maximum of 4 extrathumbs and 20 extrafanarts are downloaded. Naming these required the use of an integer flag.

### XBMC Notifier - Run Artwork Downloader
This wasn't discussed in #1023, but I mentioned an issue where even if you pre-download the extra artwork, you still have to run the artwork downloader plugin to get it to display in the skins, which is kind of lousy as far as automation goes. The solution is to have Couchpotato run the artwork downloader after the library update completes. So this PR also includes an advanced option for the XBMC notifier to do this.

There are few caveats:
1. This option will only work in XBMCv12 (Frodo) or later.
2. It requires the Artwork Downloader Addon. (Of course)
3. Since XBMC's API doesn't support notifications over HTML, there is no way for couchpotato to know when the Library Scan is complete, and if the Downloader is run before the update is complete, it will fail and the error is logged.

To get around the last issue, I implemented an adjustable delay before starting the Artwork Downloader.

Also, this option completely respects the force full scan option. If that option is selected, it will run the artwork downloader over the whole library as well. If it is disabled, it will only run the downloader on the new movie.

### Testing
Both of these features have been fairly well tested. I'm pretty confident that the fanart.tv feature is solid, since that was tested against a wide variety of different movies. The XBMC notifier is working with my XBMC setup. I can't think of anything that would cause it to fail with other setups as long as the requirements I mentioned above are met. I did not test what would happen in earlier versions of XBMC, because pre-Frodo versions did not support running addons through the API. These requirements are specifically mentioned in the settings interface.