2015-04-02, 10:10
(2015-04-02, 09:45)insertnamehere Wrote: Hey JasonPell,
I've had a spare hour or two and have made progress with the cover art image resolution problem.
I gave up on using images from Netflix, they only serve up the URL of the low res covers and the higher resolution images used on their webpage don't have a consistent numbering system to allow me to fetch the HD images.
SO.... I've been working on getting cover images from TMDb through download.py.
There were a few issues, however, it now works providing good covers and you also get background fan art.
Looks much better than the standard art.
Here is the code for download.py
PHP Code:#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import re
import base64
import xbmc
import xbmcaddon
import urllib
import urllib2
import shutil
def download(videoID, title, year):
filename = (''.join(c for c in unicode(videoID, 'utf-8') if c not in '/\\:?"*|<>')).strip()+".jpg"
filenameNone = (''.join(c for c in unicode(videoID, 'utf-8') if c not in '/\\:?"*|<>')).strip()+".none"
coverFile = os.path.join(cacheFolderCoversTMDB, filename)
coverFileNone = os.path.join(cacheFolderCoversTMDB, filenameNone)
fanartFile = os.path.join(cacheFolderFanartTMDB, filename)
content = opener.open("http://api.themoviedb.org/3/search/"+videoType+"?api_key="+apiKey+"&query="+urllib.quote_plus(title.strip())+"&year="+urllib.quote_plus(year)+"&language=en").read()
match = re.compile('"poster_path":"(.+?)"', re.DOTALL).findall(content)
# maybe its a mini-series (TMDb calls them movies)
if not match and videoType == "tv":
content = opener.open("http://api.themoviedb.org/3/search/movie?api_key="+apiKey+"&query="+urllib.quote_plus(title.strip())+"&year="+urllib.quote_plus(year)+"&language=en").read()
match = re.compile('"poster_path":"(.+?)"', re.DOTALL).findall(content)
if match:
coverUrl = "http://image.tmdb.org/t/p/original"+match[0]
contentJPG = opener.open(coverUrl).read()
fh = open(coverFile, 'wb')
fh.write(contentJPG)
fh.close()
else:
fh = open(coverFileNone, 'w')
fh.write("")
fh.close()
match = re.compile('"backdrop_path":"(.+?)"', re.DOTALL).findall(content)
if match:
fanartUrl = "http://image.tmdb.org/t/p/original"+match[0]
contentJPG = opener.open(fanartUrl).read()
fh = open(fanartFile, 'wb')
fh.write(contentJPG)
fh.close()
addonID = 'plugin.video.netflixbmc'
addon = xbmcaddon.Addon(id=addonID)
apiKey = base64.b64decode("NDc2N2I0YjJiYjk0YjEwNGZhNTUxNWM1ZmY0ZTFmZWM=")
addonUserDataFolder = xbmc.translatePath("special://profile/addon_data/"+addonID)
cacheFolder = os.path.join(addonUserDataFolder, "cache")
cacheFolderCoversTMDB = os.path.join(cacheFolder, "covers")
cacheFolderFanartTMDB = os.path.join(cacheFolder, "fanart")
opener = urllib2.build_opener()
userAgent = "Mozilla/5.0 (Windows NT 5.1; rv:25.0) Gecko/20100101 Firefox/25.0"
opener.addheaders = [('User-agent', userAgent)]
videoType = urllib.unquote_plus(sys.argv[1])
videoID = urllib.unquote_plus(sys.argv[2])
title = urllib.unquote_plus(sys.argv[3])
year = urllib.unquote_plus(sys.argv[4])
try:
download(videoID, title, year)
except:
pass
Make sure "Get covers and fanart images from TMDb" is turned on
Some TV series do not have cover art available through TMDb, so in that case the standard low def Netflix cover is displayed.
If you want more covers, you can register a TMDb and provide your own artwork for the missing TV series and movies.
After you open a list, all the covers for the list will begin loading but will take time (depends on you connection speed). Leave the list and return to see the updated cover. Once downloaded the covers and fanart are stored in the cache and always available.
Cook - I have taken your code and added it to my github.