def getLogo(title,ask=False,force=True):
infile = xbmc.translatePath("special://profile/addon_data/script.tvguide.fullscreen/logos/temp.png")
outfile = xbmc.translatePath("special://profile/addon_data/script.tvguide.fullscreen/logos/%s.png" % title)
if not force and xbmcvfs.exists(outfile):
return outfile
xbmcvfs.mkdirs("special://profile/addon_data/script.tvguide.fullscreen/logos")
db_url = "http://www.thelogodb.com/api/json/v1/4423/tvchannel.php?s=%s" % re.sub(' ','+',title)
try: json = requests.get(db_url).json()
except: pass
if json and "channels" in json:
channels = json["channels"]
if channels:
if ask:
names = ["%s [%s]" % (c["strChannel"],c["strCountry"]) for c in channels]
d = xbmcgui.Dialog()
selected = d.select("Logo Source: %s" % title,names)
else:
selected = 0
if selected > -1:
logo = channels[selected]["strLogoWide"]
if not logo:
return None
logo = re.sub('^https','http',logo)
data = requests.get(logo).content
f = xbmcvfs.File("special://profile/addon_data/script.tvguide.fullscreen/logos/temp.png","wb")
f.write(data)
f.close()
from PIL import Image, ImageOps
image = Image.open(infile)
border = 0
image = autocrop_image(image, border)
image.save(outfile)
logo = outfile
return logo
评论列表
文章目录