diff --git a/gui/slick/interfaces/default/apiBuilder.tmpl b/gui/slick/interfaces/default/apiBuilder.tmpl index 79eefee603375306575bdc1df1c2835d66893a29..3e4e5fd0410d3b87d16f1e386a87fee520776985 100644 --- a/gui/slick/interfaces/default/apiBuilder.tmpl +++ b/gui/slick/interfaces/default/apiBuilder.tmpl @@ -61,6 +61,7 @@ addList("Command", "Show.AddNew", "?cmd=show.addnew", "show.addnew", "", "", "ac addList("Command", "Show.Cache", "?cmd=show.cache", "indexerid", "", "", "action"); addList("Command", "Show.Delete", "?cmd=show.delete", "show.delete", "", "", "action"); addList("Command", "Show.GetBanner", "?cmd=show.getbanner", "indexerid", "", "", "action"); +addList("Command", "Show.GetNetworkLogo", "?cmd=show.getnetworklogo", "indexerid", "", "", "action"); addList("Command", "Show.GetPoster", "?cmd=show.getposter", "indexerid", "", "", "action"); addList("Command", "Show.GetQuality", "?cmd=show.getquality", "indexerid", "", "", "action"); addList("Command", "Show.Pause", "?cmd=show.pause", "show.pause", "", "", "action"); diff --git a/gui/slick/interfaces/default/home.tmpl b/gui/slick/interfaces/default/home.tmpl index 840b37cb23c48e4a1882d7bd5671df8ba907d32c..1f1262d21a949fbcd40400e0f59a06a32cf4f145 100644 --- a/gui/slick/interfaces/default/home.tmpl +++ b/gui/slick/interfaces/default/home.tmpl @@ -603,7 +603,7 @@ $myShowList.sort(lambda x, y: cmp(x.name, y.name)) <td class="show-table"> #if $layout != 'simple': #if $curShow.network: - <span title="$curShow.network"><img class="show-network-image" src="$sbRoot/images/network/${curShow.network.replace(u"\u00C9",'e').replace(u"\u00E9",'e').lower()}.png" alt="$curShow.network" title="$curShow.network" /></span> + <span title="$curShow.network"><img class="show-network-image" src="$sbRoot/showNetworkLogo/?show=$curShow.indexerid" alt="$curShow.network" title="$curShow.network" /></span> #else: <span title="No Network"><img class="show-network-image" src="$sbRoot/images/network/nonetwork.png" alt="No Network" title="No Network" /></span> #end if @@ -801,7 +801,7 @@ $myShowList.sort(lambda x, y: cmp(x.name, y.name)) #if $layout != 'simple': <td align="center"> #if $curShow.network: - <span title="$curShow.network"><img id="network" width="54" height="27" src="$sbRoot/images/network/${curShow.network.replace(u"\u00C9",'e').replace(u"\u00E9",'e').lower()}.png" alt="$curShow.network" title="$curShow.network" /></span> + <span title="$curShow.network"><img id="network" width="54" height="27" src="$sbRoot/showNetworkLogo/?show=$curShow.indexerid" alt="$curShow.network" title="$curShow.network" /></span> #else: <span title="No Network"><img id="network" width="54" height="27" src="$sbRoot/images/network/nonetwork.png" alt="No Network" title="No Network" /></span> #end if diff --git a/sickbeard/tv.py b/sickbeard/tv.py index 7e1b1c103ed1a4d0d81497d460cc98e281cc8c32..b2d33fb3a8586360a985402bf3ded8ec6d5f4181 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -174,6 +174,10 @@ class TVShow(object): else: return False + @property + def network_logo_name(self): + return self.network.replace(u'\u00C9', 'e').replace(u'\u00E9', 'e').lower() + def _getLocation(self): # no dir check needed if missing show dirs are created during post-processing if sickbeard.CREATE_MISSING_SHOW_DIRS: diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index c3c0eba0edd92afbd5ba2dc612b0f58168a113a8..a6027a4a61dc17e011ba92a9170f5cce8c9d6fdc 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -74,7 +74,7 @@ result_type_map = {RESULT_SUCCESS: "success", class ApiHandler(RequestHandler): """ api class that returns json results """ - version = 5 # use an int since float-point is unpredictible + version = 5 # use an int since float-point is unpredictable intent = 4 def __init__(self, *args, **kwargs): @@ -254,6 +254,8 @@ class ApiHandler(RequestHandler): # Redirect initial poster/banner thumb to default images if which[0:6] == 'poster': default_image_name = 'poster.png' + elif which[0:6] == 'fanart': + default_image_name = 'fanart.png' else: default_image_name = 'banner.png' @@ -271,6 +273,10 @@ class ApiHandler(RequestHandler): image_file_name = cache_obj.banner_path(show) if which == 'banner_thumb': image_file_name = cache_obj.banner_thumb_path(show) + if which == 'fanart': + if not cache_obj.has_fanart(show): + cache_obj.fill_cache(sickbeard.helpers.findCertainShow(sickbeard.showList, int(show))) + image_file_name = cache_obj.fanart_path(show) if ek.ek(os.path.isfile, image_file_name): static_image_path = os.path.normpath(image_file_name.replace(sickbeard.CACHE_DIR, '/cache')) @@ -278,6 +284,18 @@ class ApiHandler(RequestHandler): static_image_path = sickbeard.WEB_ROOT + static_image_path.replace('\\', '/') return self.redirect(static_image_path) + def showNetworkLogo(self, show=None): + show = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)) + + if show: + image_file_name = show.network_logo_name + else: + image_file_name = 'nonetwork' + + static_image_path = '%s/images/network/%s.png' % (sickbeard.WEB_ROOT, image_file_name) + + return self.redirect(static_image_path) + class ApiCall(ApiHandler): _help = {"desc": "No help message available. Please tell the devs that a help msg is missing for this cmd"} @@ -2411,6 +2429,39 @@ class CMD_ShowGetBanner(ApiCall): """ get the banner for a show in sickrage """ return {'outputType': 'image', 'image': self.rh.showPoster(self.indexerid, 'banner')} +class CMD_ShowGetNetworkLogo(ApiCall): + _help = { + "desc": "Get the network logo stored for a show in SickRage", + "requiredParameters": { + "indexerid": { + "desc": "Unique id of a show", + }, + }, + "optionalParameters": { + "tvdbid": { + "desc": "TheTVDB.com unique id of a show", + }, + "tvrageid": { + "desc": "TVRage.con unique id of a show", + }, + }, + } + + def __init__(self, args, kwargs): + # required + self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", []) + # optional + # super, missing, help + ApiCall.__init__(self, args, kwargs) + + def run(self): + """ + :return: The network logo for a show in SickRage + """ + return { + 'outputType': 'image', + 'image': self.rh.showNetworkLogo(self.indexerid) + } class CMD_ShowPause(ApiCall): _help = {"desc": "set a show's paused state in sickrage", @@ -2942,6 +2993,7 @@ _functionMaper = {"help": CMD_Help, "show.getquality": CMD_ShowGetQuality, "show.getposter": CMD_ShowGetPoster, "show.getbanner": CMD_ShowGetBanner, + "show.getnetworklogo": CMD_ShowGetNetworkLogo, "show.pause": CMD_ShowPause, "show.refresh": CMD_ShowRefresh, "show.seasonlist": CMD_ShowSeasonList, diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 144dcf24dc67a413402ab645fe134caad6390169..d7f71545f67a9e8f839a07ea67e301b5a51e86f2 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -410,6 +410,18 @@ class WebRoot(WebHandler): static_image_path = static_image_path.replace('\\', '/') return self.redirect(static_image_path) + def showNetworkLogo(self, show=None): + show = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)) + + if show: + image_file_name = show.network_logo_name + else: + image_file_name = 'nonetwork' + + static_image_path = '%s/images/network/%s.png' % (sickbeard.WEB_ROOT, image_file_name) + + return self.redirect(static_image_path) + def setHomeLayout(self, layout): if layout not in ('poster', 'small', 'banner', 'simple', 'coverflow'):