1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

Merge tag 'v4.0.4' into develop

v4.0.4 v4.0.4
This commit is contained in:
echel0n 2014-12-19 05:08:51 -08:00
commit 6151062ea4
4 changed files with 47 additions and 18 deletions

View File

@ -9,7 +9,7 @@
#set global $sbPath = ".." #set global $sbPath = ".."
#set global $topmenu="home"# #set global $topmenu="home"#
#import os.path #import os.pat
#include $os.path.join($sickbeard.PROG_DIR, "gui/slick/interfaces/default/inc_top.tmpl") #include $os.path.join($sickbeard.PROG_DIR, "gui/slick/interfaces/default/inc_top.tmpl")
#set $myDB = $db.DBConnection() #set $myDB = $db.DBConnection()

View File

@ -17,17 +17,8 @@
# along with SickRage. If not, see <http://www.gnu.org/licenses/>. # along with SickRage. If not, see <http://www.gnu.org/licenses/>.
import os import os
import traceback
import re
import sickbeard
import six
import chardet import chardet
import unicodedata import sickbeard
from string import ascii_letters, digits
from sickbeard import logger
from unidecode import unidecode
def _toUnicode(x): def _toUnicode(x):
try: try:

View File

@ -26,6 +26,7 @@ import platform
import sickbeard import sickbeard
from sickbeard import classes from sickbeard import classes
from sickbeard.encodingKludge import ek
from github import Github from github import Github
from pastebin import PastebinAPI from pastebin import PastebinAPI
@ -149,10 +150,11 @@ class Logger(object):
pastebin_url = None pastebin_url = None
try: try:
if self.logFile and os.path.isfile(self.logFile): if self.logFile and os.path.isfile(self.logFile):
with ek.ek(open, self.logFile) as f: with ek(open, self.logFile) as f:
data = f.readlines(50) data = f.readlines()
data = "".join(data[len(data) - 100:])
pastebin_url = PastebinAPI().paste('f59b8e9fa1fc2d033e399e6c7fb09d19', data) pastebin_url = PastebinAPI().paste('f59b8e9fa1fc2d033e399e6c7fb09d19', data)
except: except Exception as e:
pass pass
try: try:

View File

@ -128,7 +128,8 @@ class ApiHandler(RequestHandler):
else: else:
outputCallback = outputCallbackDict['default'] outputCallback = outputCallbackDict['default']
return self.finish(outputCallback(outDict)) try:self.finish(outputCallback(outDict))
except:pass
def _out_as_json(self, dict): def _out_as_json(self, dict):
self.set_header("Content-Type", "application/json;charset=UTF-8'") self.set_header("Content-Type", "application/json;charset=UTF-8'")
@ -176,7 +177,14 @@ class ApiHandler(RequestHandler):
if not (multiCmds and cmd in ('show.getposter', 'show.getbanner')): # skip these cmd while chaining if not (multiCmds and cmd in ('show.getposter', 'show.getbanner')): # skip these cmd while chaining
try: try:
if cmd in _functionMaper: if cmd in _functionMaper:
curOutDict = _functionMaper.get(cmd)(curArgs, curKwargs).run() # map function
func = _functionMaper.get(cmd)
# add request handler to function
func.rh = self
# call function and get response back
curOutDict = func(curArgs, curKwargs).run()
elif _is_int(cmd): elif _is_int(cmd):
curOutDict = TVDBShorthandWrapper(curArgs, curKwargs, cmd).run() curOutDict = TVDBShorthandWrapper(curArgs, curKwargs, cmd).run()
else: else:
@ -241,6 +249,34 @@ class ApiHandler(RequestHandler):
return curArgs, curKwargs return curArgs, curKwargs
def showPoster(self, show=None, which=None):
# Redirect initial poster/banner thumb to default images
if which[0:6] == 'poster':
default_image_name = 'poster.png'
else:
default_image_name = 'banner.png'
# image_path = ek.ek(os.path.join, sickbeard.PROG_DIR, 'gui', 'slick', 'images', default_image_name)
static_image_path = os.path.join('/images', default_image_name)
if show and sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)):
cache_obj = image_cache.ImageCache()
image_file_name = None
if which == 'poster':
image_file_name = cache_obj.poster_path(show)
if which == 'poster_thumb' or which == 'small':
image_file_name = cache_obj.poster_thumb_path(show)
if which == 'banner':
image_file_name = cache_obj.banner_path(show)
if which == 'banner_thumb':
image_file_name = cache_obj.banner_thumb_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'))
static_image_path = sickbeard.WEB_ROOT + static_image_path.replace('\\', '/')
return self.redirect(static_image_path)
class ApiCall(ApiHandler): class ApiCall(ApiHandler):
_help = {"desc": "No help message available. Please tell the devs that a help msg is missing for this cmd"} _help = {"desc": "No help message available. Please tell the devs that a help msg is missing for this cmd"}
@ -2304,7 +2340,7 @@ class CMD_ShowGetPoster(ApiCall):
def run(self): def run(self):
""" get the poster for a show in sickrage """ """ get the poster for a show in sickrage """
return {'outputType': 'image', 'image': WebRoot().showPoster(self.indexerid, 'poster')} return {'outputType': 'image', 'image': self.rh.showPoster(self.indexerid, 'poster')}
class CMD_ShowGetBanner(ApiCall): class CMD_ShowGetBanner(ApiCall):
@ -2327,7 +2363,7 @@ class CMD_ShowGetBanner(ApiCall):
def run(self): def run(self):
""" get the banner for a show in sickrage """ """ get the banner for a show in sickrage """
return {'outputType': 'image', 'image': WebRoot().showPoster(self.indexerid, 'banner')} return {'outputType': 'image', 'image': self.rh.showPoster(self.indexerid, 'banner')}
class CMD_ShowPause(ApiCall): class CMD_ShowPause(ApiCall):