diff --git a/.gitignore b/.gitignore index 8426cfb49f5eace635b8fa58267611f8ab19c404..2db538360d4a7e695c057c5448e2767d07556679 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,14 @@ # SR User Related # ###################### -/cache*/ -/Logs/ -/restore/ -/backup/ +cache*/ +Logs/ +restore/ +backup*/ cache.db* config.ini* sickbeard.db* failed.db* -/autoProcessTV/autoProcessTV.cfg +autoProcessTV.cfg server.crt server.key diff --git a/SickBeard.py b/SickBeard.py index 0e309aa6d2a1b768390ab440e0f4cd053024a447..73496dcdfca826b27c6320a821219767a5dc4e91 100755 --- a/SickBeard.py +++ b/SickBeard.py @@ -19,6 +19,8 @@ # Check needed software dependencies to nudge users to fix their setup +# pylint: disable=W0703 + from __future__ import with_statement import codecs @@ -45,6 +47,7 @@ if sys.version_info < (2, 7): if sys.version_info >= (2, 7, 9): import ssl + # pylint: disable=W0212 ssl._create_default_https_context = ssl._create_unverified_context import locale @@ -67,6 +70,7 @@ signal.signal(signal.SIGTERM, sickbeard.sig_handler) class SickRage(object): + # pylint: disable=R0902 def __init__(self): # system event callback for shutdown/restart sickbeard.events = Events(self.shutdown) @@ -81,7 +85,16 @@ class SickRage(object): self.forcedPort = None self.noLaunch = False - def help_message(self): + self.webhost = '0.0.0.0' + self.startPort = sickbeard.WEB_PORT + self.web_options = {} + + self.log_dir = None + self.consoleLogging = True + + + @staticmethod + def help_message(): """ print help message for commandline options """ @@ -112,9 +125,10 @@ class SickRage(object): return help_msg - def fix_clients_nonsense(self): + @staticmethod + def fix_clients_nonsense(): - files = [ + filenames = [ "sickbeard/clients/download_station.py", "sickbeard/clients/utorrent.py", "sickbeard/clients/qbittorrent.py", @@ -124,19 +138,20 @@ class SickRage(object): "sickbeard/clients/rtorrent.py" ] - for file in files: - file = ek(os.path.join, sickbeard.PROG_DIR, file) + for filename in filenames: + filename = ek(os.path.join, sickbeard.PROG_DIR, file) try: - if ek(os.path.exists, file): - ek(os.remove, file) - except: + if ek(os.path.exists, filename): + ek(os.remove, filename) + except Exception: pass try: - if ek(os.path.exists, file + "c"): - ek(os.remove, file + "c") - except: + if ek(os.path.exists, filename + "c"): + ek(os.remove, filename + "c") + except Exception: pass + # pylint: disable=R0912,R0915 def start(self): # do some preliminary stuff sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(__file__)) @@ -160,6 +175,7 @@ class SickRage(object): reload(sys) if sys.platform == 'win32': + #pylint: disable=E1101 if sys.getwindowsversion()[0] >= 6 and sys.stdout.encoding == 'cp65001': sickbeard.SYS_ENCODING = 'UTF-8' @@ -167,7 +183,7 @@ class SickRage(object): # pylint: disable=E1101 # On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError sys.setdefaultencoding(sickbeard.SYS_ENCODING) - except: + except Exception: sys.exit("Sorry, you MUST add the SickRage folder to the PYTHONPATH environment variable\n" + "or find another way to force Python to use " + sickbeard.SYS_ENCODING + " for string encoding.") @@ -178,7 +194,8 @@ class SickRage(object): threading.currentThread().name = "MAIN" try: - opts, args = getopt.getopt(sys.argv[1:], "hfqdp::", + # pylint: disable=W0612 + opts, args = getopt.getopt(sys.argv[1:], "hqdp::", ['help', 'quiet', 'nolaunch', 'daemon', 'pidfile=', 'port=', 'datadir=', 'config=', 'noresize']) # @UnusedVariable except getopt.GetoptError: @@ -260,7 +277,7 @@ class SickRage(object): if not os.access(sickbeard.DATA_DIR, os.F_OK): try: os.makedirs(sickbeard.DATA_DIR, 0744) - except os.error, e: + except os.error: raise SystemExit("Unable to create datadir '" + sickbeard.DATA_DIR + "'") # Make sure we can write to the data dir @@ -285,7 +302,7 @@ class SickRage(object): sys.stdout.write("Restore: restoring DB and config.ini successful...\n") else: sys.stdout.write("Restore: restoring DB and config.ini FAILED!\n") - except Exception as e: + except Exception: sys.stdout.write("Restore: restoring DB and config.ini FAILED!\n") # Load the config and publish it to the sickbeard package @@ -383,14 +400,14 @@ class SickRage(object): sickbeard.launchBrowser('https' if sickbeard.ENABLE_HTTPS else 'http', self.startPort, sickbeard.WEB_ROOT) # main loop - while (True): + while True: time.sleep(1) def daemonize(self): """ Fork off as a daemon """ - # pylint: disable=E1101 + # pylint: disable=E1101,W0212 # Make a non-session-leader child process try: pid = os.fork() # @UndefinedVariable - only available in UNIX @@ -438,7 +455,8 @@ class SickRage(object): os.dup2(stdout.fileno(), sys.stdout.fileno()) os.dup2(stderr.fileno(), sys.stderr.fileno()) - def remove_pid_file(self, PIDFILE): + @staticmethod + def remove_pid_file(PIDFILE): try: if os.path.exists(PIDFILE): os.remove(PIDFILE) @@ -448,7 +466,8 @@ class SickRage(object): return True - def loadShowsFromDB(self): + @staticmethod + def loadShowsFromDB(): """ Populates the showList with shows from the database """ @@ -470,8 +489,8 @@ class SickRage(object): logger.ERROR) logger.log(traceback.format_exc(), logger.DEBUG) - - def restoreDB(self, srcDir, dstDir): + @staticmethod + def restoreDB(srcDir, dstDir): try: filesList = ['sickbeard.db', 'config.ini', 'failed.db', 'cache.db'] @@ -483,10 +502,10 @@ class SickRage(object): shutil.move(dstFile, bakFile) shutil.move(srcFile, dstFile) return True - except: + except Exception: return False - def shutdown(self, type): + def shutdown(self, event): if sickbeard.started: # stop all tasks sickbeard.halt() @@ -500,14 +519,14 @@ class SickRage(object): self.webserver.shutDown() try: self.webserver.join(10) - except: + except Exception: pass # if run as daemon delete the pidfile if self.runAsDaemon and self.CREATEPID: self.remove_pid_file(self.PIDFILE) - if type == sickbeard.event_queue.Events.SystemEvent.RESTART: + if event == sickbeard.event_queue.Events.SystemEvent.RESTART: install_type = sickbeard.versionCheckScheduler.action.install_type popen_list = [] @@ -527,6 +546,7 @@ class SickRage(object): # system exit logger.shutdown() #Make sure the logger has stopped, just in case + # pylint: disable=W0212 os._exit(0) diff --git a/gui/slick/js/addExistingShow.js b/gui/slick/js/addExistingShow.js index cdf17b1cda5f9b9616d6a3005e7bb9b41836d0eb..6b13cba3e94b00007ae916088413d6b670f68fea 100644 --- a/gui/slick/js/addExistingShow.js +++ b/gui/slick/js/addExistingShow.js @@ -11,16 +11,16 @@ $(document).ready(function() { $('#submitShowDirs').click(function() { - var dirArr = new Array(); + var dirArr = []; $('.dirCheck').each(function(i,w) { - if (this.checked == true) { + if (this.checked === true) { var show = $(this).attr('id'); var indexer = $(this).closest('tr').find('select').val(); dirArr.push(encodeURIComponent(indexer + '|' + show)); } }); - if (dirArr.length == 0) { + if (dirArr.length === 0) { return false; } @@ -79,4 +79,4 @@ $(document).ready(function() { $('html,body').animate({scrollTop:0}, 1000); }); -}); \ No newline at end of file +}); diff --git a/gui/slick/js/ajaxEpSearch.js b/gui/slick/js/ajaxEpSearch.js index 7fb0d2073d98c6303e1b2f28a6b6dd07cad9fe2a..8f0ce9d8e4876b891c89da2f1421d1b5e1fbf278 100644 --- a/gui/slick/js/ajaxEpSearch.js +++ b/gui/slick/js/ajaxEpSearch.js @@ -1,31 +1,24 @@ var search_status_url = sbRoot + '/home/getManualSearchStatus'; -var failedDownload = false -var qualityDownload = false -var selectedEpisode = "" +var failedDownload = false; +var qualityDownload = false; +var selectedEpisode = ''; PNotify.prototype.options.maxonscreen = 5; $.fn.manualSearches = []; function check_manual_searches() { var poll_interval = 5000; - showId = $('#showID').val() - var url = "" - if ( showId !== undefined) { - var url = search_status_url + '?show=' + showId; - } else { - var url = search_status_url; - } - + showId = $('#showID').val(); + var url = showId !== undefined ? search_status_url + '?show=' + showId : search_status_url ; $.ajax({ url: url, success: function (data) { if (data.episodes) { - poll_interval = 5000; + poll_interval = 5000; + } else { + poll_interval = 15000; } - else { - poll_interval = 15000; - } - + updateImages(data); //cleanupManualSearches(data); }, @@ -41,224 +34,215 @@ function check_manual_searches() { }); } - function updateImages(data) { - $.each(data.episodes, function (name, ep) { - // Get td element for current ep - var loadingImage = 'loading16.gif'; + $.each(data.episodes, function (name, ep) { + // Get td element for current ep + var loadingImage = 'loading16.gif'; var queuedImage = 'queued.png'; var searchImage = 'search16.png'; var status = null; //Try to get the <a> Element el=$('a[id=' + ep.show + 'x' + ep.season + 'x' + ep.episode+']'); img=el.children('img'); - parent=el.parent(); + parent=el.parent(); if (el) { - if (ep.searchstatus == 'searching') { - //el=$('td#' + ep.season + 'x' + ep.episode + '.search img'); - img.prop('title','Searching'); - img.prop('alt','Searching'); - img.prop('src',sbRoot+'/images/' + loadingImage); - disableLink(el); - // Update Status and Quality - var rSearchTerm = /(\w+)\s\((.+?)\)/; - HtmlContent = ep.searchstatus; - - } - else if (ep.searchstatus == 'queued') { - //el=$('td#' + ep.season + 'x' + ep.episode + '.search img'); - img.prop('title','Queued'); - img.prop('alt','queued'); - img.prop('src',sbRoot+'/images/' + queuedImage ); - disableLink(el); - HtmlContent = ep.searchstatus; - } - else if (ep.searchstatus == 'finished') { - //el=$('td#' + ep.season + 'x' + ep.episode + '.search img'); - img.prop('title','Searching'); - img.prop('alt','searching'); - img.parent().prop('class','epRetry'); - img.prop('src',sbRoot+'/images/' + searchImage); - enableLink(el); - - // Update Status and Quality - var rSearchTerm = /(\w+)\s\((.+?)\)/; - HtmlContent = ep.status.replace(rSearchTerm,"$1"+' <span class="quality '+ep.quality+'">'+"$2"+'</span>'); - parent.closest('tr').prop("class", ep.overview + " season-" + ep.season + " seasonstyle") - - } - // update the status column if it exists - parent.siblings('.col-status').html(HtmlContent) - + if (ep.searchstatus == 'searching') { + //el=$('td#' + ep.season + 'x' + ep.episode + '.search img'); + img.prop('title','Searching'); + img.prop('alt','Searching'); + img.prop('src',sbRoot+'/images/' + loadingImage); + disableLink(el); + // Update Status and Quality + var rSearchTerm = /(\w+)\s\((.+?)\)/; + HtmlContent = ep.searchstatus; + + } + else if (ep.searchstatus == 'queued') { + //el=$('td#' + ep.season + 'x' + ep.episode + '.search img'); + img.prop('title','Queued'); + img.prop('alt','queued'); + img.prop('src',sbRoot+'/images/' + queuedImage ); + disableLink(el); + HtmlContent = ep.searchstatus; + } + else if (ep.searchstatus == 'finished') { + //el=$('td#' + ep.season + 'x' + ep.episode + '.search img'); + img.prop('title','Searching'); + img.prop('alt','searching'); + img.parent().prop('class','epRetry'); + img.prop('src',sbRoot+'/images/' + searchImage); + enableLink(el); + + // Update Status and Quality + var rSearchTerm = /(\w+)\s\((.+?)\)/; + HtmlContent = ep.status.replace(rSearchTerm,"$1"+' <span class="quality '+ep.quality+'">'+"$2"+'</span>'); + parent.closest('tr').prop("class", ep.overview + " season-" + ep.season + " seasonstyle"); + + } + // update the status column if it exists + parent.siblings('.col-status').html(HtmlContent); + } el_comEps=$('a[id=forceUpdate-' + ep.show + 'x' + ep.season + 'x' + ep.episode+']'); img_comEps=el_comEps.children('img'); if (el_comEps) { - if (ep.searchstatus == 'searching') { - img_comEps.prop('title','Searching'); - img_comEps.prop('alt','Searching'); - img_comEps.prop('src',sbRoot+'/images/' + loadingImage); - disableLink(el_comEps); - } else if (ep.searchstatus == 'queued') { - img_comEps.prop('title','Queued'); - img_comEps.prop('alt','queued'); - img_comEps.prop('src',sbRoot+'/images/' + queuedImage ); - } else if (ep.searchstatus == 'finished') { - img_comEps.prop('title','Manual Search'); - img_comEps.prop('alt','[search]'); - img_comEps.prop('src',sbRoot+'/images/' + searchImage); - if (ep.overview == 'snatched') { - el_comEps.closest('tr').remove(); - } else { - enableLink(el_comEps); - } - } + if (ep.searchstatus == 'searching') { + img_comEps.prop('title','Searching'); + img_comEps.prop('alt','Searching'); + img_comEps.prop('src',sbRoot+'/images/' + loadingImage); + disableLink(el_comEps); + } else if (ep.searchstatus == 'queued') { + img_comEps.prop('title','Queued'); + img_comEps.prop('alt','queued'); + img_comEps.prop('src',sbRoot+'/images/' + queuedImage ); + } else if (ep.searchstatus == 'finished') { + img_comEps.prop('title','Manual Search'); + img_comEps.prop('alt','[search]'); + img_comEps.prop('src',sbRoot+'/images/' + searchImage); + if (ep.overview == 'snatched') { + el_comEps.closest('tr').remove(); + } else { + enableLink(el_comEps); + } + } } - }); + }); } $(document).ready(function () { - - check_manual_searches(); - + check_manual_searches(); }); function enableLink(el) { - el.on('click.disabled', false); - el.prop('enableClick', '1'); - el.fadeTo("fast", 1) + el.on('click.disabled', false); + el.prop('enableClick', '1'); + el.fadeTo("fast", 1); } function disableLink(el) { - el.off('click.disabled'); - el.prop('enableClick', '0'); - el.fadeTo("fast", .5) + el.off('click.disabled'); + el.prop('enableClick', '0'); + el.fadeTo("fast", 0.5); } (function(){ + $.ajaxEpSearch = { + defaults: { + size: 16, + colorRow: false, + loadingImage: 'loading16.gif', + queuedImage: 'queued.png', + noImage: 'no16.png', + yesImage: 'yes16.png' + } + }; + + $.fn.ajaxEpSearch = function(options){ + options = $.extend({}, $.ajaxEpSearch.defaults, options); + + $('.epRetry').click(function(event){ + event.preventDefault(); + + // Check if we have disabled the click + if($(this).prop('enableClick') == '0') return false; + + selectedEpisode = $(this); + + $("#manualSearchModalFailed").modal('show'); + }); + + $('.epSearch').click(function(event){ + event.preventDefault(); - $.ajaxEpSearch = { - defaults: { - size: 16, - colorRow: false, - loadingImage: 'loading16.gif', - queuedImage: 'queued.png', - noImage: 'no16.png', - yesImage: 'yes16.png' - } - }; - - $.fn.ajaxEpSearch = function(options){ - options = $.extend({}, $.ajaxEpSearch.defaults, options); - - $('.epRetry').click(function(event){ - event.preventDefault(); - - // Check if we have disabled the click - if ( $(this).prop('enableClick') == '0' ) { - return false; - }; - - selectedEpisode = $(this) - - $("#manualSearchModalFailed").modal('show'); - }); - - $('.epSearch').click(function(event){ - event.preventDefault(); - - // Check if we have disabled the click - if ( $(this).prop('enableClick') == '0' ) { - return false; - }; - - selectedEpisode = $(this); - - if ($(this).parent().parent().children(".col-status").children(".quality").length) { - $("#manualSearchModalQuality").modal('show'); - } else { - manualSearch(); - } - }); - - $('#manualSearchModalFailed .btn').click(function(){ - val=$(this).text(); - if(val=='Yes'){ - failedDownload = true; - } else { - failedDownload = false; - } - $("#manualSearchModalQuality").modal('show'); - }); - - $('#manualSearchModalQuality .btn').click(function(){ - val=$(this).text(); - if(val=='Yes'){ - qualityDownload = true; - } else { - qualityDownload = false; - } - manualSearch(); - }); - - function manualSearch(){ - var parent = selectedEpisode.parent(); - - // Create var for anchor - link = selectedEpisode; - - // Create var for img under anchor and set options for the loading gif - img=selectedEpisode.children('img'); - img.prop('title','loading'); - img.prop('alt',''); - img.prop('src',sbRoot+'/images/' + options.loadingImage); - - var url = selectedEpisode.prop('href'); - - if (failedDownload === false) { - url = url.replace("retryEpisode", "searchEpisode"); - } - - if (qualityDownload === true) { - url = url + "&downCurQuality=1"; - } else { - url = url + "&downCurQuality=0"; - } - - $.getJSON(url, function(data){ - - // if they failed then just put the red X - if (data.result == 'failure') { - img_name = options.noImage; - img_result = 'failed'; - - // if the snatch was successful then apply the corresponding class and fill in the row appropriately - } else { - img_name = options.loadingImage; - img_result = 'success'; - // color the row - if (options.colorRow) - parent.parent().removeClass('skipped wanted qual good unaired').addClass('snatched'); - // applying the quality class + // Check if we have disabled the click + if ($(this).prop('enableClick') == '0') return false; + + selectedEpisode = $(this); + + if ($(this).parent().parent().children(".col-status").children(".quality").length) { + $("#manualSearchModalQuality").modal('show'); + } else { + manualSearch(); + } + }); + + $('#manualSearchModalFailed .btn').click(function(){ + val=$(this).text(); + if(val=='Yes'){ + failedDownload = true; + } else { + failedDownload = false; + } + $("#manualSearchModalQuality").modal('show'); + }); + + $('#manualSearchModalQuality .btn').click(function(){ + val=$(this).text(); + if(val=='Yes'){ + qualityDownload = true; + } else { + qualityDownload = false; + } + manualSearch(); + }); + + function manualSearch(){ + var parent = selectedEpisode.parent(); + + // Create var for anchor + link = selectedEpisode; + + // Create var for img under anchor and set options for the loading gif + img=selectedEpisode.children('img'); + img.prop('title','loading'); + img.prop('alt',''); + img.prop('src',sbRoot+'/images/' + options.loadingImage); + + var url = selectedEpisode.prop('href'); + + if (failedDownload === false) { + url = url.replace("retryEpisode", "searchEpisode"); + } + + if (qualityDownload === true) { + url = url + "&downCurQuality=1"; + } else { + url = url + "&downCurQuality=0"; + } + + $.getJSON(url, function(data){ + + // if they failed then just put the red X + if (data.result == 'failure') { + img_name = options.noImage; + img_result = 'failed'; + + // if the snatch was successful then apply the corresponding class and fill in the row appropriately + } else { + img_name = options.loadingImage; + img_result = 'success'; + // color the row + if (options.colorRow) + parent.parent().removeClass('skipped wanted qual good unaired').addClass('snatched'); + // applying the quality class var rSearchTerm = /(\w+)\s\((.+?)\)/; - HtmlContent = data.result.replace(rSearchTerm,"$1"+' <span class="quality '+data.quality+'">'+"$2"+'</span>'); - // update the status column if it exists - parent.siblings('.col-status').html(HtmlContent) + HtmlContent = data.result.replace(rSearchTerm,"$1"+' <span class="quality '+data.quality+'">'+"$2"+'</span>'); + // update the status column if it exists + parent.siblings('.col-status').html(HtmlContent); // Only if the queuing was successful, disable the onClick event of the loading image disableLink(link); - } - - // put the corresponding image as the result of queuing of the manual search - img.prop('title',img_result); - img.prop('alt',img_result); - img.prop('height', options.size); - img.prop('src',sbRoot+"/images/"+img_name); - }); - // - - // don't follow the link - return false; - }; - - }; + } + + // put the corresponding image as the result of queuing of the manual search + img.prop('title',img_result); + img.prop('alt',img_result); + img.prop('height', options.size); + img.prop('src',sbRoot+"/images/"+img_name); + }); + // + + // don't follow the link + return false; + } + }; })(); diff --git a/gui/slick/js/ajaxEpSubtitles.js b/gui/slick/js/ajaxEpSubtitles.js index 3514e7af2ca95bca629012dd5166a93be07e2594..261bf1a778b3c8bc345931b3c0060788d6445223 100644 --- a/gui/slick/js/ajaxEpSubtitles.js +++ b/gui/slick/js/ajaxEpSubtitles.js @@ -1,49 +1,49 @@ (function(){ - $.fn.ajaxEpSubtitlesSearch = function(){ - $('.epSubtitlesSearch').click(function(){ - var subtitles_td = $(this).parent().siblings('.col-subtitles'); - var subtitles_search_link = $(this); - // fill with the ajax loading gif - subtitles_search_link.empty(); - subtitles_search_link.append($("<img/>").attr({"src": sbRoot+"/images/loading16.gif", "alt": "", "title": "loading"})); - $.getJSON($(this).attr('href'), function(data){ - if (data.result != "failure" && data.result != "No subtitles downloaded") { - // clear and update the subtitles column with new informations - var subtitles = data.subtitles.split(','); - subtitles_td.empty() - $.each(subtitles,function(index, language){ - if (language != "" && language != "und") { - if (index != subtitles.length - 1) { - subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/subtitles/flags/"+language+".png", "alt": language, "width": 16, "height": 11})); - } else { - subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/subtitles/flags/"+language+".png", "alt": language, "width": 16, "height": 11})); - } - } - }); - // don't allow other searches - subtitles_search_link.remove(); - } else { - subtitles_search_link.remove(); - } - }); - - // don't follow the link - return false; - }); - }; + $.fn.ajaxEpSubtitlesSearch = function(){ + $('.epSubtitlesSearch').click(function(){ + var subtitles_td = $(this).parent().siblings('.col-subtitles'); + var subtitles_search_link = $(this); + // fill with the ajax loading gif + subtitles_search_link.empty(); + subtitles_search_link.append($("<img/>").attr({"src": sbRoot+"/images/loading16.gif", "alt": "", "title": "loading"})); + $.getJSON($(this).attr('href'), function(data){ + if (data.result != "failure" && data.result != "No subtitles downloaded") { + // clear and update the subtitles column with new informations + var subtitles = data.subtitles.split(','); + subtitles_td.empty(); + $.each(subtitles,function(index, language){ + if (language !== "" && language != "und") { + if (index != subtitles.length - 1) { + subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/subtitles/flags/"+language+".png", "alt": language, "width": 16, "height": 11})); + } else { + subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/subtitles/flags/"+language+".png", "alt": language, "width": 16, "height": 11})); + } + } + }); + // don't allow other searches + subtitles_search_link.remove(); + } else { + subtitles_search_link.remove(); + } + }); - $.fn.ajaxEpMergeSubtitles = function(){ - $('.epMergeSubtitles').click(function(){ - var subtitles_merge_link = $(this); - // fill with the ajax loading gif - subtitles_merge_link.empty(); - subtitles_merge_link.append($("<img/>").attr({"src": sbRoot+"/images/loading16.gif", "alt": "", "title": "loading"})); - $.getJSON($(this).attr('href'), function(data){ - // don't allow other merges - subtitles_merge_link.remove(); - }); - // don't follow the link - return false; - }); - } + // don't follow the link + return false; + }); + }; + + $.fn.ajaxEpMergeSubtitles = function(){ + $('.epMergeSubtitles').click(function(){ + var subtitles_merge_link = $(this); + // fill with the ajax loading gif + subtitles_merge_link.empty(); + subtitles_merge_link.append($("<img/>").attr({"src": sbRoot+"/images/loading16.gif", "alt": "", "title": "loading"})); + $.getJSON($(this).attr('href'), function(data){ + // don't allow other merges + subtitles_merge_link.remove(); + }); + // don't follow the link + return false; + }); + }; })(); diff --git a/gui/slick/js/apibuilder.js b/gui/slick/js/apibuilder.js index cdf0e730f40f8c99e545870a1b7480ca43dacb47..65a53e704f2e55e04e0ded72c044a61930ef4436 100644 --- a/gui/slick/js/apibuilder.js +++ b/gui/slick/js/apibuilder.js @@ -9,7 +9,7 @@ var _disable_empty_list=false; var _hide_empty_list=false; -var _image_commands=['?cmd=show.getbanner', '?cmd=show.getfanart', '?cmd=show.getnetworklogo', '?cmd=show.getposter'] +var _image_commands=['?cmd=show.getbanner', '?cmd=show.getfanart', '?cmd=show.getnetworklogo', '?cmd=show.getposter']; function goListGroup(apikey, L7, L6, L5, L4, L3, L2, L1){ var html, GlobalOptions = ""; @@ -40,8 +40,7 @@ function goListGroup(apikey, L7, L6, L5, L4, L3, L2, L1){ $('#imgcache').attr('src', imgcache); } }); - } - else { + } else { html = sbRoot + "/api/" + apikey + "/" + L1 + L2 + L3 + L4 + L5 + L6 + L7 + GlobalOptions + "<br/><pre>"; html += $.ajax({ url: sbRoot + "/api/" + apikey + "/" + L1 + L2 + L3 + L4 + L5 + L6 + L7 + GlobalOptions, @@ -59,7 +58,7 @@ if (typeof(disable_empty_list)=="undefined") { disable_empty_list=_disable_empty if (typeof(hide_empty_list)=="undefined") { hide_empty_list=_hide_empty_list; } var cs_goodContent=true, cs_M="M", cs_L="L", cs_G="G", cs_EG="EG"; -var cs_names=new Array(); +var cs_names = []; var cs_supportDOM=document.createElement; var cs_nav=navigator.userAgent.toLowerCase(); var cs_isIE7=(cs_nav.indexOf("msie 7")!=-1 || cs_nav.indexOf("msie 8")!=-1); @@ -82,7 +81,7 @@ function cs_findM(m,n) { for (var i=0; i<m.items.length; i++) { if (m.items[i].type==cs_M) { sm=cs_findM(m.items[i],n); - if (sm!=null) { break; } + if (sm !== null) break; } } return sm; @@ -93,51 +92,52 @@ function cs_subContentOBJ(n,list) { this.list=list; this.ifm=document.createElement("IFRAME"); - with (this.ifm.style) { - position="absolute"; left="-200px"; top="-200px"; visibility="hidden"; width="100px"; height="100px"; - } + this.ifm.style.position="absolute"; left="-200px"; top="-200px"; visibility="hidden"; width="100px"; height="100px"; document.body.appendChild(this.ifm); this.ifm.src=n; -}; cs_subContent=new Array(); +} + +cs_subContent = []; function cs_contentOBJ(n,obj){ this.name=n; this.menu=obj; - this.lists=new Array(); + this.lists = []; this.cookie=""; this.callback=null; this.count=1; -}; cs_content=new Array(); +} + +cs_subContent = []; function cs_topmenuOBJ(tm) { this.name=tm; this.type=cs_M; - this.items=new Array(); + this.items = []; this.df=","; this.oidx=0; - this.addM=cs_addM; this.addL=cs_addL; this.addG=cs_addG, this.endG=cs_endG; + this.addM=cs_addM; this.addL=cs_addL; this.addG=cs_addG; this.endG=cs_endG; } + function cs_submenuOBJ(dis,link,sub,label,css) { - this.name=sub; - this.type=cs_M; - this.dis=dis; - this.link=link; - this.label=label; - this.css=css; - this.df=","; - this.oidx=0; + this.name=sub; + this.type=cs_M; + this.dis=dis; + this.link=link; + this.label=label; + this.css=css; + this.df=","; + this.oidx=0; - this.addM=cs_addM; this.addL=cs_addL; this.addG=cs_addG, this.endG=cs_endG; + this.addM=cs_addM; this.addL=cs_addL; this.addG=cs_addG; this.endG=cs_endG; - if (typeof(cs_names[sub])=="undefined") { - this.items=new Array(); - cs_names[sub] = this; - } - else - { - this.items = cs_names[sub].items; - } + if (typeof(cs_names[sub])=="undefined") { + this.items = []; + cs_names[sub] = this; + } else { + this.items = cs_names[sub].items; + } } function cs_linkOBJ(dis,link,label,css) { this.type=cs_L; @@ -194,7 +194,7 @@ function cs_getOptions(menu,list) { for (var i=0; i<menu.items.length; i++) { opt[i]=new cs_optionOBJ(menu.items[i].type, menu.items[i].dis, menu.items[i].link, menu.items[i].label, menu.items[i].css); } - if (opt.length==0 && menu.name!="") { + if (opt.length===0 && menu.name !== '') { cs_getSubList(menu.name,list); //opt[0]=new cs_optionOBJ(cs_L, "loading ...", "", "", ""); } @@ -229,10 +229,10 @@ function cs_refreshList(list,opt,df,key) { list.options[iCount].idx=i; list.options[iCount].key=key; - if (opt[i].label!="") { + if (opt[i].label !== '') { list.options[iCount].label=opt[i].label; } - if (opt[i].css!="") { + if (opt[i].css !== '') { list.options[iCount].className=opt[i].css; } @@ -247,7 +247,7 @@ function cs_refreshList(list,opt,df,key) { if (opt[i].type==cs_G) { optGroup=document.createElement("optgroup"); optGroup.setAttribute("label", opt[i].label); - if (opt[i].css!="") { + if (opt[i].css !== '') { optGroup.setAttribute("className", opt[i].css); } list.appendChild(optGroup); @@ -279,10 +279,10 @@ function cs_refreshList(list,opt,df,key) { if (df.indexOf(","+optCount+",")!=-1) { newOpt.selected=true; } - if (opt[i].label!="") { + if (opt[i].label !== '') { newOpt.label=opt[i].label; } - if (opt[i].css!="") { + if (opt[i].css !== '') { newOpt.className=opt[i].css; } @@ -309,7 +309,7 @@ function cs_getKey(key,idx) { function cs_getSelected(mode,name,idx,key,df) { if (mode) { var cookies=cs_getCookie(name+"_"+idx); - if (cookies!="") { + if (cookies !== '') { var mc=cookies.split("-"); for (var i=0; i<mc.length; i++) { if (mc[i].indexOf(key)!=-1) { @@ -333,7 +333,7 @@ function cs_updateListGroup(content,idx,mode) { for (var i=0; i<options.length; i++) { if (options[i].selected) { if (key!=options[i].key) { - cookies+=key==""?"":((cookies==""?"":"-")+key+option); + cookies+=key === '' ? '' : ((cookies === '' ? '' : '-')+key+option); key=options[i].key; option=","; @@ -355,8 +355,8 @@ function cs_updateListGroup(content,idx,mode) { } } - if (key!="") { - cookies+=(cookies==""?"":"-")+key+option; + if (key !== '') { + cookies+=(cookies === '' ? '' : '-')+key+option; } if (content.cookie) { @@ -408,16 +408,16 @@ function cs_updateList() { var opt=""; for (var j=0; j<this.options.length; j++) { if (this.options[j].selected) { - if (opt!="") { + if (opt !== '') { opt+=","; } - if (this.options[j].value!="") { + if (this.options[j].value !== '') { opt+=this.options[j].value; } - else if (this.options[j].text!="") { + else if (this.options[j].text !== '') { opt+=this.options[j].text; } - else if (this.options[j].label!="") { + else if (this.options[j].label !== '') { opt+=this.options[j].label; } } @@ -437,7 +437,7 @@ function cs_updateList() { function cs_getSubList(n,list) { if (cs_goodContent && cs_supportDOM) { var cs_subList=cs_findSubContent(n); - if (cs_subList==null) { + if (cs_subList===null) { cs_subContent[cs_subContent.length]=new cs_subContentOBJ(n,list); } } @@ -445,9 +445,9 @@ function cs_getSubList(n,list) { function cs_updateSubList(cn,sn) { var cc=cs_findContent(cn), sc=cs_findContent(sn); - if (cc!=null && sc!=null) { + if (cc!==null && sc!==null) { var cs_sub=cs_findM(cc.menu,sn); - if (cs_sub!=null) { + if (cs_sub!==null) { cs_sub.df=sc.menu.df; cs_sub.oidx=sc.menu.oidx; cs_sub.items=sc.menu.items; @@ -455,7 +455,7 @@ function cs_updateSubList(cn,sn) { } var cs_subList=cs_findSubContent(sn); - if (cs_subList!=null) { + if (cs_subList!==null) { cs_subList.list.onchange(); cs_subList.ifm.src=""; @@ -470,7 +470,7 @@ function addListGroup(n,tm) { cs_names[tm]=new cs_topmenuOBJ(tm); var c=cs_findContent(n); - if (c==null) { + if (c===null) { cs_content[cs_content.length]=new cs_contentOBJ(n,cs_names[tm]); } else { @@ -480,7 +480,7 @@ function addListGroup(n,tm) { } function addList(n,dis,link,sub,df,label,css) { - if (typeof(sub)=="undefined" || sub=="") { + if (typeof(sub)=="undefined" || sub === '') { addOption(n,dis,link||"",df||"",label||"",css||""); } else if (cs_goodContent) { @@ -536,7 +536,7 @@ function endOptGroup(n) { function initListGroup(n) { var _content=cs_findContent(n), count=0; - if (_content!=null) { + if (_content!==null) { var content=new cs_contentOBJ("cs_"+_content.count+"_"+n,_content.menu); content.count=_content.count++; cs_content[cs_content.length]=content; @@ -571,14 +571,14 @@ function initListGroups(n) { for (var i=1; i<initListGroups.arguments.length; i++) { // opera takes select array as function if ((typeof(arguments[i])=="object" || typeof(arguments[i])=="function") && arguments[i].length && typeof(arguments[i][0])!="undefined" && arguments[i][0].tagName && arguments[i][0].tagName=="SELECT") { - if (listCount>arguments[i].length || listCount==0) { + if (listCount>arguments[i].length || listCount===0) { listCount=arguments[i].length; } } } var _content=cs_findContent(n), count=0, content=null; - if (_content!=null) { + if (_content!==null) { for (var l=0; l<listCount; l++) { count=0; content=new cs_contentOBJ("cs_"+_content.count+"_"+n,_content.menu); @@ -613,20 +613,20 @@ function initListGroups(n) { function resetListGroup(n,count) { var content=cs_findContent("cs_"+(count||1)+"_"+n); - if (content!=null && content.lists.length>0) { + if (content!==null && content.lists.length>0) { cs_initListGroup(content,""); } } function selectOptions(n,opts,mode) { var content=cs_findContent(n); - if (content!=null) { + if (content!==null) { var optss=opts.split(":"), menu=content.menu, path=true; for (var i=0; i<optss.length; i+=2) { if (menu.type==cs_M && path) { path=false; for (var o=0; o<menu.items.length; o++) { - if (mode==0 && menu.items[o].dis==optss[i] || mode==1 && menu.items[o].link==optss[i] || mode==2 && o==optss[i]) { + if (mode===0 && menu.items[o].dis==optss[i] || mode==1 && menu.items[o].link==optss[i] || mode==2 && o==optss[i]) { path=true; if (optss[i+1]!="-") { menu.df=","+o+","; @@ -637,6 +637,5 @@ function selectOptions(n,opts,mode) { } } } - } + } } -// ------ \ No newline at end of file diff --git a/gui/slick/js/blackwhite.js b/gui/slick/js/blackwhite.js index 7509a6f000c08d964fb7038e0fcad14507af8f2f..49a86fedef94201ca269090fe2c1cd0dfb1bc8f1 100644 --- a/gui/slick/js/blackwhite.js +++ b/gui/slick/js/blackwhite.js @@ -1,25 +1,25 @@ function generate_bwlist() { - var realvalues = []; + var realvalues = []; - $('#white option').each(function(i, selected) { - realvalues[i] = $(selected).val(); - }); - $("#whitelist").val(realvalues.join(",")); + $('#white option').each(function(i, selected) { + realvalues[i] = $(selected).val(); + }); + $("#whitelist").val(realvalues.join(",")); - realvalues = []; - $('#black option').each(function(i, selected) { - realvalues[i] = $(selected).val(); - }); - $("#blacklist").val(realvalues.join(",")); -}; + realvalues = []; + $('#black option').each(function(i, selected) { + realvalues[i] = $(selected).val(); + }); + $("#blacklist").val(realvalues.join(",")); +} function update_bwlist(show_name) { - $('#pool').children().remove(); + $('#pool').children().remove(); $('#blackwhitelist').show(); if (show_name) { $.getJSON(sbRoot + '/home/fetch_releasegroups', {'show_name': show_name}, function (data) { - if (data['result'] == 'success') { + if (data.result == 'success') { $.each(data.groups, function(i, group) { var option = $("<option>"); option.attr("value", group.name); @@ -29,46 +29,46 @@ function update_bwlist(show_name) { } }); } - }; + } $('#removeW').click(function() { - !$('#white option:selected').remove().appendTo('#pool'); + !$('#white option:selected').remove().appendTo('#pool'); }); $('#addW').click(function() { - !$('#pool option:selected').remove().appendTo('#white'); + !$('#pool option:selected').remove().appendTo('#white'); }); $('#addB').click(function() { - !$('#pool option:selected').remove().appendTo('#black'); + !$('#pool option:selected').remove().appendTo('#black'); }); $('#removeP').click(function() { - !$('#pool option:selected').remove(); + !$('#pool option:selected').remove(); }); $('#removeB').click(function() { - !$('#black option:selected').remove().appendTo('#pool'); + !$('#black option:selected').remove().appendTo('#pool'); }); $('#addToWhite').click(function() { - var group = $('#addToPoolText').val(); - if('' != group) { - var option = $('<option>'); - option.attr('value',group); - option.html(group); - option.appendTo('#white'); - $('#addToPoolText').val(''); - } + var group = $('#addToPoolText').val(); + if(group !== '') { + var option = $('<option>'); + option.attr('value',group); + option.html(group); + option.appendTo('#white'); + $('#addToPoolText').val(''); + } }); $('#addToBlack').click(function() { - var group = $('#addToPoolText').val(); - if('' != group) { - var option = $('<option>'); - option.attr('value',group); - option.html(group); - option.appendTo('#black'); - $('#addToPoolText').val(''); - } -}); \ No newline at end of file + var group = $('#addToPoolText').val(); + if(group !== '') { + var option = $('<option>'); + option.attr('value',group); + option.html(group); + option.appendTo('#black'); + $('#addToPoolText').val(''); + } +}); diff --git a/gui/slick/js/browser.js b/gui/slick/js/browser.js index 4baefc77bbb862f2803555231060997100ceef9c..9da6a8bafe019f9dfa2d49b2cd658e9a7518d768 100644 --- a/gui/slick/js/browser.js +++ b/gui/slick/js/browser.js @@ -32,7 +32,7 @@ var i = 0; var list, link = null; data = $.grep(data, function (value) { - return i++ != 0; + return i++ !== 0; }); $('<h2>').text(first_val.current_path).appendTo(fileBrowserDialog); list = $('<ul>').appendTo(fileBrowserDialog); @@ -152,7 +152,7 @@ if (ls && options.key) { path = localStorage['fileBrowser-' + options.key]; } - if (options.key && options.field.val().length == 0 && (path)) { + if (options.key && options.field.val().length === 0 && (path)) { options.field.val(path); } diff --git a/gui/slick/js/configNotifications.js b/gui/slick/js/configNotifications.js index a8a8ca327a1ee245cbbec7f49d6fa1f199188f7c..4222f207be2df8fbf7d1a5845a0bb2de455a89af 100644 --- a/gui/slick/js/configNotifications.js +++ b/gui/slick/js/configNotifications.js @@ -6,11 +6,11 @@ $(document).ready(function(){ var growl_password = $.trim($('#growl_password').val()); if (!growl_host) { $('#testGrowl-result').html('Please fill out the necessary fields above.'); - $('#growl_host').addClass('warning'); + $('#growl_host').addClass('warning'); return; } $('#growl_host').removeClass('warning'); - $(this).prop('disabled', true); + $(this).prop('disabled', true); $('#testGrowl-result').html(loading); $.get(sbRoot + '/home/testGrowl', {'host': growl_host, 'password': growl_password}) .done(function (data) { @@ -24,11 +24,11 @@ $(document).ready(function(){ var prowl_priority = $('#prowl_priority').val(); if (!prowl_api) { $('#testProwl-result').html('Please fill out the necessary fields above.'); - $('#prowl_api').addClass('warning'); + $('#prowl_api').addClass('warning'); return; } $('#prowl_api').removeClass('warning'); - $(this).prop('disabled', true); + $(this).prop('disabled', true); $('#testProwl-result').html(loading); $.get(sbRoot + '/home/testProwl', {'prowl_api': prowl_api, 'prowl_priority': prowl_priority}) .done(function (data) { @@ -43,11 +43,11 @@ $(document).ready(function(){ var kodi_password = $.trim($('#kodi_password').val()); if (!kodi_host) { $('#testKODI-result').html('Please fill out the necessary fields above.'); - $('#kodi_host').addClass('warning'); + $('#kodi_host').addClass('warning'); return; } $('#kodi_host').removeClass('warning'); - $(this).prop('disabled', true); + $(this).prop('disabled', true); $('#testKODI-result').html(loading); $.get(sbRoot + '/home/testKODI', {'host': kodi_host, 'username': kodi_username, 'password': kodi_password}) .done(function (data) { @@ -56,44 +56,44 @@ $(document).ready(function(){ }); }); - $('#testPMC').click(function () { - var plex_host = $.trim($('#plex_host').val()); - var plex_client_username = $.trim($('#plex_client_username').val()); - var plex_client_password = $.trim($('#plex_client_password').val()); - if (!plex_host) { - $('#testPMC-result').html('Please fill out the necessary fields above.'); - $('#plex_host').addClass('warning'); - return; - } - $('#plex_host').removeClass('warning'); - $(this).prop('disabled', true); - $('#testPMC-result').html(loading); - $.get(sbRoot + '/home/testPMC', {'host': plex_host, 'username': plex_client_username, 'password': plex_client_password}) - .done(function (data) { - $('#testPMC-result').html(data); - $('#testPMC').prop('disabled', false); - }); - }); - - $('#testPMS').click(function () { - var plex_server_host = $.trim($('#plex_server_host').val()); - var plex_username = $.trim($('#plex_username').val()); - var plex_password = $.trim($('#plex_password').val()); + $('#testPMC').click(function () { + var plex_host = $.trim($('#plex_host').val()); + var plex_client_username = $.trim($('#plex_client_username').val()); + var plex_client_password = $.trim($('#plex_client_password').val()); + if (!plex_host) { + $('#testPMC-result').html('Please fill out the necessary fields above.'); + $('#plex_host').addClass('warning'); + return; + } + $('#plex_host').removeClass('warning'); + $(this).prop('disabled', true); + $('#testPMC-result').html(loading); + $.get(sbRoot + '/home/testPMC', {'host': plex_host, 'username': plex_client_username, 'password': plex_client_password}) + .done(function (data) { + $('#testPMC-result').html(data); + $('#testPMC').prop('disabled', false); + }); + }); + + $('#testPMS').click(function () { + var plex_server_host = $.trim($('#plex_server_host').val()); + var plex_username = $.trim($('#plex_username').val()); + var plex_password = $.trim($('#plex_password').val()); var plex_server_token = $.trim($('#plex_server_token').val()); - if (!plex_server_host) { - $('#testPMS-result').html('Please fill out the necessary fields above.'); - $('#plex_server_host').addClass('warning'); - return; - } - $('#plex_server_host').removeClass('warning'); - $(this).prop('disabled', true); - $('#testPMS-result').html(loading); - $.get(sbRoot + '/home/testPMS', {'host': plex_server_host, 'username': plex_username, 'password': plex_password, 'plex_server_token': plex_server_token}) - .done(function (data) { - $('#testPMS-result').html(data); - $('#testPMS').prop('disabled', false); - }); - }); + if (!plex_server_host) { + $('#testPMS-result').html('Please fill out the necessary fields above.'); + $('#plex_server_host').addClass('warning'); + return; + } + $('#plex_server_host').removeClass('warning'); + $(this).prop('disabled', true); + $('#testPMS-result').html(loading); + $.get(sbRoot + '/home/testPMS', {'host': plex_server_host, 'username': plex_username, 'password': plex_password, 'plex_server_token': plex_server_token}) + .done(function (data) { + $('#testPMS-result').html(data); + $('#testPMS').prop('disabled', false); + }); + }); $('#testEMBY').click(function () { var emby_host = $('#emby_host').val(); @@ -123,14 +123,14 @@ $(document).ready(function(){ }); $('#testBoxcar').click(function() { - var boxcar_username = $.trim($('#boxcar_username').val()); - if (!boxcar_username) { + var boxcar_username = $.trim($('#boxcar_username').val()); + if (!boxcar_username) { $('#testBoxcar-result').html('Please fill out the necessary fields above.'); - $('#boxcar_username').addClass('warning'); + $('#boxcar_username').addClass('warning'); return; } - $('#boxcar_username').removeClass('warning'); - $(this).prop('disabled', true); + $('#boxcar_username').removeClass('warning'); + $(this).prop('disabled', true); $('#testBoxcar-result').html(loading); $.get(sbRoot + '/home/testBoxcar', {'username': boxcar_username}) .done(function (data) { @@ -143,11 +143,11 @@ $(document).ready(function(){ var boxcar2_accesstoken = $.trim($('#boxcar2_accesstoken').val()); if (!boxcar2_accesstoken) { $('#testBoxcar2-result').html('Please fill out the necessary fields above.'); - $('#boxcar2_accesstoken').addClass('warning'); + $('#boxcar2_accesstoken').addClass('warning'); return; } $('#boxcar2_accesstoken').removeClass('warning'); - $(this).prop('disabled', true); + $(this).prop('disabled', true); $('#testBoxcar2-result').html(loading); $.get(sbRoot + '/home/testBoxcar2', {'accesstoken': boxcar2_accesstoken}) .done(function (data) { @@ -161,20 +161,20 @@ $(document).ready(function(){ var pushover_apikey = $('#pushover_apikey').val(); if (!pushover_userkey || !pushover_apikey) { $('#testPushover-result').html('Please fill out the necessary fields above.'); - if (!pushover_userkey) { - $('#pushover_userkey').addClass('warning'); - } else { - $('#pushover_userkey').removeClass('warning'); - } - if (!pushover_apikey) { - $('#pushover_apikey').addClass('warning'); - } else { - $('#pushover_apikey').removeClass('warning'); - } + if (!pushover_userkey) { + $('#pushover_userkey').addClass('warning'); + } else { + $('#pushover_userkey').removeClass('warning'); + } + if (!pushover_apikey) { + $('#pushover_apikey').addClass('warning'); + } else { + $('#pushover_apikey').removeClass('warning'); + } return; } - $('#pushover_userkey,#pushover_apikey').removeClass('warning'); - $(this).prop('disabled', true); + $('#pushover_userkey,#pushover_apikey').removeClass('warning'); + $(this).prop('disabled', true); $('#testPushover-result').html(loading); $.get(sbRoot + '/home/testPushover', {'userKey': pushover_userkey, 'apiKey': pushover_apikey}) .done(function (data) { @@ -199,10 +199,10 @@ $(document).ready(function(){ var twitter_key = $.trim($('#twitter_key').val()); if (!twitter_key) { $('#testTwitter-result').html('Please fill out the necessary fields above.'); - $('#twitter_key').addClass('warning'); + $('#twitter_key').addClass('warning'); return; } - $('#twitter_key').removeClass('warning'); + $('#twitter_key').removeClass('warning'); $('#testTwitter-result').html(loading); $.get(sbRoot + '/home/twitterStep2', {'key': twitter_key}, function (data) { $('#testTwitter-result').html(data); }); @@ -252,11 +252,11 @@ $(document).ready(function(){ var nmj_mount = $('#nmj_mount').val(); if (!nmj_host) { $('#testNMJ-result').html('Please fill out the necessary fields above.'); - $('#nmj_host').addClass('warning'); + $('#nmj_host').addClass('warning'); return; } $('#nmj_host').removeClass('warning'); - $(this).prop('disabled', true); + $(this).prop('disabled', true); $('#testNMJ-result').html(loading); $.get(sbRoot + '/home/testNMJ', {'host': nmj_host, 'database': nmj_database, 'mount': nmj_mount}) .done(function (data) { @@ -265,7 +265,7 @@ $(document).ready(function(){ }); }); - $('#settingsNMJv2').click(function() { + $('#settingsNMJv2').click(function() { if (!$('#nmjv2_host').val()) { alert('Please fill in the Popcorn IP address'); $('#nmjv2_host').focus(); @@ -273,19 +273,19 @@ $(document).ready(function(){ } $('#testNMJv2-result').html(loading); var nmjv2_host = $('#nmjv2_host').val(); - var nmjv2_dbloc; - var radios = document.getElementsByName('nmjv2_dbloc'); - for (var i = 0; i < radios.length; i++) { - if (radios[i].checked) { - nmjv2_dbloc=radios[i].value; - break; - } - } + var nmjv2_dbloc; + var radios = document.getElementsByName('nmjv2_dbloc'); + for (var i = 0; i < radios.length; i++) { + if (radios[i].checked) { + nmjv2_dbloc=radios[i].value; + break; + } + } var nmjv2_dbinstance=$('#NMJv2db_instance').val(); $.get(sbRoot + '/home/settingsNMJv2', {'host': nmjv2_host,'dbloc': nmjv2_dbloc,'instance': nmjv2_dbinstance}, function (data){ - if (data == null) { + if (data === null) { $('#nmjv2_database').removeAttr('readonly'); } var JSONData = $.parseJSON(data); @@ -303,10 +303,10 @@ $(document).ready(function(){ var nmjv2_host = $.trim($('#nmjv2_host').val()); if (!nmjv2_host) { $('#testNMJv2-result').html('Please fill out the necessary fields above.'); - $('#nmjv2_host').addClass('warning'); + $('#nmjv2_host').addClass('warning'); return; } - $('#nmjv2_host').removeClass('warning'); + $('#nmjv2_host').removeClass('warning'); $(this).prop('disabled', true); $('#testNMJv2-result').html(loading); $.get(sbRoot + '/home/testNMJv2', {'host': nmjv2_host}) @@ -321,19 +321,19 @@ $(document).ready(function(){ var freemobile_apikey = $.trim($('#freemobile_apikey').val()); if (!freemobile_id || !freemobile_apikey) { $('#testFreeMobile-result').html('Please fill out the necessary fields above.'); - if (!freemobile_id) { - $('#freemobile_id').addClass('warning'); - } else { - $('#freemobile_id').removeClass('warning'); - } - if (!freemobile_apikey) { - $('#freemobile_apikey').addClass('warning'); - } else { - $('#freemobile_apikey').removeClass('warning'); - } + if (!freemobile_id) { + $('#freemobile_id').addClass('warning'); + } else { + $('#freemobile_id').removeClass('warning'); + } + if (!freemobile_apikey) { + $('#freemobile_apikey').addClass('warning'); + } else { + $('#freemobile_apikey').removeClass('warning'); + } return; } - $('#freemobile_id,#freemobile_apikey').removeClass('warning'); + $('#freemobile_id,#freemobile_apikey').removeClass('warning'); $(this).prop('disabled', true); $('#testFreeMobile-result').html(loading); $.get(sbRoot + '/home/testFreeMobile', {'freemobile_id': freemobile_id, 'freemobile_apikey': freemobile_apikey}) @@ -353,7 +353,7 @@ $(document).ready(function(){ $('#trakt_pin').change(function() { var trakt_pin = $('#trakt_pin').val(); - if (trakt_pin.length !=0) { + if (trakt_pin.length !== 0) { $('#TraktGetPin').addClass('hide'); $('#authTrakt').removeClass('hide'); } @@ -366,7 +366,7 @@ $(document).ready(function(){ $('#trakt_pin').keyup(function () { var trakt_pin = $('#trakt_pin').val(); - if (trakt_pin.length !=0) { + if (trakt_pin.length !== 0) { $('#TraktGetPin').addClass('hide'); $('#authTrakt').removeClass('hide'); } @@ -378,7 +378,7 @@ $(document).ready(function(){ $('#authTrakt').click(function() { var trakt_pin = $('#trakt_pin').val(); - if (trakt_pin.length !=0) { + if (trakt_pin.length !== 0) { $.get(sbRoot + '/home/getTraktToken', { "trakt_pin": trakt_pin }) .done(function (data) { $('#testTrakt-result').html(data); @@ -394,21 +394,21 @@ $(document).ready(function(){ var trakt_trending_blacklist = $.trim($('#trakt_blacklist_name').val()); if (!trakt_username) { $('#testTrakt-result').html('Please fill out the necessary fields above.'); - if (!trakt_username) { - $('#trakt_username').addClass('warning'); - } else { - $('#trakt_username').removeClass('warning'); - } + if (!trakt_username) { + $('#trakt_username').addClass('warning'); + } else { + $('#trakt_username').removeClass('warning'); + } return; } if (/\s/g.test(trakt_trending_blacklist)) { $('#testTrakt-result').html('Check blacklist name; the value need to be a trakt slug'); - $('#trakt_blacklist_name').addClass('warning'); + $('#trakt_blacklist_name').addClass('warning'); return; } - $('#trakt_username').removeClass('warning'); - $('#trakt_blacklist_name').removeClass('warning'); + $('#trakt_username').removeClass('warning'); + $('#trakt_blacklist_name').removeClass('warning'); $(this).prop('disabled', true); $('#testTrakt-result').html(loading); $.get(sbRoot + '/home/testTrakt', {'username': trakt_username, 'blacklist_name': trakt_trending_blacklist}) @@ -459,10 +459,10 @@ $(document).ready(function(){ var nma_priority = $('#nma_priority').val(); if (!nma_api) { $('#testNMA-result').html('Please fill out the necessary fields above.'); - $('#nma_api').addClass('warning'); + $('#nma_api').addClass('warning'); return; } - $('#nma_api').removeClass('warning'); + $('#nma_api').removeClass('warning'); $(this).prop('disabled', true); $('#testNMA-result').html(loading); $.get(sbRoot + '/home/testNMA', {'nma_api': nma_api, 'nma_priority': nma_priority}) @@ -476,10 +476,10 @@ $(document).ready(function(){ var pushalot_authorizationtoken = $.trim($('#pushalot_authorizationtoken').val()); if (!pushalot_authorizationtoken) { $('#testPushalot-result').html('Please fill out the necessary fields above.'); - $('#pushalot_authorizationtoken').addClass('warning'); + $('#pushalot_authorizationtoken').addClass('warning'); return; } - $('#pushalot_authorizationtoken').removeClass('warning'); + $('#pushalot_authorizationtoken').removeClass('warning'); $(this).prop('disabled', true); $('#testPushalot-result').html(loading); $.get(sbRoot + '/home/testPushalot', {'authorizationToken': pushalot_authorizationtoken}) @@ -489,14 +489,14 @@ $(document).ready(function(){ }); }); - $('#testPushbullet').click(function () { + $('#testPushbullet').click(function () { var pushbullet_api = $.trim($('#pushbullet_api').val()); if (!pushbullet_api) { $('#testPushbullet-result').html('Please fill out the necessary fields above.'); - $('#pushbullet_api').addClass('warning'); + $('#pushbullet_api').addClass('warning'); return; } - $('#pushbullet_api').removeClass('warning'); + $('#pushbullet_api').removeClass('warning'); $(this).prop('disabled', true); $('#testPushbullet-result').html(loading); $.get(sbRoot + '/home/testPushbullet', {'api': pushbullet_api}) @@ -526,7 +526,7 @@ $(document).ready(function(){ var current_pushbullet_device = $("#pushbullet_device").val(); $("#pushbullet_device_list").html(''); for (var i = 0; i < devices.length; i++) { - if(devices[i].active == true) { + if(devices[i].active === true) { if(current_pushbullet_device == devices[i].iden) { $("#pushbullet_device_list").append('<option value="'+devices[i].iden+'" selected>' + devices[i].nickname + '</option>'); } else { @@ -534,7 +534,7 @@ $(document).ready(function(){ } } } - if (current_pushbullet_device == "") { + if (current_pushbullet_device === '') { $("#pushbullet_device_list").prepend('<option value="" selected>All devices</option>'); } else { $("#pushbullet_device_list").prepend('<option value="">All devices</option>'); @@ -549,7 +549,7 @@ $(document).ready(function(){ $("#pushbullet_device").val($("#pushbullet_device_list").val()); $('#testPushbullet-result').html("Don't forget to save your new pushbullet settings."); }); - }; + } $('#getPushbulletDevices').click(function(){ get_pushbullet_devices("Device list updated. Please choose a device to push to."); @@ -561,7 +561,7 @@ $(document).ready(function(){ $('#email_show').change(function () { var key = parseInt($('#email_show').val(), 10); $('#email_show_list').val(key >= 0 ? notify_data[key.toString()].list : ''); - }); + }); // Update the internal data struct anytime settings are saved to the server $('#email_show').bind('notify', function () { load_show_notify_lists(); }); @@ -588,10 +588,10 @@ $(document).ready(function(){ load_show_notify_lists(); $('#email_show_save').click(function() { - $.post(sbRoot + "/home/saveShowNotifyList", { show: $('#email_show').val(), emails: $('#email_show_list').val()}, function (data) { - // Reload the per show notify lists to reflect changes - load_show_notify_lists(); - }); + $.post(sbRoot + "/home/saveShowNotifyList", { show: $('#email_show').val(), emails: $('#email_show_list').val()}, function (data) { + // Reload the per show notify lists to reflect changes + load_show_notify_lists(); + }); }); // show instructions for plex when enabled diff --git a/gui/slick/js/configPostProcessing.js b/gui/slick/js/configPostProcessing.js index ab3fdb6b98d35dc5b0ae777f56538ead27608bad..0f6b36787004d106f7f86bbb1b16e618edac55f7 100644 --- a/gui/slick/js/configPostProcessing.js +++ b/gui/slick/js/configPostProcessing.js @@ -9,23 +9,23 @@ $(document).ready(function () { }; })(); - function israr_supported() { - var pattern = $('#naming_pattern').val(); - $.get(sbRoot + '/config/postProcessing/isRarSupported', - function (data) { + function israr_supported() { + var pattern = $('#naming_pattern').val(); + $.get(sbRoot + '/config/postProcessing/isRarSupported', + function (data) { if (data == "supported") { } else { $('#unpack').qtip('option', { 'content.text': 'Unrar Executable not found.', 'style.classes': 'qtip-rounded qtip-shadow qtip-red' - }); - $('#unpack').qtip('toggle', true); + }); + $('#unpack').qtip('toggle', true); $('#unpack').css('background-color', '#FFFFDD'); - + } }); - } - + } + function fill_examples() { var pattern = $('#naming_pattern').val(); var multi = $('#naming_multi_ep :selected').val(); @@ -161,47 +161,6 @@ $(document).ready(function () { } - function fill_sports_examples() { - var pattern = $('#naming_sports_pattern').val(); - - $.get(sbRoot + '/config/postProcessing/testNaming', {pattern: pattern, sports: 'True'}, - function (data) { - if (data) { - $('#naming_sports_example').text(data + '.ext'); - $('#naming_sports_example_div').show(); - } else { - $('#naming_sports_example_div').hide(); - } - }); - - $.get(sbRoot + '/config/postProcessing/isNamingValid', {pattern: pattern, sports: 'True'}, - function (data) { - if (data == "invalid") { - $('#naming_sports_pattern').qtip('option', { - 'content.text': 'This pattern is invalid.', - 'style.classes': 'qtip-rounded qtip-shadow qtip-red' - }); - $('#naming_sports_pattern').qtip('toggle', true); - $('#naming_sports_pattern').css('background-color', '#FFDDDD'); - } else if (data == "seasonfolders") { - $('#naming_sports_pattern').qtip('option', { - 'content.text': 'This pattern would be invalid without the folders, using it will force "Flatten" off for all shows.', - 'style.classes': 'qtip-rounded qtip-shadow qtip-red' - }); - $('#naming_sports_pattern').qtip('toggle', true); - $('#naming_sports_pattern').css('background-color', '#FFFFDD'); - } else { - $('#naming_sports_pattern').qtip('option', { - 'content.text': 'This pattern is valid.', - 'style.classes': 'qtip-rounded qtip-shadow qtip-green' - }); - $('#naming_sports_pattern').qtip('toggle', false); - $('#naming_sports_pattern').css('background-color', '#FFFFFF'); - } - }); - - } - function fill_anime_examples() { var pattern = $('#naming_anime_pattern').val(); var multi = $('#naming_anime_multi_ep :selected').val(); @@ -299,11 +258,11 @@ $(document).ready(function () { } $('#unpack').change(function () { - if(this.checked) { - israr_supported(); + if(this.checked) { + israr_supported(); } else { - $('#unpack').qtip('toggle', false); - } + $('#unpack').qtip('toggle', false); + } }); $('#name_presets').change(function () { @@ -446,8 +405,8 @@ $(document).ready(function () { config_arr.push(show_metadata ? '1' : '0'); config_arr.push(episode_metadata ? '1' : '0'); config_arr.push(fanart ? '1' : '0'); - config_arr.push(poster ? '1' : '0'); - config_arr.push(banner ? '1' : '0'); + config_arr.push(poster ? '1' : '0'); + config_arr.push(banner ? '1' : '0'); config_arr.push(episode_thumbnails ? '1' : '0'); config_arr.push(season_posters ? '1' : '0'); config_arr.push(season_banners ? '1' : '0'); @@ -477,12 +436,12 @@ $(document).ready(function () { }); - if (cur_most_provider != '' && first) { + if (cur_most_provider !== '' && first) { $('#metadataType option[value=' + cur_most_provider + ']').attr('selected', 'selected'); $(this).showHideMetadata(); } - } + }; $(this).refreshMetadataConfig(true); $('img[title]').qtip( { @@ -534,4 +493,4 @@ $(document).ready(function () { } }); -}); \ No newline at end of file +}); diff --git a/gui/slick/js/configProviders.js b/gui/slick/js/configProviders.js index aa9965afd6c57f2f4ff32583e2e1c1f46b5a8a22..f9560b362ef6eb3553da436b5b1e669161446d01 100644 --- a/gui/slick/js/configProviders.js +++ b/gui/slick/js/configProviders.js @@ -11,7 +11,7 @@ $(document).ready(function(){ $(this).hide(); } }); - } + }; /** * Gets categories for the provided newznab provider. @@ -20,45 +20,43 @@ $(document).ready(function(){ * @return no return data. Function updateNewznabCaps() is run at callback */ $.fn.getCategories = function (isDefault, selectedProvider) { - - var name = selectedProvider[0]; - var url = selectedProvider[1]; - var key = selectedProvider[2]; - - if (!name) - return; - - if (!url) - return; - - if (!key) - return; - - var params = {url: url, name: name, key: key}; - var returnData; - - $(".updating_categories").wrapInner('<span><img src="' + sbRoot + '/images/loading16' + themeSpinner + '.gif"> Updating Categories ...</span>'); - var jqxhr = $.getJSON(sbRoot + '/config/providers/getNewznabCategories', params, + + var name = selectedProvider[0]; + var url = selectedProvider[1]; + var key = selectedProvider[2]; + + if (!name) + return; + + if (!url) + return; + + if (!key) + return; + + var params = {url: url, name: name, key: key}; + var returnData; + + $(".updating_categories").wrapInner('<span><img src="' + sbRoot + '/images/loading16' + themeSpinner + '.gif"> Updating Categories ...</span>'); + var jqxhr = $.getJSON(sbRoot + '/config/providers/getNewznabCategories', params, function(data){ $(this).updateNewznabCaps( data, selectedProvider ); console.debug(data.tv_categories); }); - jqxhr.always(function() { - $(".updating_categories").empty(); - }); + jqxhr.always(function() { + $(".updating_categories").empty(); + }); }; - + $.fn.addProvider = function (id, name, url, key, cat, isDefault, showProvider) { - url = $.trim(url); - if (!url) - return; - - if (!/^https?:\/\//i.test(url)) - url = "http://" + url; - - if (url.match('/$') == null) - url = url + '/'; + url = $.trim(url); + if (!url) + return; + + if (!/^https?:\/\//i.test(url)) url = "http://" + url; + + if (url.match('/$') === null) url = url + '/'; var newData = [isDefault, [name, url, key, cat]]; newznabProviders[id] = newData; @@ -68,17 +66,15 @@ $(document).ready(function(){ $(this).populateNewznabSection(); } - if ($('#provider_order_list > #'+id).length == 0 && showProvider != false) { - var toAdd = '<li class="ui-state-default" id="' + id + '"> <input type="checkbox" id="enable_' + id + '" class="provider_enabler" CHECKED> <a href="' + anonURL + url + '" class="imgLink" target="_new"><img src="' + sbRoot - + '/images/providers/newznab.png" alt="' + name + '" width="16" height="16"></a> ' + name + '</li>' + if ($('#provider_order_list > #'+id).length === 0 && showProvider !== false) { + var toAdd = '<li class="ui-state-default" id="' + id + '"> <input type="checkbox" id="enable_' + id + '" class="provider_enabler" CHECKED> <a href="' + anonURL + url + '" class="imgLink" target="_new"><img src="' + sbRoot + '/images/providers/newznab.png" alt="' + name + '" width="16" height="16"></a> ' + name + '</li>'; $('#provider_order_list').append(toAdd); $('#provider_order_list').sortable("refresh"); } $(this).makeNewznabProviderString(); - - } + }; $.fn.addTorrentRssProvider = function (id, name, url, cookies, titleTAG) { @@ -88,17 +84,15 @@ $(document).ready(function(){ $('#editATorrentRssProvider').addOption(id, name); $(this).populateTorrentRssSection(); - if ($('#provider_order_list > #'+id).length == 0) { - var toAdd = '<li class="ui-state-default" id="' + id + '"> <input type="checkbox" id="enable_' + id + '" class="provider_enabler" CHECKED> <a href="' + anonURL + url + '" class="imgLink" target="_new"><img src="' + sbRoot - + '/images/providers/torrentrss.png" alt="' + name + '" width="16" height="16"></a> ' + name + '</li>' + if ($('#provider_order_list > #'+id).length === 0) { + var toAdd = '<li class="ui-state-default" id="' + id + '"> <input type="checkbox" id="enable_' + id + '" class="provider_enabler" CHECKED> <a href="' + anonURL + url + '" class="imgLink" target="_new"><img src="' + sbRoot + '/images/providers/torrentrss.png" alt="' + name + '" width="16" height="16"></a> ' + name + '</li>'; $('#provider_order_list').append(toAdd); $('#provider_order_list').sortable("refresh"); } $(this).makeTorrentRssProviderString(); - - } + }; $.fn.updateProvider = function (id, url, key, cat) { @@ -110,7 +104,7 @@ $(document).ready(function(){ $(this).makeNewznabProviderString(); - } + }; $.fn.deleteProvider = function (id) { @@ -120,7 +114,7 @@ $(document).ready(function(){ $('li').remove('#'+id); $(this).makeNewznabProviderString(); - } + }; $.fn.updateTorrentRssProvider = function (id, url, cookies, titleTAG) { torrentRssProviders[id][1] = url; @@ -128,7 +122,7 @@ $(document).ready(function(){ torrentRssProviders[id][3] = titleTAG; $(this).populateTorrentRssSection(); $(this).makeTorrentRssProviderString(); - } + }; $.fn.deleteTorrentRssProvider = function (id) { $('#editATorrentRssProvider').removeOption(id); @@ -136,35 +130,37 @@ $(document).ready(function(){ $(this).populateTorrentRssSection(); $('li').remove('#'+id); $(this).makeTorrentRssProviderString(); - } + }; $.fn.populateNewznabSection = function() { var selectedProvider = $('#editANewznabProvider :selected').val(); + var data = ''; + var isDefault = ''; if (selectedProvider == 'addNewznab') { - var data = ['','','']; - var isDefault = 0; + data = ['','','']; + isDefault = 0; $('#newznab_add_div').show(); $('#newznab_update_div').hide(); $('#newznab_cat').attr('disabled','disabled'); $('#newznab_cap').attr('disabled','disabled'); $('#newznab_cat_update').attr('disabled','disabled'); $('#newznabcapdiv').hide(); - + $("#newznab_cat option").each(function() { - $(this).remove(); - return; + $(this).remove(); + return; }); - + $("#newznab_cap option").each(function() { - $(this).remove(); - return; + $(this).remove(); + return; }); - + } else { - var data = newznabProviders[selectedProvider][1]; - var isDefault = newznabProviders[selectedProvider][0]; + data = newznabProviders[selectedProvider][1]; + isDefault = newznabProviders[selectedProvider][0]; $('#newznab_add_div').hide(); $('#newznab_update_div').show(); $('#newznab_cat').removeAttr("disabled"); @@ -176,25 +172,23 @@ $(document).ready(function(){ $('#newznab_name').val(data[0]); $('#newznab_url').val(data[1]); $('#newznab_key').val(data[2]); - + //Check if not already array if (typeof data[3] === 'string') { - rrcat = data[3].split(",") - } - else { - rrcat = data[3]; + rrcat = data[3].split(","); + } else { + rrcat = data[3]; } - + // Update the category select box (on the right) var newCatOptions = []; if (rrcat) { - rrcat.forEach(function (cat) { - if (cat != "") - newCatOptions.push({text : cat, value : cat}); + rrcat.forEach(function (cat) { + if (cat !== '') newCatOptions.push({text : cat, value : cat}); }); - $("#newznab_cat").replaceOptions(newCatOptions); - }; - + $("#newznab_cat").replaceOptions(newCatOptions); + } + if (selectedProvider == 'addNewznab') { $('#newznab_name').removeAttr("disabled"); $('#newznab_url').removeAttr("disabled"); @@ -208,81 +202,79 @@ $(document).ready(function(){ } else { $('#newznab_url').removeAttr("disabled"); $('#newznab_delete').removeAttr("disabled"); - + //Get Categories Capabilities if (data[0] && data[1] && data[2] && !ifExists($.fn.newznabProvidersCapabilities, data[0])) { - $(this).getCategories(isDefault, data); + $(this).getCategories(isDefault, data); } $(this).updateNewznabCaps( null, data ); } } - } + }; ifExists = function(loopThroughArray, searchFor) { - var found = false; - - loopThroughArray.forEach(function(rootObject) { - if (rootObject.name == searchFor) { - found = true; - } - console.log(rootObject.name + " while searching for: "+ searchFor); - }); - return found; + var found = false; + + loopThroughArray.forEach(function(rootObject) { + if (rootObject.name == searchFor) { + found = true; + } + console.log(rootObject.name + " while searching for: "+ searchFor); + }); + return found; }; - + /** - * Updates the Global array $.fn.newznabProvidersCapabilities with a combination of newznab prov name + * Updates the Global array $.fn.newznabProvidersCapabilities with a combination of newznab prov name * and category capabilities. Return * @param {Array} newzNabCaps, is the returned object with newzNabprod Name and Capabilities. * @param {Array} selectedProvider * @return no return data. The multiselect input $("#newznab_cap") is updated, as a result. */ $.fn.updateNewznabCaps = function( newzNabCaps, selectedProvider ) { - - if (newzNabCaps && !ifExists($.fn.newznabProvidersCapabilities, selectedProvider[0])) { - $.fn.newznabProvidersCapabilities.push({'name' : selectedProvider[0], 'categories' : newzNabCaps.tv_categories}); - } - - //Loop through the array and if currently selected newznab provider name matches one in the array, use it to + + if (newzNabCaps && !ifExists($.fn.newznabProvidersCapabilities, selectedProvider[0])) { + $.fn.newznabProvidersCapabilities.push({'name' : selectedProvider[0], 'categories' : newzNabCaps.tv_categories}); + } + + //Loop through the array and if currently selected newznab provider name matches one in the array, use it to //update the capabilities select box (on the left). if (selectedProvider[0]) { - $.fn.newznabProvidersCapabilities.forEach(function(newzNabCap) { - - if (newzNabCap.name && newzNabCap.name == selectedProvider[0] && newzNabCap.categories instanceof Array) { - var newCapOptions = []; - newzNabCap.categories.forEach(function(category_set) { - if (category_set.id && category_set.name) { - newCapOptions.push({value : category_set.id, text : category_set.name + "(" + category_set.id + ")"}); - } - }); - $("#newznab_cap").replaceOptions(newCapOptions); - } + $.fn.newznabProvidersCapabilities.forEach(function(newzNabCap) { + + if (newzNabCap.name && newzNabCap.name == selectedProvider[0] && newzNabCap.categories instanceof Array) { + var newCapOptions = []; + newzNabCap.categories.forEach(function(category_set) { + if (category_set.id && category_set.name) { + newCapOptions.push({value : category_set.id, text : category_set.name + "(" + category_set.id + ")"}); + } + }); + $("#newznab_cap").replaceOptions(newCapOptions); + } }); } }; - - $.fn.makeNewznabProviderString = function() { - var provStrings = new Array(); + $.fn.makeNewznabProviderString = function() { + var provStrings = []; for (var id in newznabProviders) { provStrings.push(newznabProviders[id][1].join('|')); } - $('#newznab_string').val(provStrings.join('!!!')) - - } + $('#newznab_string').val(provStrings.join('!!!')); + }; $.fn.populateTorrentRssSection = function() { - var selectedProvider = $('#editATorrentRssProvider :selected').val(); + var data = ''; if (selectedProvider == 'addTorrentRss') { - var data = ['','','','title']; + data = ['','','','title']; $('#torrentrss_add_div').show(); $('#torrentrss_update_div').hide(); } else { - var data = torrentRssProviders[selectedProvider]; + data = torrentRssProviders[selectedProvider]; $('#torrentrss_add_div').hide(); $('#torrentrss_update_div').show(); } @@ -305,44 +297,41 @@ $(document).ready(function(){ $('#torrentrss_delete').removeAttr("disabled"); } - } + }; $.fn.makeTorrentRssProviderString = function() { - - var provStrings = new Array(); + var provStrings = []; for (var id in torrentRssProviders) { provStrings.push(torrentRssProviders[id].join('|')); } - $('#torrentrss_string').val(provStrings.join('!!!')) - - } + $('#torrentrss_string').val(provStrings.join('!!!')); + }; $.fn.refreshProviderList = function() { var idArr = $("#provider_order_list").sortable('toArray'); - var finalArr = new Array(); + var finalArr = []; $.each(idArr, function(key, val) { var checked = + $('#enable_'+val).prop('checked') ? '1' : '0'; finalArr.push(val + ':' + checked); }); - $("#provider_order").val(finalArr.join(' ')); - + $("#provider_order").val(finalArr.join(' ')); $(this).refreshEditAProvider(); - } + }; $.fn.refreshEditAProvider = function() { $('#provider-list').empty(); var idArr = $("#provider_order_list").sortable('toArray'); - var finalArr = new Array(); + var finalArr = []; $.each(idArr, function(key, val) { if ($('#enable_'+val).prop('checked')) { finalArr.push(val); } }); - + if (finalArr.length > 0) { $('<select>').prop('id','editAProvider').addClass('form-control input-sm').appendTo('#provider-list'); for (var i = 0; i < finalArr.length; i++) { @@ -354,11 +343,11 @@ $(document).ready(function(){ } $(this).showHideProviders(); - } + }; + + var newznabProviders = []; + var torrentRssProviders = []; - var newznabProviders = new Array(); - var torrentRssProviders = new Array(); - $(this).on('change', '.newznab_key', function(){ var provider_id = $(this).attr('id'); @@ -373,29 +362,24 @@ $(document).ready(function(){ }); $('#newznab_key,#newznab_url').change(function(){ - var selectedProvider = $('#editANewznabProvider :selected').val(); - if (selectedProvider == "addNewznab") - return; - + if (selectedProvider == "addNewznab") return; + var url = $('#newznab_url').val(); var key = $('#newznab_key').val(); var cat = $('#newznab_cat option').map(function(i, opt) { - return $(opt).text(); - }).toArray().join(','); - - $(this).updateProvider(selectedProvider, url, key, cat); + return $(opt).text(); + }).toArray().join(','); + $(this).updateProvider(selectedProvider, url, key, cat); }); $('#torrentrss_url,#torrentrss_cookies,#torrentrss_titleTAG').change(function(){ - var selectedProvider = $('#editATorrentRssProvider :selected').val(); - if (selectedProvider == "addTorrentRss") - return; + if (selectedProvider == "addTorrentRss") return; var url = $('#torrentrss_url').val(); var cookies = $('#torrentrss_cookies').val(); @@ -422,42 +406,42 @@ $(document).ready(function(){ $('#newznab_cat_update').click(function(){ console.debug('Clicked Button'); - + // Maybe check if there is anything selected? $("#newznab_cat option").each(function() { - $(this).remove(); + $(this).remove(); }); - + var newOptions = []; - - // When the update botton is clicked, loop through the capabilities list + + // When the update botton is clicked, loop through the capabilities list // and copy the selected category id's to the category list on the right. $("#newznab_cap option:selected").each(function(){ var selected_cat = $(this).val(); console.debug(selected_cat); - newOptions.push({text: selected_cat, value: selected_cat}) + newOptions.push({text: selected_cat, value: selected_cat}); }); - + $("#newznab_cat").replaceOptions(newOptions); - + var selectedProvider = $("#editANewznabProvider :selected").val(); if (selectedProvider == "addNewznab") return; - - var url = $('#newznab_url').val(); - var key = $('#newznab_key').val(); - - var cat = $('#newznab_cat option').map(function(i, opt) { - return $(opt).text(); - }).toArray().join(','); - - $("#newznab_cat option:not([value])").remove(); - + + var url = $('#newznab_url').val(); + var key = $('#newznab_key').val(); + + var cat = $('#newznab_cat option').map(function(i, opt) { + return $(opt).text(); + }).toArray().join(','); + + $("#newznab_cat option:not([value])").remove(); + $(this).updateProvider(selectedProvider, url, key, cat); }); - - + + $('#newznab_add').click(function(){ var selectedProvider = $('#editANewznabProvider :selected').val(); @@ -466,26 +450,26 @@ $(document).ready(function(){ var url = $.trim($('#newznab_url').val()); var key = $.trim($('#newznab_key').val()); //var cat = $.trim($('#newznab_cat').val()); - + var cat = $.trim($('#newznab_cat option').map(function(i, opt) { - return $(opt).text();}).toArray().join(',')); - - + return $(opt).text();}).toArray().join(',')); + + if (!name) - return; + return; if (!url) - return; + return; if (!key) - return; + return; var params = {name: name}; // send to the form with ajax, get a return value $.getJSON(sbRoot + '/config/providers/canAddNewznabProvider', params, function(data){ - if (data.error != undefined) { + if (data.error !== undefined) { alert(data.error); return; } @@ -496,11 +480,8 @@ $(document).ready(function(){ }); $('.newznab_delete').click(function(){ - var selectedProvider = $('#editANewznabProvider :selected').val(); - $(this).deleteProvider(selectedProvider); - }); $('#torrentrss_add').click(function(){ @@ -510,12 +491,12 @@ $(document).ready(function(){ var url = $('#torrentrss_url').val(); var cookies = $('#torrentrss_cookies').val(); var titleTAG = $('#torrentrss_titleTAG').val(); - var params = { name: name, url: url, cookies: cookies, titleTAG: titleTAG} + var params = { name: name, url: url, cookies: cookies, titleTAG: titleTAG}; // send to the form with ajax, get a return value $.getJSON(sbRoot + '/config/providers/canAddTorrentRssProvider', params, function(data){ - if (data.error != undefined) { + if (data.error !== undefined) { alert(data.error); return; } @@ -538,57 +519,52 @@ $(document).ready(function(){ }); $(this).on('change', "[class='providerDiv_tip'] select", function(){ - - $(this).find('option').each( function() { - if ($(this).is(':selected')) { - $(this).prop('defaultSelected', true) - } else { - $(this).prop('defaultSelected', false); - } + $(this).find('option').each( function() { + if ($(this).is(':selected')) { + $(this).prop('defaultSelected', true); + } else { + $(this).prop('defaultSelected', false); + } + }); + $('div .providerDiv ' + "[name=" + $(this).attr('name') + "]").empty().replaceWith($(this).clone()); }); - $('div .providerDiv ' + "[name=" + $(this).attr('name') + "]").empty().replaceWith($(this).clone())}); - $(this).on('change', '.enabler', function(){ - if ($(this).is(':checked')) { - $('.content_'+$(this).attr('id')).each( function() { - $(this).show() - }) - } else { + if ($(this).is(':checked')) { + $('.content_'+$(this).attr('id')).each( function() { + $(this).show(); + }); + } else { $('.content_'+$(this).attr('id')).each( function() { - $(this).hide() - }) - } + $(this).hide(); + }); + } }); $(".enabler").each(function(){ if (!$(this).is(':checked')) { - $('.content_'+$(this).attr('id')).hide(); + $('.content_'+$(this).attr('id')).hide(); } else { - $('.content_'+$(this).attr('id')).show(); - } + $('.content_'+$(this).attr('id')).show(); + } }); $.fn.makeTorrentOptionString = function(provider_id) { - var seed_ratio = $('.providerDiv_tip #'+provider_id+'_seed_ratio').prop('value'); - var seed_time = $('.providerDiv_tip #'+provider_id+'_seed_time').prop('value'); - var process_met = $('.providerDiv_tip #'+provider_id+'_process_method').prop('value'); - var option_string = $('.providerDiv_tip #'+provider_id+'_option_string'); + var seed_ratio = $('.providerDiv_tip #'+provider_id+'_seed_ratio').prop('value'); + var seed_time = $('.providerDiv_tip #'+provider_id+'_seed_time').prop('value'); + var process_met = $('.providerDiv_tip #'+provider_id+'_process_method').prop('value'); + var option_string = $('.providerDiv_tip #'+provider_id+'_option_string'); - option_string.val([seed_ratio, seed_time, process_met].join('|')) - - } + option_string.val([seed_ratio, seed_time, process_met].join('|')); + }; $(this).on('change', '.seed_option', function(){ - var provider_id = $(this).attr('id').split('_')[0]; + $(this).makeTorrentOptionString(provider_id); + }); - $(this).makeTorrentOptionString(provider_id); - }); - - $.fn.replaceOptions = function(options) { var self, $option; @@ -605,7 +581,7 @@ $(document).ready(function(){ // initialization stuff - + $.fn.newznabProvidersCapabilities = []; $(this).showHideProviders(); @@ -620,8 +596,7 @@ $(document).ready(function(){ $("#provider_order_list").disableSelection(); if ($('#editANewznabProvider').length) { - $(this).populateNewznabSection(); + $(this).populateNewznabSection(); } }); - diff --git a/gui/slick/js/configSearch.js b/gui/slick/js/configSearch.js index 838d224d78544b2aa973da1dbfb99544b6f105b1..14c839b61748a7646ec99d15a10de8c16aca0640 100644 --- a/gui/slick/js/configSearch.js +++ b/gui/slick/js/configSearch.js @@ -32,29 +32,29 @@ $(document).ready(function(){ $(testSABnzbd).show(); $(testSABnzbd_result).show(); } - } + }; $.fn.rtorrent_scgi = function(){ - var selectedProvider = $('#torrent_method :selected').val(); - - if ('rtorrent' == selectedProvider) { - var hostname = $('#torrent_host').prop('value'); - var isMatch = hostname.substr(0, 7) == "scgi://"; - - if (isMatch) { - $('#torrent_username_option').hide(); - $('#torrent_username').prop('value', ''); - $('#torrent_password_option').hide(); - $('#torrent_password').prop('value', ''); - $('#torrent_auth_type_option').hide(); - $("#torrent_auth_type option[value=none]").attr('selected', 'selected'); - } else { - $('#torrent_username_option').show(); - $('#torrent_password_option').show(); - $('#torrent_auth_type_option').show(); - } - } - } + var selectedProvider = $('#torrent_method :selected').val(); + + if ('rtorrent' == selectedProvider) { + var hostname = $('#torrent_host').prop('value'); + var isMatch = hostname.substr(0, 7) == "scgi://"; + + if (isMatch) { + $('#torrent_username_option').hide(); + $('#torrent_username').prop('value', ''); + $('#torrent_password_option').hide(); + $('#torrent_password').prop('value', ''); + $('#torrent_auth_type_option').hide(); + $("#torrent_auth_type option[value=none]").attr('selected', 'selected'); + } else { + $('#torrent_username_option').show(); + $('#torrent_password_option').show(); + $('#torrent_auth_type_option').show(); + } + } + }; $.fn.torrent_method_handler = function() { @@ -69,7 +69,7 @@ $(document).ready(function(){ directory = ' directory', client = '', option_panel = '#options_torrent_blackhole'; - rpcurl = ' RPC URL' + rpcurl = ' RPC URL'; if ('blackhole' != selectedProvider) { var label_warning_deluge = '#label_warning_deluge', @@ -103,7 +103,7 @@ $(document).ready(function(){ $(path_synology).hide(); $(torrent_paused_option).show(); $(torrent_rpcurl_option).hide(); - $(this).rtorrent_scgi + $(this).rtorrent_scgi(); if ('utorrent' == selectedProvider) { client = 'uTorrent'; @@ -175,7 +175,7 @@ $(document).ready(function(){ option_panel = '#options_torrent_clients'; } $(option_panel).show(); - } + }; $('#nzb_method').change($(this).nzb_method_handler); @@ -211,6 +211,6 @@ $(document).ready(function(){ $.get(sbRoot + '/home/testTorrent', {'torrent_method': torrent_method, 'host': torrent_host, 'username': torrent_username, 'password': torrent_password}, function (data){ $('#test_torrent_result').html(data); }); }); - + $('#torrent_host').change($(this).rtorrent_scgi); }); diff --git a/gui/slick/js/configSubtitles.js b/gui/slick/js/configSubtitles.js index 91ec87474c9d2c93523c837c1c9dedd1734a210d..6a3f2f5f1a7374808800f1fecb60062f6c080502 100644 --- a/gui/slick/js/configSubtitles.js +++ b/gui/slick/js/configSubtitles.js @@ -11,47 +11,45 @@ $(document).ready(function(){ $(this).hide(); }); - } + }; $.fn.addService = function (id, name, url, key, isDefault, showService) { - - if (url.match('/$') == null) - url = url + '/' + if (url.match('/$') === null) url = url + '/'; var newData = [isDefault, [name, url, key]]; - if ($('#service_order_list > #'+id).length == 0 && showService != false) { - var toAdd = '<li class="ui-state-default" id="' + id + '"> <input type="checkbox" id="enable_' + id + '" class="service_enabler" CHECKED> <a href="' + anonURL + url + '" class="imgLink" target="_new"><img src="' + sbRoot + '/images/services/newznab.gif" alt="' + name + '" width="16" height="16"></a> ' + name + '</li>' + if ($('#service_order_list > #'+id).length === 0 && showService !== false) { + var toAdd = '<li class="ui-state-default" id="' + id + '"> <input type="checkbox" id="enable_' + id + '" class="service_enabler" CHECKED> <a href="' + anonURL + url + '" class="imgLink" target="_new"><img src="' + sbRoot + '/images/services/newznab.gif" alt="' + name + '" width="16" height="16"></a> ' + name + '</li>'; $('#service_order_list').append(toAdd); $('#service_order_list').sortable("refresh"); } - } + }; $.fn.deleteService = function (id) { $('#service_order_list > #'+id).remove(); - } + }; $.fn.refreshServiceList = function() { var idArr = $("#service_order_list").sortable('toArray'); - var finalArr = new Array(); + var finalArr = []; $.each(idArr, function(key, val) { var checked = + $('#enable_'+val).prop('checked') ? '1' : '0'; finalArr.push(val + ':' + checked); }); $("#service_order").val(finalArr.join(' ')); - } + }; $('#editAService').change(function(){ $(this).showHideServices(); }); - + $('.service_enabler').on('click', function(){ $(this).refreshServiceList(); }); - + // initialization stuff @@ -65,5 +63,5 @@ $(document).ready(function(){ }); $("#service_order_list").disableSelection(); - -}); \ No newline at end of file + +}); diff --git a/gui/slick/js/confirmations.js b/gui/slick/js/confirmations.js index c12ff1509657d6c8d18c4e90f2f3cd3a59b3c3db..b88dab2f21b12de2a0dc1c40cff4fdbdfec3e48b 100644 --- a/gui/slick/js/confirmations.js +++ b/gui/slick/js/confirmations.js @@ -1,129 +1,129 @@ $(document).ready(function () { - $('a.shutdown').bind('click', function(e) { - e.preventDefault(); - var target = $(this).attr('href'); - $.confirm({ - 'title' : 'Shutdown', - 'message' : 'Are you sure you want to shutdown SickRage ?', - 'buttons' : { - 'Yes' : { - 'class' : 'green', - 'action': function(){ - location.href = target; - } - }, - 'No' : { - 'class' : 'red', - 'action': function(){} // Nothing to do in this case. You can as well omit the action property. - } - } - }); - }); + $('a.shutdown').bind('click', function(e) { + e.preventDefault(); + var target = $(this).attr('href'); + $.confirm({ + 'title' : 'Shutdown', + 'message' : 'Are you sure you want to shutdown SickRage ?', + 'buttons' : { + 'Yes' : { + 'class' : 'green', + 'action': function(){ + location.href = target; + } + }, + 'No' : { + 'class' : 'red', + 'action': function(){} // Nothing to do in this case. You can as well omit the action property. + } + } + }); + }); - $('a.restart').bind('click', function(e) { - e.preventDefault(); - var target = $(this).attr('href'); - $.confirm({ - 'title' : 'Restart', - 'message' : 'Are you sure you want to restart SickRage ?', - 'buttons' : { - 'Yes' : { - 'class' : 'green', - 'action': function(){ - location.href = target; - } - }, - 'No' : { - 'class' : 'red', - 'action': function(){} // Nothing to do in this case. You can as well omit the action property. - } - } - }); - }); + $('a.restart').bind('click', function(e) { + e.preventDefault(); + var target = $(this).attr('href'); + $.confirm({ + 'title' : 'Restart', + 'message' : 'Are you sure you want to restart SickRage ?', + 'buttons' : { + 'Yes' : { + 'class' : 'green', + 'action': function(){ + location.href = target; + } + }, + 'No' : { + 'class' : 'red', + 'action': function(){} // Nothing to do in this case. You can as well omit the action property. + } + } + }); + }); - $('a.removeshow').on('click', function(e) { - e.preventDefault(); - var target = $(this).attr('href'); - var showname = document.getElementById("showtitle").getAttribute('data-showname'); - $.confirm({ - 'title' : 'Remove Show', - 'message' : 'Are you sure you want to remove <span class="footerhighlight">' + showname + '</span> from the database ?<br /><br /><input type="checkbox" id="deleteFiles"> <span class="red-text">Check to delete files as well. IRREVERSIBLE</span></input>', - 'buttons' : { - 'Yes' : { - 'class' : 'green', - 'action': function(){ - location.href = target + (document.getElementById('deleteFiles').checked ? '&full=1' : ''); - // If checkbox is ticked, remove show and delete files. Else just remove show. - } - }, - 'No' : { - 'class' : 'red', - 'action': function(){} // Nothing to do in this case. You can as well omit the action property. - } - } - }); - }); + $('a.removeshow').on('click', function(e) { + e.preventDefault(); + var target = $(this).attr('href'); + var showname = document.getElementById("showtitle").getAttribute('data-showname'); + $.confirm({ + 'title' : 'Remove Show', + 'message' : 'Are you sure you want to remove <span class="footerhighlight">' + showname + '</span> from the database ?<br /><br /><input type="checkbox" id="deleteFiles"> <span class="red-text">Check to delete files as well. IRREVERSIBLE</span></input>', + 'buttons' : { + 'Yes' : { + 'class' : 'green', + 'action': function(){ + location.href = target + (document.getElementById('deleteFiles').checked ? '&full=1' : ''); + // If checkbox is ticked, remove show and delete files. Else just remove show. + } + }, + 'No' : { + 'class' : 'red', + 'action': function(){} // Nothing to do in this case. You can as well omit the action property. + } + } + }); + }); - $('a.clearhistory').bind('click', function(e) { - e.preventDefault(); - var target = $(this).attr('href'); - $.confirm({ - 'title' : 'Clear History', - 'message' : 'Are you sure you want to clear all download history ?', - 'buttons' : { - 'Yes' : { - 'class' : 'green', - 'action': function(){ - location.href = target; - } - }, - 'No' : { - 'class' : 'red', - 'action': function(){} // Nothing to do in this case. You can as well omit the action property. - } - } - }); - }); + $('a.clearhistory').bind('click', function(e) { + e.preventDefault(); + var target = $(this).attr('href'); + $.confirm({ + 'title' : 'Clear History', + 'message' : 'Are you sure you want to clear all download history ?', + 'buttons' : { + 'Yes' : { + 'class' : 'green', + 'action': function(){ + location.href = target; + } + }, + 'No' : { + 'class' : 'red', + 'action': function(){} // Nothing to do in this case. You can as well omit the action property. + } + } + }); + }); - $('a.trimhistory').bind('click', function(e) { - e.preventDefault(); - var target = $(this).attr('href'); - $.confirm({ - 'title' : 'Trim History', - 'message' : 'Are you sure you want to trim all download history older than 30 days ?', - 'buttons' : { - 'Yes' : { - 'class' : 'green', - 'action': function(){ - location.href = target; - } - }, - 'No' : { - 'class' : 'red', - 'action': function(){} // Nothing to do in this case. You can as well omit the action property. - } - } - }); - }); + $('a.trimhistory').bind('click', function(e) { + e.preventDefault(); + var target = $(this).attr('href'); + $.confirm({ + 'title' : 'Trim History', + 'message' : 'Are you sure you want to trim all download history older than 30 days ?', + 'buttons' : { + 'Yes' : { + 'class' : 'green', + 'action': function(){ + location.href = target; + } + }, + 'No' : { + 'class' : 'red', + 'action': function(){} // Nothing to do in this case. You can as well omit the action property. + } + } + }); + }); - $('a.submiterrors').on('click', function(e) { - e.preventDefault(); - var target = $(this).attr('href'); - $.confirm({ - 'title' : 'Submit Errors', - 'message' : 'Are you sure you want to submit these errors ?<br /><br /><span class="red-text">Make sure SickRage is updated and trigger<br /> this error with debug enabled before submitting</span>', - 'buttons' : { - 'Yes' : { - 'class' : 'green', - 'action': function(){ - location.href = target; - } - }, - 'No' : { - 'class' : 'red', - 'action': function(){} // Nothing to do in this case. You can as well omit the action property. - } - } - }); - }); + $('a.submiterrors').on('click', function(e) { + e.preventDefault(); + var target = $(this).attr('href'); + $.confirm({ + 'title' : 'Submit Errors', + 'message' : 'Are you sure you want to submit these errors ?<br /><br /><span class="red-text">Make sure SickRage is updated and trigger<br /> this error with debug enabled before submitting</span>', + 'buttons' : { + 'Yes' : { + 'class' : 'green', + 'action': function(){ + location.href = target; + } + }, + 'No' : { + 'class' : 'red', + 'action': function(){} // Nothing to do in this case. You can as well omit the action property. + } + } + }); + }); }); diff --git a/gui/slick/js/displayShow.js b/gui/slick/js/displayShow.js index c7d59a8beb134cbf0261e8de65186d14421b5680..8f413118b1cf5c9e4d49022e9a763970a2c3bc5d 100644 --- a/gui/slick/js/displayShow.js +++ b/gui/slick/js/displayShow.js @@ -7,7 +7,9 @@ $(document).ready(function () { $('#seasonJump').change(function () { var id = $('#seasonJump option:selected').val(); if (id && id != 'jump') { - $('html,body').animate({scrollTop: $('[name ="' + id.substring(1) + '"]').offset().top - 50}, 'slow'); + var season = $('#seasonJump option:selected').data('season'); + $('html,body').animate({scrollTop: $('[name ="' + id.substring(1) + '"]').offset().top - 50}, 'slow'); + $('#collapseSeason-' + season).collapse('show'); location.hash = id; } $(this).val('jump'); @@ -25,21 +27,16 @@ $(document).ready(function () { $('#changeStatus').click(function () { var sbRoot = $('#sbRoot').val(); - var epArr = new Array() + var epArr = []; $('.epCheck').each(function () { - - if (this.checked == true) { - epArr.push($(this).attr('id')) - } - + if (this.checked === true) epArr.push($(this).attr('id')); }); - if (epArr.length == 0) - return false; + if (epArr.length === 0) return false; url = sbRoot + '/home/setStatus?show=' + $('#showID').attr('value') + '&eps=' + epArr.join('|') + '&status=' + $('#statusSelect').val(); - window.location.href = url + window.location.href = url; }); @@ -50,10 +47,7 @@ $(document).ready(function () { $('#collapseSeason-' + seasNo).collapse('show'); $('.epCheck:visible').each(function () { var epParts = $(this).attr('id').split('x'); - - if (epParts[0] == seasNo) { - this.checked = seasCheck.checked - } + if (epParts[0] == seasNo) this.checked = seasCheck.checked; }); }); @@ -86,20 +80,20 @@ $(document).ready(function () { // selects all visible episode checkboxes. $('.seriesCheck').click(function () { $('.epCheck:visible').each(function () { - this.checked = true + this.checked = true; }); $('.seasonCheck:visible').each(function () { - this.checked = true - }) + this.checked = true; + }); }); // clears all visible episode checkboxes and the season selectors $('.clearAll').click(function () { $('.epCheck:visible').each(function () { - this.checked = false + this.checked = false; }); $('.seasonCheck:visible').each(function () { - this.checked = false + this.checked = false; }); }); @@ -107,10 +101,9 @@ $(document).ready(function () { $('#pickShow').change(function () { var sbRoot = $('#sbRoot').val(); var val = $(this).val(); - if (val == 0) - return; + if (val === 0) return; url = sbRoot + '/home/displayShow?show=' + val; - window.location.href = url + window.location.href = url; }); // show/hide different types of rows when the checkboxes are changed @@ -147,16 +140,15 @@ $(document).ready(function () { var numRows = 0; var seasonNo = $(this).attr('id'); $('tr.' + seasonNo + ' :visible').each(function () { - numRows++ + numRows++; }); - if (numRows == 0) { + if (numRows === 0) { $(this).hide(); - $('#' + seasonNo + '-cols').hide() + $('#' + seasonNo + '-cols').hide(); } else { $(this).show(); - $('#' + seasonNo + '-cols').show() + $('#' + seasonNo + '-cols').show(); } - }); }; @@ -260,5 +252,5 @@ $(document).ready(function () { sceneAbsolute = m[1]; } setAbsoluteSceneNumbering(forAbsolute, sceneAbsolute); - }); + }); }); diff --git a/gui/slick/js/failedDownloads.js b/gui/slick/js/failedDownloads.js index 1b081ad97c166d4f3d7496024bafc178cfb90afe..7d7fe27349804729fb14055dc8133a9eab859f6f 100644 --- a/gui/slick/js/failedDownloads.js +++ b/gui/slick/js/failedDownloads.js @@ -1,60 +1,48 @@ $(document).ready(function(){ - $('#submitMassRemove').click(function(){ + $('#submitMassRemove').click(function(){ + var removeArr = []; - var removeArr = new Array() + $('.removeCheck').each(function() { + if (this.checked === true) { + removeArr.push($(this).attr('id').split('-')[1]); + } + }); - $('.removeCheck').each(function() { - if (this.checked == true) { - removeArr.push($(this).attr('id').split('-')[1]) - } - }); - - if (removeArr.length == 0) - return false - - url = sbRoot + '/manage/failedDownloads?toRemove='+removeArr.join('|') - - window.location.href = url + if (removeArr.length === 0) return false; - }); - - $('.bulkCheck').click(function(){ - - var bulkCheck = this; - var whichBulkCheck = $(bulkCheck).attr('id'); - - $('.'+whichBulkCheck+':visible').each(function(){ - this.checked = bulkCheck.checked + url = sbRoot + '/manage/failedDownloads?toRemove='+removeArr.join('|'); + window.location.href = url; }); - }); - - ['.removeCheck'].forEach(function(name) { - var lastCheck = null; - $(name).click(function(event) { - - if(!lastCheck || !event.shiftKey) { - lastCheck = this; - return; - } - - var check = this; - var found = 0; - - $(name+':visible').each(function() { - switch (found) { - case 2: return false; - case 1: - this.checked = lastCheck.checked; - } - - if (this == check || this == lastCheck) - found++; - }); + $('.bulkCheck').click(function(){ + var bulkCheck = this; + var whichBulkCheck = $(bulkCheck).attr('id'); + $('.'+whichBulkCheck+':visible').each(function(){ + this.checked = bulkCheck.checked; + }); }); - }); - - + $('.removeCheck').forEach(function(name) { + var lastCheck = null; + $(name).click(function(event) { + if(!lastCheck || !event.shiftKey) { + lastCheck = this; + return; + } + + var check = this; + var found = 0; + + $(name+':visible').each(function() { + switch (found) { + case 2: return false; + case 1: + this.checked = lastCheck.checked; + } + + if (this == check || this == lastCheck) found++; + }); + }); + }); }); diff --git a/gui/slick/js/manageEpisodeStatuses.js b/gui/slick/js/manageEpisodeStatuses.js index f9d310314728e63dae482635b378e063b496d8b2..61fad70d6c8dea4d2a2366c3ff62a7a1893d3e35 100644 --- a/gui/slick/js/manageEpisodeStatuses.js +++ b/gui/slick/js/manageEpisodeStatuses.js @@ -1,20 +1,17 @@ -$(document).ready(function() { +$(document).ready(function() { function make_row(indexer_id, season, episode, name, checked) { - if (checked) - var checked = ' checked'; - else - var checked = ''; - + checked = checked ? ' checked' : ''; + var row_class = $('#row_class').val(); - + var row = ''; row += ' <tr class="'+row_class+' show-'+indexer_id+'">'; row += ' <td class="tableleft" align="center"><input type="checkbox" class="'+indexer_id+'-epcheck" name="'+indexer_id+'-'+season+'x'+episode+'"'+checked+'></td>'; row += ' <td>'+season+'x'+episode+'</td>'; row += ' <td class="tableright" style="width: 100%">'+name+'</td>'; - row += ' </tr>' - + row += ' </tr>'; + return row; } @@ -29,7 +26,7 @@ $(document).ready(function() { var last_row = $('tr#'+cur_indexer_id); var clicked = $(this).attr('data-clicked'); var action = $(this).attr('value'); - + if (!clicked) { $.getJSON(sbRoot+'/manage/showEpisodeStatuses', { @@ -44,7 +41,7 @@ $(document).ready(function() { }); }); }); - $(this).attr('data-clicked',1); + $(this).attr('data-clicked',1); $(this).prop('value', 'Collapse'); } else { if (action === 'Collapse') { @@ -53,9 +50,9 @@ $(document).ready(function() { } else if (action === 'Expand') { $('table tr').filter('.show-'+cur_indexer_id).show(); - $(this).prop('value', 'Collapse'); + $(this).prop('value', 'Collapse'); } - + } }); @@ -79,4 +76,4 @@ $(document).ready(function() { }); }); -}); \ No newline at end of file +}); diff --git a/gui/slick/js/manageSubtitleMissed.js b/gui/slick/js/manageSubtitleMissed.js index 08c78d890b2b38342d10ab8ac1394d285a6b2d1f..cc292030c15c51f15848cb8c361e45cc7ad897ca 100644 --- a/gui/slick/js/manageSubtitleMissed.js +++ b/gui/slick/js/manageSubtitleMissed.js @@ -1,24 +1,20 @@ -$(document).ready(function() { +$(document).ready(function() { function make_row(indexer_id, season, episode, name, subtitles, checked) { - if (checked) - var checked = ' checked'; - else - var checked = ''; + checked = checked ? ' checked' : ''; var row = ''; row += ' <tr class="good show-' + indexer_id + '">'; row += ' <td align="center"><input type="checkbox" class="'+indexer_id+'-epcheck" name="'+indexer_id+'-'+season+'x'+episode+'"'+checked+'></td>'; row += ' <td style="width: 1%;">'+season+'x'+episode+'</td>'; row += ' <td>'+name+'</td>'; - row += ' <td style="float: right;">'; - subtitles = subtitles.split(',') - for (var i in subtitles) - { - row += ' <img src="/images/subtitles/flags/'+subtitles[i]+'.png" width="16" height="11" alt="'+subtitles[i]+'" /> '; - } + row += ' <td style="float: right;">'; + subtitles = subtitles.split(','); + for (var i in subtitles) { + row += ' <img src="/images/subtitles/flags/'+subtitles[i]+'.png" width="16" height="11" alt="'+subtitles[i]+'" /> '; + } row += ' </td>'; - row += ' </tr>' + row += ' </tr>'; return row; } diff --git a/gui/slick/js/massUpdate.js b/gui/slick/js/massUpdate.js index 751ff1475ed6734d97e98d292fffd25e05fe254e..1a149f6e078f60cc0f0e781269d01ca952bd98a1 100644 --- a/gui/slick/js/massUpdate.js +++ b/gui/slick/js/massUpdate.js @@ -1,91 +1,70 @@ $(document).ready(function(){ + $('#submitMassEdit').click(function(){ + var editArr = []; - $('#submitMassEdit').click(function(){ - var editArr = new Array() - - $('.editCheck').each(function() { - if (this.checked == true) { - editArr.push($(this).attr('id').split('-')[1]) - } - }); + $('.editCheck').each(function() { + if (this.checked === true) editArr.push($(this).attr('id').split('-')[1]); + }); - if (editArr.length == 0) - return + if (editArr.length === 0) return; - url = 'massEdit?toEdit='+editArr.join('|') - window.location.href = url - }); + url = 'massEdit?toEdit='+editArr.join('|'); + window.location.href = url; + }); + $('#submitMassUpdate').click(function(){ - $('#submitMassUpdate').click(function(){ - - var updateArr = new Array() - var refreshArr = new Array() - var renameArr = new Array() - var subtitleArr = new Array() - var deleteArr = new Array() - var removeArr = new Array() - var metadataArr = new Array() + var updateArr = []; + var refreshArr = []; + var renameArr = []; + var subtitleArr = []; + var deleteArr = []; + var removeArr = []; + var metadataArr = []; $('.updateCheck').each(function() { - if (this.checked == true) { - updateArr.push($(this).attr('id').split('-')[1]) - } + if (this.checked === true) updateArr.push($(this).attr('id').split('-')[1]); }); $('.refreshCheck').each(function() { - if (this.checked == true) { - refreshArr.push($(this).attr('id').split('-')[1]) - } - }); + if (this.checked === true) refreshArr.push($(this).attr('id').split('-')[1]); + }); $('.renameCheck').each(function() { - if (this.checked == true) { - renameArr.push($(this).attr('id').split('-')[1]) - } + if (this.checked === true) renameArr.push($(this).attr('id').split('-')[1]); }); - $('.subtitleCheck').each(function() { - if (this.checked == true) { - subtitleArr.push($(this).attr('id').split('-')[1]) - } + $('.subtitleCheck').each(function() { + if (this.checked === true) subtitleArr.push($(this).attr('id').split('-')[1]); + }); + + $('.removeCheck').each(function() { + if (this.checked === true) removeArr.push($(this).attr('id').split('-')[1]); }); - $('.removeCheck').each(function() { - if (this.checked == true) { - removeArr.push($(this).attr('id').split('-')[1]) - } - }); - var deleteCount = 0; $('.deleteCheck').each(function() { - if (this.checked == true) { - deleteCount++; - } + if (this.checked === true) deleteCount++; }); - + if (deleteCount >= 1) { bootbox.confirm("You have selected to delete " + deleteCount + " show(s). Are you sure you wish to cntinue? All files will be removed from your system.", function(result) { if (result) { $('.deleteCheck').each(function() { - if (this.checked == true) { - deleteArr.push($(this).attr('id').split('-')[1]) + if (this.checked === true) { + deleteArr.push($(this).attr('id').split('-')[1]); } }); } - if (updateArr.length+refreshArr.length+renameArr.length+subtitleArr.length+deleteArr.length+removeArr.length+metadataArr.length == 0) - return false; + if (updateArr.length+refreshArr.length+renameArr.length+subtitleArr.length+deleteArr.length+removeArr.length+metadataArr.length === 0) return false; url = 'massUpdate?toUpdate='+updateArr.join('|')+'&toRefresh='+refreshArr.join('|')+'&toRename='+renameArr.join('|')+'&toSubtitle='+subtitleArr.join('|')+'&toDelete='+deleteArr.join('|')+'&toRemove='+removeArr.join('|')+'&toMetadata='+metadataArr.join('|'); - window.location.href = url + window.location.href = url; }); - } - else - { - if (updateArr.length+refreshArr.length+renameArr.length+subtitleArr.length+deleteArr.length+removeArr.length+metadataArr.length == 0) - return false; + } else { + if (updateArr.length+refreshArr.length+renameArr.length+subtitleArr.length+deleteArr.length+removeArr.length+metadataArr.length === 0) return false; url = 'massUpdate?toUpdate='+updateArr.join('|')+'&toRefresh='+refreshArr.join('|')+'&toRename='+renameArr.join('|')+'&toSubtitle='+subtitleArr.join('|')+'&toDelete='+deleteArr.join('|')+'&toRemove='+removeArr.join('|')+'&toMetadata='+metadataArr.join('|'); - window.location.href = url + window.location.href = url; } /* $('.metadataCheck').each(function() { @@ -97,45 +76,36 @@ $(document).ready(function(){ }); - $('.bulkCheck').click(function(){ - - var bulkCheck = this; - var whichBulkCheck = $(bulkCheck).attr('id'); + $('.bulkCheck').click(function(){ + var bulkCheck = this; + var whichBulkCheck = $(bulkCheck).attr('id'); - $('.'+whichBulkCheck).each(function(){ - if (!this.disabled) - this.checked = !this.checked + $('.'+whichBulkCheck).each(function(){ + if (!this.disabled) this.checked = !this.checked; + }); }); - }); ['.editCheck', '.updateCheck', '.refreshCheck', '.renameCheck', '.deleteCheck', '.removeCheck'].forEach(function(name) { - var lastCheck = null; + var lastCheck = null; - $(name).click(function(event) { - - if(!lastCheck || !event.shiftKey) { - lastCheck = this; - return; - } - - var check = this; - var found = 0; - - $(name).each(function() { - switch (found) { - case 2: return false; - case 1: - if (!this.disabled) - this.checked = lastCheck.checked; - } - - if (this == check || this == lastCheck) - found++; - }); + $(name).click(function(event) { + if(!lastCheck || !event.shiftKey) { + lastCheck = this; + return; + } - lastClick = this; + var check = this; + var found = 0; + + $(name).each(function() { + switch (found) { + case 2: return false; + case 1: + if (!this.disabled) this.checked = lastCheck.checked; + } + if (this == check || this == lastCheck) found++; + }); + lastClick = this; + }); }); - - }); - }); diff --git a/gui/slick/js/new/comingEpisodes.js b/gui/slick/js/new/comingEpisodes.js index a1c5a2d1fc3ac7c804fc2892ecc1a582dfc52df8..b739fd6f6b06727a6c2db454807931e29b5a4ed9 100644 --- a/gui/slick/js/new/comingEpisodes.js +++ b/gui/slick/js/new/comingEpisodes.js @@ -2,11 +2,11 @@ if($('meta[data-var="sickbeard.COMING_EPS_LAYOUT"]').data('content') == 'list'){ $.tablesorter.addParser({ id: 'loadingNames', is: function(s) { - return false + return false; }, format: function(s) { - if (0 == s.indexOf('Loading...')){ - return s.replace('Loading...', '000') + if (0 === s.indexOf('Loading...')){ + return s.replace('Loading...', '000'); } else { return ($('meta[data-var="sickbeard.SORT_ARTICLE"]').data('content') == 'False' ? (s || '') : (s || '').replace(/^(The|A|An)\s/i,'')); } @@ -16,20 +16,20 @@ if($('meta[data-var="sickbeard.COMING_EPS_LAYOUT"]').data('content') == 'list'){ $.tablesorter.addParser({ id: 'quality', is: function(s) { - return false + return false; }, format: function(s) { - return s.replace('hd1080p', 5).replace('hd720p', 4).replace('hd', 3).replace('sd', 2).replace('any', 1).replace('best', 0).replace('custom', 7) + return s.replace('hd1080p', 5).replace('hd720p', 4).replace('hd', 3).replace('sd', 2).replace('any', 1).replace('best', 0).replace('custom', 7); }, type: 'numeric' }); $.tablesorter.addParser({ id: 'cDate', is: function(s) { - return false + return false; }, format: function(s) { - return new Date(s).getTime() + return new Date(s).getTime(); }, type: 'numeric' }); @@ -45,8 +45,8 @@ $(document).ready(function(){ widgets: ['stickyHeaders'], sortList: sortList, textExtraction: { - 0: function(node) { return $(node).find('time').attr('datetime') }, - 5: function(node) { return $(node).find('span').text().toLowerCase() } + 0: function(node) { return $(node).find('time').attr('datetime'); }, + 5: function(node) { return $(node).find('span').text().toLowerCase(); } }, headers: { 0: { sorter: 'cDate' }, @@ -69,11 +69,14 @@ $(document).ready(function(){ $('.ep_summaryTrigger').click(function() { $(this).next('.ep_summary').slideToggle('normal', function() { $(this).prev('.ep_summaryTrigger').attr('src', function(i, src) { - return $(this).next('.ep_summary').is(':visible') ? src.replace('plus','minus') : src.replace('minus','plus') + return $(this).next('.ep_summary').is(':visible') ? src.replace('plus','minus') : src.replace('minus','plus'); }); }); }); } }); -window.setInterval('location.reload(true)', 600000); // Refresh every 10 minutes +setTimeout(function () { + "use strict"; + location.reload(true); +}, 60000); diff --git a/gui/slick/js/new/home.js b/gui/slick/js/new/home.js index 85f0842be47dc4b86a2a2c96f05408111ef90902..a71dc84faca2a3a929846ee095d6b4313b329e1a 100644 --- a/gui/slick/js/new/home.js +++ b/gui/slick/js/new/home.js @@ -4,7 +4,7 @@ $.tablesorter.addParser({ return false; }, format: function(s) { - if (s.indexOf('Loading...') == 0) + if (s.indexOf('Loading...') === 0) return s.replace('Loading...','000'); else return ($('meta[data-var="sickbeard.SORT_ARTICLE"]').data('content') == 'True' ? (s || '') : (s || '').replace(/^(The|A|An)\s/i,'')); @@ -31,8 +31,7 @@ $.tablesorter.addParser({ format: function(s) { match = s.match(/^(.*)/); - if (match == null || match[1] == "?") - return -10; + if (match === null || match[1] == "?") return -10; var nums = match[1].split(" / "); if (nums[0].indexOf("+") != -1) { @@ -40,14 +39,14 @@ $.tablesorter.addParser({ nums[0] = num_parts[0]; } - nums[0] = parseInt(nums[0]) - nums[1] = parseInt(nums[1]) + nums[0] = parseInt(nums[0]); + nums[1] = parseInt(nums[1]); if (nums[0] === 0) return nums[1]; var finalNum = parseInt(($('meta[data-var="max_download_count"]').data('content'))*nums[0]/nums[1]); - var pct = Math.round((nums[0]/nums[1])*100) / 1000 + var pct = Math.round((nums[0]/nums[1])*100) / 1000; if (finalNum > 0) finalNum += nums[0]; @@ -92,7 +91,7 @@ $(document).ready(function(){ 4: { sorter: 'quality' }, 5: { sorter: 'eps' }, 6: { filter : 'parsed' } - } + }; } else { return { 0: { sorter: 'isoDate' }, @@ -100,7 +99,7 @@ $(document).ready(function(){ 2: { sorter: 'loadingNames' }, 4: { sorter: 'quality' }, 5: { sorter: 'eps' } - } + }; } }()), widgetOptions: (function(){ @@ -166,11 +165,11 @@ $(document).ready(function(){ }, filter_reset: '.resetshows', columnSelector_mediaquery: false - } + }; } else { return { filter_columnFilters: false - } + }; } }()), sortStable: true, @@ -197,7 +196,7 @@ $(document).ready(function(){ 4: { sorter: 'quality' }, 5: { sorter: 'eps' }, 6: { filter : 'parsed' } - } + }; } else { return { 0: { sorter: 'isoDate' }, @@ -205,7 +204,7 @@ $(document).ready(function(){ 2: { sorter: 'loadingNames' }, 4: { sorter: 'quality' }, 5: { sorter: 'eps' } - } + }; } }()), widgetOptions: (function(){ @@ -271,11 +270,11 @@ $(document).ready(function(){ }, filter_reset: '.resetanime', columnSelector_mediaquery: false - } + }; } else { return { filter_columnFilters: false - } + }; } }()), sortStable: true, diff --git a/gui/slick/js/newShow.js b/gui/slick/js/newShow.js index d17336c107ddea8ed368460a55a21fa4651b63ca..60d2576ac7f40558d76390f8d3b1abf3457f9910 100644 --- a/gui/slick/js/newShow.js +++ b/gui/slick/js/newShow.js @@ -3,9 +3,7 @@ $(document).ready(function () { var searchRequestXhr = null; function searchIndexers() { - if (!$('#nameToSearch').val().length) { - return; - } + if (!$('#nameToSearch').val().length) return; if (searchRequestXhr) searchRequestXhr.abort(); @@ -40,7 +38,7 @@ $(document).ready(function () { resultStr += '<input type="radio" id="whichSeries" name="whichSeries" value="' + whichSeries.replace(/"/g, "") + '"' + checked + ' /> '; - if (data.langid && data.langid != "") { + if (data.langid && data.langid !== "") { resultStr += '<a href="' + anonURL + obj[2] + obj[3] + '&lid=' + data.langid + '" onclick=\"window.open(this.href, \'_blank\'); return false;\" ><b>' + obj[4] + '</b></a>'; } else { resultStr += '<a href="' + anonURL + obj[2] + obj[3] + '" onclick=\"window.open(this.href, \'_blank\'); return false;\" ><b>' + obj[4] + '</b></a>'; @@ -84,7 +82,7 @@ $(document).ready(function () { alert('You must choose a show to continue'); return false; } - generate_bwlist() + generate_bwlist(); $('#addShowForm').submit(); }); @@ -208,7 +206,7 @@ $(document).ready(function () { $('#blackwhitelist').show(); if (show_name) { $.getJSON(sbRoot + '/home/fetch_releasegroups', {'show_name': show_name}, function (data) { - if (data['result'] == 'success') { + if (data.result == 'success') { $.each(data.groups, function(i, group) { var option = $("<option>"); option.attr("value", group.name); @@ -221,5 +219,5 @@ $(document).ready(function () { } else { $('#blackwhitelist').hide(); } - }; + } }); diff --git a/gui/slick/js/qualityChooser.js b/gui/slick/js/qualityChooser.js index 1fb8b4981e2a6aefef4a46489b797c952dd7453e..2361b9cb8afba6eb0cba2c05fbbf5e5f8f557152 100644 --- a/gui/slick/js/qualityChooser.js +++ b/gui/slick/js/qualityChooser.js @@ -1,6 +1,6 @@ $(document).ready(function() { function setFromPresets (preset) { - if (preset == 0) { + if (preset === 0) { $('#customQuality').show(); return; } else { diff --git a/gui/slick/js/ratingTooltip.js b/gui/slick/js/ratingTooltip.js index 712c2f9a80087b7ee58839563c8e7291e8b74232..5c106db24cd8f890572524affcd71156af6bbd05 100644 --- a/gui/slick/js/ratingTooltip.js +++ b/gui/slick/js/ratingTooltip.js @@ -1,18 +1,18 @@ $(function () { - $('.imdbstars').qtip({ - content: { - text: function(event, api) { - // Retrieve content from custom attribute of the $('.selector') elements. - return $(this).attr('qtip-content'); - } - }, + $('.imdbstars').qtip({ + content: { + text: function(event, api) { + // Retrieve content from custom attribute of the $('.selector') elements. + return $(this).attr('qtip-content'); + } + }, show: { solo: true }, position: { viewport: $(window), my: 'right center', - at: 'center left', + at: 'center left', adjust: { y: 0, x: -6 @@ -27,4 +27,3 @@ $(function () { } }); }); - diff --git a/gui/slick/js/restart.js b/gui/slick/js/restart.js index ae7fb75b6007ecea0ddc6083f7d0afe1f14304dd..07f741bbdd10da629bcaac2780a81dbc7d8846dc 100644 --- a/gui/slick/js/restart.js +++ b/gui/slick/js/restart.js @@ -1,65 +1,65 @@ $(document).ready(function() { - window.console_debug = false; - window.console_prefix = 'Restart: '; - window.current_pid = ''; - - var is_alive_url = sbRoot + '/home/is_alive/'; - - var check_isAlive = setInterval(is_alive, 1000); - - function is_alive() { - // Setup error detection - $.ajaxSetup({ - error: ajax_error - }); - - var jqxhr = $.get(is_alive_url, function(data) { - if (data.msg == 'nope') { - // if it's still initializing then just wait and try again - if (console_debug) { - console.log(console_prefix + 'is_alive: Sickrage is starting.'); - } - $('#shut_down_loading').hide(); - $('#shut_down_success').show(); - $('#restart_message').show(); - } else { - // if this is before we've even shut down then just try again later - if (console_debug) { - console.log(console_prefix + 'is_alive: Sickrage is shutdowning.'); - } - if (current_pid === '' || data.msg == current_pid) { - current_pid = data.msg; - // if we're ready to go then redirect to new url - } else { - clearInterval(check_isAlive); - if (console_debug) { - console.log(console_prefix + 'is_alive: Setting redirect.'); - } - $('#restart_loading').hide(); - $('#restart_success').show(); - $('#refresh_message').show(); - setTimeout(function(){window.location = sbRoot + '/' + sbDefaultPage + '/';}, 5000); - } - } - - }, 'jsonp'); - - jqxhr.fail(function() { - ajax_error(); - }); - } - - function ajax_error(x, e) { - if (console_debug) { - if (x.status === 0) { - console.log(console_prefix + 'is_alive: Sickrage is not responding.'); - } else if (x.status == 404) { - console.log(console_prefix + 'is_alive: Requested URL not found.'); - } else if (x.status == 500) { - console.log(console_prefix + 'is_alive: Internel Server Error.'); - } else { - console.log(console_prefix + 'is_alive: Unknow Error.\n' + x.responseText); - } - } - } + window.console_debug = false; + window.console_prefix = 'Restart: '; + window.current_pid = ''; + + var is_alive_url = sbRoot + '/home/is_alive/'; + + var check_isAlive = setInterval(is_alive, 1000); + + function is_alive() { + // Setup error detection + $.ajaxSetup({ + error: ajax_error + }); + + var jqxhr = $.get(is_alive_url, function(data) { + if (data.msg == 'nope') { + // if it's still initializing then just wait and try again + if (console_debug) { + console.log(console_prefix + 'is_alive: Sickrage is starting.'); + } + $('#shut_down_loading').hide(); + $('#shut_down_success').show(); + $('#restart_message').show(); + } else { + // if this is before we've even shut down then just try again later + if (console_debug) { + console.log(console_prefix + 'is_alive: Sickrage is shutdowning.'); + } + if (current_pid === '' || data.msg == current_pid) { + current_pid = data.msg; + // if we're ready to go then redirect to new url + } else { + clearInterval(check_isAlive); + if (console_debug) { + console.log(console_prefix + 'is_alive: Setting redirect.'); + } + $('#restart_loading').hide(); + $('#restart_success').show(); + $('#refresh_message').show(); + setTimeout(function(){window.location = sbRoot + '/' + sbDefaultPage + '/';}, 5000); + } + } + + }, 'jsonp'); + + jqxhr.fail(function() { + ajax_error(); + }); + } + + function ajax_error(x, e) { + if (console_debug) { + if (x.status === 0) { + console.log(console_prefix + 'is_alive: Sickrage is not responding.'); + } else if (x.status == 404) { + console.log(console_prefix + 'is_alive: Requested URL not found.'); + } else if (x.status == 500) { + console.log(console_prefix + 'is_alive: Internel Server Error.'); + } else { + console.log(console_prefix + 'is_alive: Unknow Error.\n' + x.responseText); + } + } + } }); diff --git a/gui/slick/js/rootDirs.js b/gui/slick/js/rootDirs.js index b4826dbe2fa6c508a314afcebfa312ed7c3c02e8..286ba763eafe7c2ed59b578993a6b569c6f4f441 100644 --- a/gui/slick/js/rootDirs.js +++ b/gui/slick/js/rootDirs.js @@ -63,9 +63,9 @@ $(document).ready(function() { refreshRootDirs(); $.get(sbRoot+'/config/general/saveRootDirs', {rootDirString: $('#rootDirText').val()}); } - - $('#addRootDir').click(function(){$(this).nFileBrowser(addRootDir)}); - $('#editRootDir').click(function(){$(this).nFileBrowser(editRootDir, {initialDir: $("#rootDirs option:selected").val()})}); + + $('#addRootDir').click(function(){$(this).nFileBrowser(addRootDir);}); + $('#editRootDir').click(function(){$(this).nFileBrowser(editRootDir, {initialDir: $("#rootDirs option:selected").val()});}); $('#deleteRootDir').click(function() { if ($("#rootDirs option:selected").length) { @@ -91,8 +91,7 @@ $(document).ready(function() { } else if ($("#whichDefaultRootDir").val().length) { var old_default_num = $("#whichDefaultRootDir").val().substr(3); - if (old_default_num > deleted_num) - $("#whichDefaultRootDir").val('rd-'+(old_default_num-1)) + if (old_default_num > deleted_num) $("#whichDefaultRootDir").val('rd-'+(old_default_num-1)); } } @@ -108,21 +107,17 @@ $(document).ready(function() { }); function setDefault(which, force){ - console.log('setting default to '+which); - if (which != undefined && !which.length) - return + if (which !== undefined && !which.length) return; - if ($('#whichDefaultRootDir').val() == which && force != true) - return + if ($('#whichDefaultRootDir').val() == which && force !== true) return; // put an asterisk on the text - if ($('#'+which).text().charAt(0) != '*') - $('#'+which).text('*'+$('#'+which).text()); + if ($('#'+which).text().charAt(0) != '*') $('#'+which).text('*'+$('#'+which).text()); // if there's an existing one then take the asterisk off - if ($('#whichDefaultRootDir').val() && force != true) { + if ($('#whichDefaultRootDir').val() && force !== true) { var old_default = $('#'+$('#whichDefaultRootDir').val()); old_default.text(old_default.text().substring(1)); } @@ -140,8 +135,7 @@ $(document).ready(function() { function refreshRootDirs() { - if (!$("#rootDirs").length) - return + if (!$("#rootDirs").length) return; var do_disable = 'true'; @@ -149,8 +143,7 @@ $(document).ready(function() { syncOptionIDs(); // if nothing's selected then select the default - if (!$("#rootDirs option:selected").length && $('#whichDefaultRootDir').val().length) - $('#'+$('#whichDefaultRootDir').val()).prop("selected", true) + if (!$("#rootDirs option:selected").length && $('#whichDefaultRootDir').val().length) $('#'+$('#whichDefaultRootDir').val()).prop("selected", true); // if something's selected then we have some behavior to figure out if ($("#rootDirs option:selected").length) { @@ -164,16 +157,16 @@ $(document).ready(function() { var log_str = ''; var dir_text = ''; - if ($('#whichDefaultRootDir').val().length >= 4) - var dir_text = $('#whichDefaultRootDir').val().substr(3); + if ($('#whichDefaultRootDir').val().length >= 4){ + dir_text = $('#whichDefaultRootDir').val().substr(3); + } $('#rootDirs option').each(function() { log_str += $(this).val()+'='+$(this).text()+'->'+$(this).attr('id')+'\n'; - if (dir_text.length) - dir_text += '|' + $(this).val() + if (dir_text.length) dir_text += '|' + $(this).val(); }); log_str += 'def: '+ $('#whichDefaultRootDir').val(); console.log(log_str); - + $('#rootDirText').val(dir_text); $('#rootDirText').change(); console.log('rootDirText: '+$('#rootDirText').val()); @@ -183,7 +176,6 @@ $(document).ready(function() { // set up buttons on page load syncOptionIDs(); - setDefault($('#whichDefaultRootDir').val(), true) + setDefault($('#whichDefaultRootDir').val(), true); refreshRootDirs(); - -}); \ No newline at end of file +}); diff --git a/gui/slick/js/script.js b/gui/slick/js/script.js index d1be809feb07db04d984d66ff96e20fa03993f38..cb4e383fb647a8e86c79c740ae466c6cbb46f813 100644 --- a/gui/slick/js/script.js +++ b/gui/slick/js/script.js @@ -39,11 +39,9 @@ function showMsg(msg, loader, timeout, ms) { feedback.removeAttr("style"); } feedback.fadeIn(); - var message = $("<div class='msg'>" + msg + "</div>"); - if (loader) { - var message = $("<div class='msg'><img src='interfaces/default/images/loader_black.gif' alt='loading' class='loader' style='position: relative;top:10px;margin-top:-15px; margin-left:-10px;'/>" + msg + "</div>"); - feedback.css("padding", "14px 10px") - } + var tmpMessage = $("<div class='msg'>" + msg + "</div>"); + var message = loader ? $("<div class='msg'><img src='interfaces/default/images/loader_black.gif' alt='loading' class='loader' style='position: relative;top:10px;margin-top:-15px; margin-left:-10px;'/>" + msg + "</div>") : tmpMessage; + if (loader) feedback.css("padding", "14px 10px"); $(feedback).prepend(message); if (timeout) { setTimeout(function () { @@ -67,16 +65,16 @@ function initFancybox() { $("head").append("<link rel='stylesheet' href='" + sbRoot + "/js/fancybox/jquery.fancybox.css'>"); $("a[rel=dialog]").fancybox({ type: "image", - padding: 0, - helpers : { - title : null, - overlay : { - locked: false, - css : { - 'background' : 'rgba(0, 0, 0, 0.4)' - } - } - } + padding: 0, + helpers : { + title : null, + overlay : { + locked: false, + css : { + 'background' : 'rgba(0, 0, 0, 0.4)' + } + } + } }); }); } @@ -91,11 +89,11 @@ function initTabs() { if (lastOpenedPanel) { } else { - lastOpenedPanel = $(ui.oldPanel) + lastOpenedPanel = $(ui.oldPanel); } if (!$(this).data("topPositionTab")) { - $(this).data("topPositionTab", $(ui.newPanel).position()['top']) + $(this).data("topPositionTab", $(ui.newPanel).position().top); } //Dont use the builtin fx effects. This will fade in/out both tabs, we dont want that @@ -103,7 +101,6 @@ function initTabs() { $(ui.newPanel).hide().fadeIn(0); if (lastOpenedPanel) { - // 1. Show the previous opened tab by removing the jQuery UI class // 2. Make the tab temporary position:absolute so the two tabs will overlap // 3. Set topposition so they will overlap if you go from tab 1 to tab 0 @@ -116,7 +113,6 @@ function initTabs() { $(this) .css("position", ""); }); - } //Saving the last tab has been opened @@ -135,4 +131,4 @@ function init() { $(document).ready(function () { init(); -}); \ No newline at end of file +}); diff --git a/gui/slick/js/testRename.js b/gui/slick/js/testRename.js index faf61b7028c1c040c829a9e3c118665fb3627819..f59879991c7feb98db87befc2897c59058795ed5 100644 --- a/gui/slick/js/testRename.js +++ b/gui/slick/js/testRename.js @@ -1,45 +1,42 @@ $(document).ready(function(){ - $('.seriesCheck').click(function(){ - var serCheck = this; - - $('.seasonCheck:visible').each(function(){ - - this.checked = serCheck.checked - }); - - $('.epCheck:visible').each(function(){ - - this.checked = serCheck.checked - }); - }); - + $('.seriesCheck').click(function(){ + var serCheck = this; + + $('.seasonCheck:visible').each(function(){ + this.checked = serCheck.checked; + }); + + $('.epCheck:visible').each(function(){ + this.checked = serCheck.checked; + }); + }); + $('.seasonCheck').click(function(){ var seasCheck = this; var seasNo = $(seasCheck).attr('id'); $('.epCheck:visible').each(function(){ - var epParts = $(this).attr('id').split('x') + var epParts = $(this).attr('id').split('x'); if (epParts[0] == seasNo) { - this.checked = seasCheck.checked + this.checked = seasCheck.checked; } }); }); $('input[type=submit]').click(function(){ - var epArr = new Array() + var epArr = []; $('.epCheck').each(function() { - if (this.checked == true) { - epArr.push($(this).attr('id')) + if (this.checked === true) { + epArr.push($(this).attr('id')); } - }); + }); - if (epArr.length == 0) - return false + if (epArr.length === 0) return false; - url = sbRoot+'/home/doRename?show='+$('#showID').attr('value')+'&eps='+epArr.join('|') - window.location.href = url + url = sbRoot+'/home/doRename?show='+$('#showID').attr('value')+'&eps='+epArr.join('|'); + window.location.href = url; }); - -}); \ No newline at end of file + +}); diff --git a/gui/slick/views/config.mako b/gui/slick/views/config.mako index 9d3cacc0ab4a5c7759dfccf91c30e6d5afadad90..6cd206a1cd20ab1a23bfae1c3aae48d8e02ef06c 100644 --- a/gui/slick/views/config.mako +++ b/gui/slick/views/config.mako @@ -54,8 +54,8 @@ "" % endtry - <tr><td class="infoTableHeader">SR Config file:</td><td class="infoTableCell">${sickbeard.CONFIG_FILE}</td></tr> - <tr><td class="infoTableHeader">SR Database file:</td><td class="infoTableCell">${db.dbFilename()}</td></tr> + <tr><td class="infoTableHeader">SR Config:</td><td class="infoTableCell">${sickbeard.CONFIG_FILE}</td></tr> + <tr><td class="infoTableHeader">SR Database:</td><td class="infoTableCell">${db.dbFilename()}</td></tr> <tr><td class="infoTableHeader">SR Cache Dir:</td><td class="infoTableCell">${sickbeard.CACHE_DIR}</td></tr> <tr><td class="infoTableHeader">SR Log Dir:</td><td class="infoTableCell">${sickbeard.LOG_DIR}</td></tr> <tr><td class="infoTableHeader">SR Arguments:</td><td class="infoTableCell">${sickbeard.MY_ARGS}</td></tr> @@ -64,9 +64,10 @@ % endif <tr><td class="infoTableHeader">Python Version:</td><td class="infoTableCell">${sys.version[:120]}</td></tr> <tr class="infoTableSeperator"><td class="infoTableHeader"><i class="icon16-sb"></i> Homepage</td><td class="infoTableCell"><a href="${anon_url('http://www.sickrage.tv/')}" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false;">http://www.sickrage.tv/</a></td></tr> + <tr><td class="infoTableHeader"><i class="icon16-WiKi"></i> WiKi</td><td class="infoTableCell"><a href="${anon_url('https://github.com/SiCKRAGETV/sickrage-issues/wiki')}" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false;">https://github.com/SiCKRAGETV/sickrage-issues/wiki</a></td></tr> <tr><td class="infoTableHeader"><i class="icon16-web"></i> Forums</td><td class="infoTableCell"><a href="${anon_url('http://sickrage.tv/forums/')}" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false;">http://sickrage.tv/forums/</a></td></tr> <tr><td class="infoTableHeader"><i class="icon16-github"></i> Source</td><td class="infoTableCell"><a href="${anon_url('https://github.com/SiCKRAGETV/SickRage/')}" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false;">https://github.com/SiCKRAGETV/SickRage/</a></td></tr> - <tr><td class="infoTableHeader"><i class="icon16-mirc"></i> Internet Relay Chat</td><td class="infoTableCell"><a href="irc://irc.freenode.net/#sickrage" rel="noreferrer"><i>#sickrage</i> on <i>irc.freenode.net</i></a></td></tr> + <tr><td class="infoTableHeader"><i class="icon16-mirc"></i> IRChat</td><td class="infoTableCell"><a href="irc://irc.freenode.net/#sickrage" rel="noreferrer"><i>#sickrage</i> on <i>irc.freenode.net</i></a></td></tr> </table> </div> </%block> diff --git a/gui/slick/views/config_providers.mako b/gui/slick/views/config_providers.mako index f62699fa5a8e7b92ec6cdf6605ab387647aeb2e8..1078218c57e6d998341afd2cd4dde42b9d898532 100644 --- a/gui/slick/views/config_providers.mako +++ b/gui/slick/views/config_providers.mako @@ -79,7 +79,7 @@ $('#config-components').tabs(); curName = curProvider.getID() %> - <li class="ui-state-default" id="${curName}"> + <li class="ui-state-default ${('private', 'public')[bool(curProvider.public)]}" id="${curName}"> <input type="checkbox" id="enable_${curName}" class="provider_enabler" ${('', 'checked="checked"')[curProvider.isEnabled() == True]}/> <a href="${anon_url(curProvider.url)}" class="imgLink" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false;"><img src="${sbRoot}/images/providers/${curProvider.imageName()}" alt="${curProvider.name}" title="${curProvider.name}" width="16" height="16" style="vertical-align:middle;"/></a> <span style="vertical-align:middle;">${curProvider.name}</span> diff --git a/gui/slick/views/displayShow.mako b/gui/slick/views/displayShow.mako index 605e371adf13157854ef38dbab35267244212300..822ae454a7053d9efec5b295d0446058d172593b 100644 --- a/gui/slick/views/displayShow.mako +++ b/gui/slick/views/displayShow.mako @@ -123,7 +123,7 @@ $(document).ready(function(){ <select id="seasonJump" class="form-control input-sm" style="position: relative; top: -4px;"> <option value="jump">Jump to Season</option> % for seasonNum in seasonResults: - <option value="#season-${seasonNum["season"]}">${('Specials', 'Season ' + str(seasonNum["season"]))[int(seasonNum["season"]) == 0]}</option> + <option value="#season-${seasonNum["season"]}" data-season="${seasonNum["season"]}">${('Specials', 'Season ' + str(seasonNum["season"]))[int(seasonNum["season"]) > 0]}</option> % endfor </select> % else: diff --git a/lib/adba/aniDBAbstracter.py b/lib/adba/aniDBAbstracter.py index 64ebd851a2be10d076c1ced2599b306af557f3d5..eb6774e16fc00cb116f134c821c2167c8206ce92 100644 --- a/lib/adba/aniDBAbstracter.py +++ b/lib/adba/aniDBAbstracter.py @@ -17,15 +17,19 @@ from __future__ import with_statement +import os, re, string from time import time, sleep + import aniDBfileInfo as fileInfo -import xml.etree.cElementTree as etree -import os, re, string from aniDBmaper import AniDBMaper from aniDBtvDBmaper import TvDBMap from aniDBerrors import * from aniDBfileInfo import read_anidb_xml, read_tvdb_map_xml +try: + import xml.etree.cElementTree as etree +except ImportError: + import xml.etree.ElementTree as etree class aniDBabstractObject(object): def __init__(self, aniDB, load=False): @@ -97,7 +101,7 @@ class aniDBabstractObject(object): """ type - Type of notification: type=> 0=all, 1=new, 2=group, 3=complete priority - low = 0, medium = 1, high = 2 (unconfirmed) - + """ if self.aid: self.aniDB.notifyadd(aid=self.aid, type=1, priority=1) @@ -267,7 +271,7 @@ class Episode(aniDBabstractObject): 1 on hdd - the file is stored on hdd 2 on cd - the file is stored on cd 3 deleted - the file has been deleted or is not available for other reasons (i.e. reencoded) - + """ if self.filePath and not (self.ed2k or self.size): (self.ed2k, self.size) = self._calculate_file_stuff(self.filePath) @@ -288,4 +292,3 @@ class Episode(aniDBabstractObject): ed2k = fileInfo.get_file_hash(filePath) size = fileInfo.get_file_size(filePath) return (ed2k, size) - diff --git a/lib/adba/aniDBfileInfo.py b/lib/adba/aniDBfileInfo.py index fb7bd606bcb16a705f646fcc6eb9fda71fb2a3e7..c8cb246ae0682f99749826d0c9f6eefea7702636 100644 --- a/lib/adba/aniDBfileInfo.py +++ b/lib/adba/aniDBfileInfo.py @@ -19,9 +19,13 @@ from __future__ import with_statement import hashlib import os -import xml.etree.cElementTree as etree import time +try: + import xml.etree.cElementTree as etree +except ImportError: + import xml.etree.ElementTree as etree + # http://www.radicand.org/blog/orz/2010/2/21/edonkey2000-hash-in-python/ import requests diff --git a/lib/adba/aniDBtvDBmaper.py b/lib/adba/aniDBtvDBmaper.py index c3d01b4dc10a5e9b2f7340774c67a32cb01ffb1a..e3c964d2c9f27220dbf483a8cffa37146294539b 100644 --- a/lib/adba/aniDBtvDBmaper.py +++ b/lib/adba/aniDBtvDBmaper.py @@ -16,22 +16,27 @@ # along with aDBa. If not, see <http://www.gnu.org/licenses/>. import os -import xml.etree.cElementTree as etree + +try: + import xml.etree.cElementTree as etree +except ImportError: + import xml.etree.ElementTree as etree + import aniDBfileInfo as fileInfo class TvDBMap(): - + def __init__(self,filePath=None): self.xmlMap = fileInfo.read_tvdb_map_xml(filePath) - + def get_tvdb_for_anidb(self,anidb_id): return self._get_x_for_y(anidb_id,"anidbid","tvdbid") - + def get_anidb_for_tvdb(self,tvdb_id): return self._get_x_for_y(tvdb_id,"tvdbid","anidbid") - + def _get_x_for_y(self,xValue,x,y): #print("searching "+x+" with the value "+str(xValue)+" and want to give back "+y) @@ -43,23 +48,23 @@ class TvDBMap(): except ValueError, e: continue return 0 - - + + def get_season_episode_for_anidb_absoluteNumber(self,anidb_id,absoluteNumber): # NOTE: this cant be done without the length of each season from thetvdb #TODO: implement season = 0 episode = 0 - + for anime in self.xmlMap.findall("anime"): if int(anime.get("anidbid",False)) == anidb_id: defaultSeason = int(anime.get("defaulttvdbseason",1)) - - + + return (season,episode) - + def get_season_episode_for_tvdb_absoluteNumber(self,anidb_id,absoluteNumber): #TODO: implement season = 0 episode = 0 - return (season,episode) \ No newline at end of file + return (season,episode) diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index bb87c426e6f83299932f2973800582d7402b4acd..4603219bfa8880cd8b3b8b03539bd707ac3f28e7 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -60,7 +60,7 @@ from sickbeard.common import SD from sickbeard.common import SKIPPED from sickbeard.common import WANTED from sickbeard.databases import mainDB, cache_db, failed_db -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex from sickrage.system.Shutdown import Shutdown from configobj import ConfigObj @@ -664,7 +664,7 @@ def initialize(consoleLogging=True): gh = Github(user_agent="SiCKRAGE").get_organization(GIT_ORG).get_repo(GIT_REPO) except Exception as e: gh = None - logger.log('Unable to setup github properly, github will not be available. Error: {0}'.format(ex(e)),logger.WARNING) + logger.log('Unable to setup GitHub properly. GitHub will not be available. Error: %s' % ex(e), logger.WARNING) # git reset on update GIT_RESET = bool(check_setting_int(CFG, 'General', 'git_reset', 1)) diff --git a/sickbeard/common.py b/sickbeard/common.py index a43d162f3c48fd46deccc5fa22f68e79ad73c5dc..92703e7aa940a105c865ce9d0fcdfa1c0c90fc03 100644 --- a/sickbeard/common.py +++ b/sickbeard/common.py @@ -58,7 +58,7 @@ subtitleExtensions = ['srt', 'sub', 'ass', 'idx', 'ssa'] cpu_presets = {'HIGH': 5, 'NORMAL': 2, 'LOW': 1 -} + } ### Other constants MULTI_EP_RESULT = -1 @@ -107,7 +107,7 @@ multiEpStrings[NAMING_EXTEND] = "Extend" multiEpStrings[NAMING_LIMITED_EXTEND] = "Extend (Limited)" multiEpStrings[NAMING_LIMITED_EXTEND_E_PREFIXED] = "Extend (Limited, E-prefixed)" - +# pylint: disable=W0232,C1001 class Quality: NONE = 0 # 0 SDTV = 1 # 1 @@ -172,9 +172,9 @@ class Quality: :return: Human readable status value """ toReturn = {} - for x in Quality.qualityStrings.keys(): - toReturn[Quality.compositeStatus(status, x)] = Quality.statusPrefixes[status] + " (" + \ - Quality.qualityStrings[x] + ")" + for q in Quality.qualityStrings.keys(): + toReturn[Quality.compositeStatus(status, q)] = Quality.statusPrefixes[status] + " (" + \ + Quality.qualityStrings[q] + ")" return toReturn @staticmethod @@ -220,6 +220,7 @@ class Quality: return Quality.UNKNOWN + @staticmethod def sceneQuality(name, anime=False): """ @@ -229,61 +230,65 @@ class Quality: :param anime: Boolean to indicate if the show we're resolving is Anime :return: Quality prefix """ + + # pylint: disable=R0912 + + ret = Quality.UNKNOWN if not name: - return Quality.UNKNOWN + return ret name = os.path.basename(name) checkName = lambda list, func: func([re.search(x, name, re.I) for x in list]) if anime: - dvdOptions = checkName(["dvd", "dvdrip"], any) - blueRayOptions = checkName(["BD", "blue?-?ray"], any) - sdOptions = checkName(["360p", "480p", "848x480", "XviD"], any) - hdOptions = checkName(["720p", "1280x720", "960x720"], any) - fullHD = checkName(["1080p", "1920x1080"], any) + dvdOptions = checkName([r"dvd", r"dvdrip"], any) + blueRayOptions = checkName([r"BD", r"blue?-?ray"], any) + sdOptions = checkName([r"360p", r"480p", r"848x480", r"XviD"], any) + hdOptions = checkName([r"720p", r"1280x720", r"960x720"], any) + fullHD = checkName([r"1080p", r"1920x1080"], any) if sdOptions and not blueRayOptions and not dvdOptions: - return Quality.SDTV + ret = Quality.SDTV elif dvdOptions: - return Quality.SDDVD + ret = Quality.SDDVD elif hdOptions and not blueRayOptions and not fullHD: - return Quality.HDTV + ret = Quality.HDTV elif fullHD and not blueRayOptions and not hdOptions: - return Quality.FULLHDTV + ret = Quality.FULLHDTV elif hdOptions and not blueRayOptions and not fullHD: - return Quality.HDWEBDL + ret = Quality.HDWEBDL elif blueRayOptions and hdOptions and not fullHD: - return Quality.HDBLURAY + ret = Quality.HDBLURAY elif blueRayOptions and fullHD and not hdOptions: - return Quality.FULLHDBLURAY - else: - return Quality.UNKNOWN - - if checkName(["(pdtv|hdtv|dsr|tvrip).(xvid|x26[45]|h.?26[45])"], all) and not checkName(["(720|1080)[pi]"], all) and\ - not checkName(["hr.ws.pdtv.x26[45]"], any): - return Quality.SDTV - elif checkName(["web.dl|webrip", "xvid|x26[45]|h.?26[45]"], all) and not checkName(["(720|1080)[pi]"], all): - return Quality.SDTV - elif checkName(["(dvdrip|b[rd]rip|blue?-?ray)(.ws)?.(xvid|divx|x26[45])"], any) and not checkName(["(720|1080)[pi]"], all): - return Quality.SDDVD - elif checkName(["720p", "hdtv", "x26[45]"], all) or checkName(["hr.ws.pdtv.x26[45]"], any) and not checkName( - ["1080[pi]"], all): - return Quality.HDTV - elif checkName(["720p|1080i", "hdtv", "mpeg-?2"], all) or checkName(["1080[pi].hdtv", "h.?26[45]"], all): - return Quality.RAWHDTV - elif checkName(["1080p", "hdtv", "x26[45]"], all): - return Quality.FULLHDTV - elif checkName(["720p", "web.dl|webrip"], all) or checkName(["720p", "itunes", "h.?26[45]"], all): - return Quality.HDWEBDL - elif checkName(["1080p", "web.dl|webrip"], all) or checkName(["1080p", "itunes", "h.?26[45]"], all): - return Quality.FULLHDWEBDL - elif checkName(["720p", "blue?-?ray|hddvd|b[rd]rip", "x26[45]"], all): - return Quality.HDBLURAY - elif checkName(["1080p", "blue?-?ray|hddvd|b[rd]rip", "x26[45]"], all): - return Quality.FULLHDBLURAY - else: - return Quality.UNKNOWN + ret = Quality.FULLHDBLURAY + + return ret + + if checkName([r"(pdtv|hd.?tv|dsr|tvrip).(xvid|x26[45]|h.?26[45])"], all) and not checkName([r"(720|1080)[pi]"], all) and\ + not checkName([r"hr.ws.pdtv.x26[45]"], any): + ret = Quality.SDTV + elif checkName([r"web.dl|webrip", r"xvid|x26[45]|h.?26[45]"], all) and not checkName([r"(720|1080)[pi]"], all): + ret = Quality.SDTV + elif checkName([r"(dvdrip|b[rd]rip|blue?-?ray)(.ws)?.(xvid|divx|x26[45])"], any) and not checkName([r"(720|1080)[pi]"], all): + ret = Quality.SDDVD + elif checkName([r"720p", r"hd.?tv", r"x26[45]"], all) or checkName([r"hr.ws.pdtv.x26[45]"], any) and not checkName( + [r"1080[pi]"], all): + ret = Quality.HDTV + elif checkName([r"720p|1080i", r"hd.?tv", r"mpeg-?2"], all) or checkName([r"1080[pi].hdtv", r"h.?26[45]"], all): + ret = Quality.RAWHDTV + elif checkName([r"1080p", r"hd.?tv", r"x26[45]"], all): + ret = Quality.FULLHDTV + elif checkName([r"720p", r"web.?dl|webrip"], all) or checkName([r"720p", r"itunes", r"h.?26[45]"], all): + ret = Quality.HDWEBDL + elif checkName([r"1080p", r"web.?dl|webrip"], all) or checkName([r"1080p", r"itunes", r"h.?26[45]"], all): + ret = Quality.FULLHDWEBDL + elif checkName([r"720p", r"blue?-?ray|hddvd|b[rd]rip", r"x26[45]"], all): + ret = Quality.HDBLURAY + elif checkName([r"1080p", r"blue?-?ray|hddvd|b[rd]rip", r"x26[45]"], all): + ret = Quality.FULLHDBLURAY + + return ret @staticmethod def assumeQuality(name): @@ -310,11 +315,15 @@ class Quality: :param filename: Filename to analyse :return: Quality prefix """ + + # pylint: disable=R0912 + from hachoir_parser import createParser from hachoir_metadata import extractMetadata try: parser = createParser(filename) + # pylint: disable=W0703 except Exception: parser = None @@ -323,12 +332,15 @@ class Quality: try: metadata = extractMetadata(parser) + # pylint: disable=W0703 except Exception: metadata = None try: + # pylint: disable=W0212 parser.stream._input.close() - except: + # pylint: disable=W0703 + except Exception: pass if not metadata: @@ -347,14 +359,19 @@ class Quality: if not height: return Quality.UNKNOWN - if height > 1040: - return Quality.FULLHDTV - elif height > 680 and height < 760: - return Quality.HDTV + base_filename = os.path.basename(filename) + bluray = re.search(r'blue?-?ray', base_filename, re.I) is not None + webdl = re.search(r'web-?dl', base_filename, re.I) is not None + + ret = Quality.UNKNOWN + if height > 1000: + ret = ((Quality.FULLHDTV, Quality.FULLHDBLURAY)[bluray], Quality.FULLHDWEBDL)[webdl] + elif height > 680 and height < 800: + ret = ((Quality.HDTV, Quality.HDBLURAY)[bluray], Quality.HDWEBDL)[webdl] elif height < 680: - return Quality.SDTV + ret = (Quality.SDTV, Quality.SDDVD)[re.search(r'dvd', base_filename, re.I) is not None] - return Quality.UNKNOWN + return ret @staticmethod def compositeStatus(status, quality): @@ -370,9 +387,9 @@ class Quality: if status == UNKNOWN: return (UNKNOWN, Quality.UNKNOWN) - for x in sorted(Quality.qualityStrings.keys(), reverse=True): - if status > x * 100: - return (status - x * 100, x) + for q in sorted(Quality.qualityStrings.keys(), reverse=True): + if status > q * 100: + return (status - q * 100, q) return (status, Quality.NONE) @@ -426,6 +443,7 @@ qualityPresetStrings = {SD: "SD", ANY: "Any"} +# pylint: disable=R0903,C1001 class StatusStrings: def __init__(self): self.statusStrings = {UNKNOWN: "Unknown", @@ -458,7 +476,9 @@ class StatusStrings: statusStrings = StatusStrings() +# pylint: disable=R0903,C1001 class Overview: + UNAIRED = UNAIRED # 1 QUAL = 2 WANTED = WANTED # 3 @@ -475,6 +495,7 @@ class Overview: UNAIRED: "unaired", SNATCHED: "snatched"} + # Get our xml namespaces correct for lxml XML_NSMAP = {'xsi': 'http://www.w3.org/2001/XMLSchema-instance', 'xsd': 'http://www.w3.org/2001/XMLSchema'} @@ -482,4 +503,4 @@ XML_NSMAP = {'xsi': 'http://www.w3.org/2001/XMLSchema-instance', countryList = {'Australia': 'AU', 'Canada': 'CA', 'USA': 'US' -} + } diff --git a/sickbeard/dailysearcher.py b/sickbeard/dailysearcher.py index cf12e6f1e3d56d9df217564c5bf29f4647fc59c7..db774959516f560504ef73f4a4aac88f8ea7897a 100644 --- a/sickbeard/dailysearcher.py +++ b/sickbeard/dailysearcher.py @@ -27,8 +27,8 @@ from sickbeard import logger from sickbeard import db from sickbeard import common from sickbeard import helpers -from sickbeard import exceptions from sickbeard import network_timezones +from sickrage.helper.exceptions import MultipleShowObjectsException class DailySearcher(): @@ -75,7 +75,7 @@ class DailySearcher(): if not show or show.paused: continue - except exceptions.MultipleShowObjectsException: + except MultipleShowObjectsException: logger.log(u"ERROR: expected to find a single show matching " + str(sqlEp['showid'])) continue diff --git a/sickbeard/databases/mainDB.py b/sickbeard/databases/mainDB.py index abcd93602e82e7d07772e61cc5219fb21940ad2e..40012f5d5f0348abb1c91cfa0ea02d8c6f5b4d0d 100644 --- a/sickbeard/databases/mainDB.py +++ b/sickbeard/databases/mainDB.py @@ -973,7 +973,7 @@ class AddAnimeBlacklistWhitelist(AddSceneAbsoluteNumbering): self.incDBVersion() -class AddSceneAbsoluteNumbering(AddAnimeBlacklistWhitelist): +class AddSceneAbsoluteNumbering2(AddAnimeBlacklistWhitelist): def test(self): return self.checkDBVersion() >= 36 @@ -985,7 +985,7 @@ class AddSceneAbsoluteNumbering(AddAnimeBlacklistWhitelist): self.incDBVersion() -class AddXemRefresh(AddSceneAbsoluteNumbering): +class AddXemRefresh(AddSceneAbsoluteNumbering2): def test(self): return self.checkDBVersion() >= 37 diff --git a/sickbeard/db.py b/sickbeard/db.py index e1eb68c94346ef05abb7c201e0ac325aecc50e30..5fa1fdff9ad245ed4afd2a2d53dbc39b6fa9acd1 100644 --- a/sickbeard/db.py +++ b/sickbeard/db.py @@ -27,8 +27,8 @@ import threading import sickbeard from sickbeard import logger -from sickbeard.exceptions import ex from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex db_cons = {} db_locks = {} diff --git a/sickbeard/event_queue.py b/sickbeard/event_queue.py index 3b64097c7ba390f91bb2ce56d6b5175219ada33b..a2a56e93cedac640f64da6b4d7a2df35a1829b6e 100644 --- a/sickbeard/event_queue.py +++ b/sickbeard/event_queue.py @@ -2,7 +2,7 @@ import threading import traceback from Queue import Queue, Empty from sickbeard import logger -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex class Event: diff --git a/sickbeard/exceptions.py b/sickbeard/exceptions.py deleted file mode 100644 index 1ae11922a23ac36c6d2f50145b79967ea9d44572..0000000000000000000000000000000000000000 --- a/sickbeard/exceptions.py +++ /dev/null @@ -1,144 +0,0 @@ -# Author: Nic Wolfe <nic@wolfeden.ca> -# URL: https://sickrage.tv -# Git: https://github.com/SiCKRAGETV/SickRage.git -# -# This file is part of SickRage. -# -# SickRage is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SickRage is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SickRage. If not, see <http://www.gnu.org/licenses/>. - -from sickrage.helper.encoding import ss - - -def ex(e): - """ - Returns a unicode string from the exception text if it exists. - """ - - e_message = u"" - - if not e or not e.args: - return e_message - - for arg in e.args: - - if arg is not None: - if isinstance(arg, (str, unicode)): - fixed_arg = ss(arg) - else: - try: - fixed_arg = u"error " + ss(str(arg)) - except: - fixed_arg = None - - if fixed_arg: - if not e_message: - e_message = fixed_arg - else: - e_message = e_message + " : " + fixed_arg - - return e_message - - -class SickBeardException(Exception): - "Generic SickRage Exception - should never be thrown, only subclassed" - - -class ConfigErrorException(SickBeardException): - "Error in the config file" - - -class LaterException(SickBeardException): - "Something bad happened that I'll make a real exception for later" - - -class NoNFOException(SickBeardException): - "No NFO was found!" - - -class NoShowDirException(SickBeardException): - "Unable to find the show's directory" - - -class FileNotFoundException(SickBeardException): - "The specified file doesn't exist" - - -class MultipleDBEpisodesException(SickBeardException): - "Found multiple episodes in the DB! Must fix DB first" - - -class MultipleDBShowsException(SickBeardException): - "Found multiple shows in the DB! Must fix DB first" - - -class MultipleShowObjectsException(SickBeardException): - "Found multiple objects for the same show! Something is very wrong" - - -class WrongShowException(SickBeardException): - "The episode doesn't belong to the same show as its parent folder" - - -class ShowNotFoundException(SickBeardException): - "The show wasn't found on the Indexer" - - -class EpisodeNotFoundException(SickBeardException): - "The episode wasn't found on the Indexer" - - -class NewzbinAPIThrottled(SickBeardException): - "Newzbin has throttled us, deal with it" - - -class ShowDirNotFoundException(SickBeardException): - "The show dir doesn't exist" - - -class AuthException(SickBeardException): - "Your authentication information is incorrect" - - -class EpisodeDeletedException(SickBeardException): - "This episode has been deleted" - - -class CantRefreshException(SickBeardException): - "The show can't be refreshed right now" - - -class CantUpdateException(SickBeardException): - "The show can't be updated right now" - -class CantRemoveException(SickBeardException): - "The show can't be removed right now" - -class PostProcessingFailed(SickBeardException): - "Post-processing the episode failed" - - -class FailedProcessingFailed(SickBeardException): - "Post-processing the failed release failed" - - -class FailedHistoryMultiSnatchException(SickBeardException): - "Episode was snatched again before the first one was done" - - -class FailedHistoryNotFoundException(SickBeardException): - "The release was not found in the failed download history tracker" - - -class EpisodeNotFoundByAbsoluteNumberException(SickBeardException): - "The show wasn't found in the DB while looking at Absolute Numbers" diff --git a/sickbeard/failedProcessor.py b/sickbeard/failedProcessor.py index 155280a9c459947b8ce694f1254df7942df31b27..2d58cb23f83835e306b272efc55e1a399edffe4b 100644 --- a/sickbeard/failedProcessor.py +++ b/sickbeard/failedProcessor.py @@ -20,10 +20,10 @@ from __future__ import with_statement import sickbeard from sickbeard import logger -from sickbeard import exceptions from sickbeard import show_name_helpers from sickbeard import search_queue from sickbeard.name_parser.parser import NameParser, InvalidNameException, InvalidShowException +from sickrage.helper.exceptions import FailedPostProcessingFailedException class FailedProcessor(object): @@ -50,17 +50,17 @@ class FailedProcessor(object): releaseName = show_name_helpers.determineReleaseName(self.dir_name, self.nzb_name) if releaseName is None: self._log(u"Warning: unable to find a valid release name.", logger.WARNING) - raise exceptions.FailedProcessingFailed() + raise FailedPostProcessingFailedException() try: parser = NameParser(False) parsed = parser.parse(releaseName) except InvalidNameException: self._log(u"Error: release name is invalid: " + releaseName, logger.DEBUG) - raise exceptions.FailedProcessingFailed() + raise FailedPostProcessingFailedException() except InvalidShowException: self._log(u"Error: unable to parse release name " + releaseName + " into a valid show", logger.DEBUG) - raise exceptions.FailedProcessingFailed() + raise FailedPostProcessingFailedException() logger.log(u"name_parser info: ", logger.DEBUG) logger.log(u" - " + str(parsed.series_name), logger.DEBUG) diff --git a/sickbeard/failed_history.py b/sickbeard/failed_history.py index 14ef0c99cc96c2802ba35e31d8da0c2b7a153b0a..833d280031e76501d87200f332486ffd0de54c85 100644 --- a/sickbeard/failed_history.py +++ b/sickbeard/failed_history.py @@ -23,10 +23,10 @@ import datetime from sickbeard import db from sickbeard import logger -from sickbeard.exceptions import ex, EpisodeNotFoundException from sickbeard.common import Quality from sickbeard.common import WANTED, FAILED from sickrage.helper.encoding import ss +from sickrage.helper.exceptions import EpisodeNotFoundException, ex from sickrage.show.History import History diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index 6348d3ac8811a7a217338c2fff3039a241e36e35..bda130937bb78547eccac51412f683c24b60d497 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -63,7 +63,6 @@ try: except ImportError: gzip = None -from sickbeard.exceptions import MultipleShowObjectsException, ex from sickbeard import logger, classes from sickbeard.common import USER_AGENT from sickbeard.common import mediaExtensions @@ -73,6 +72,7 @@ from sickbeard import notifiers from sickbeard import clients from sickbeard.subtitles import isValidLanguage from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex, MultipleShowObjectsException from cachecontrol import CacheControl, caches from itertools import izip, cycle diff --git a/sickbeard/image_cache.py b/sickbeard/image_cache.py index 75eb4b40d659811c00cec8801de5bbee1bbab378..f891412066f2cb55f29d672b3228d8fb0734be8e 100644 --- a/sickbeard/image_cache.py +++ b/sickbeard/image_cache.py @@ -21,9 +21,10 @@ import os.path import sickbeard -from sickbeard import helpers, logger, exceptions +from sickbeard import helpers, logger from sickbeard.metadata.generic import GenericMetadata from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ShowDirectoryNotFoundException from hachoir_parser import createParser from hachoir_metadata import extractMetadata @@ -301,7 +302,7 @@ class ImageCache: cur_file_type), logger.DEBUG) self._cache_image_from_file(cur_file_name, cur_file_type, show_obj.indexerid) need_images[cur_file_type] = False - except exceptions.ShowDirNotFoundException: + except ShowDirectoryNotFoundException: logger.log(u"Unable to search for images in show dir because it doesn't exist", logger.WARNING) # download from indexer for missing ones diff --git a/sickbeard/imdbPopular.py b/sickbeard/imdbPopular.py index 6249ce5a4be6c6d0aaef99d39fe4affd90283a88..2ba08e938ffc0d769e673b695ac1e781c4994ab6 100644 --- a/sickbeard/imdbPopular.py +++ b/sickbeard/imdbPopular.py @@ -8,12 +8,20 @@ import sickbeard from sickbeard import helpers from sickrage.helper.encoding import ek - +# pylint: disable=C1001 class imdbPopular: def __init__(self): + """Gets a list of most popular TV series from imdb""" + + # Use akas.imdb.com, just like the imdb lib. + self.url = 'http://akas.imdb.com/search/title' - self.url = "http://www.imdb.com/search/title?at=0&sort=moviemeter&title_type=tv_series&year=%s,%s" % \ - (date.today().year - 1, date.today().year + 1) + self.params = { + 'at': 0, + 'sort': 'moviemeter', + 'title_type': 'tv_series', + 'year': '%s,%s' % (date.today().year - 1, date.today().year + 1) + } self.session = requests.Session() @@ -22,13 +30,13 @@ class imdbPopular: popular_shows = [] - data = helpers.getURL(self.url, session=self.session) + data = helpers.getURL(self.url, session=self.session, params=self.params, headers={'Referer': 'http://akas.imdb.com/'}) if not data: return None soup = BeautifulSoup(data, 'html.parser') results = soup.find("table", {"class": "results"}) - rows = results.find_all("tr"); + rows = results.find_all("tr") for row in rows: show = {} @@ -36,7 +44,7 @@ class imdbPopular: if image_td: image = image_td.find("img") - show['image_url_large'] = self.change_size(image['src'],3) + show['image_url_large'] = self.change_size(image['src'], 3) show['image_path'] = os.path.join('images', 'imdb_popular', os.path.basename(show['image_url_large'])) self.cache_image(show['image_url_large']) @@ -54,10 +62,14 @@ class imdbPopular: if rating_string: rating_string = rating_string['title'] - matches = re.search(".* (.*)\/10.*\((.*)\).*", rating_string).groups() - show['rating'] = matches[0] - show['votes'] = matches[1] - + match = re.search(r".* (.*)\/10.*\((.*)\).*", rating_string) + if match: + matches = match.groups() + show['rating'] = matches[0] + show['votes'] = matches[1] + else: + show['rating'] = None + show['votes'] = None else: show['rating'] = None show['votes'] = None @@ -67,7 +79,8 @@ class imdbPopular: return popular_shows - def change_size(self, image_url, factor=3): + @staticmethod + def change_size(image_url, factor=3): match = re.search("^(.*)V1._(.{2})(.*?)_(.{2})(.*?),(.*?),(.*?),(.*?)_.jpg$", image_url) if match: @@ -81,7 +94,7 @@ class imdbPopular: matches[7] = int(matches[7]) * factor return "%sV1._%s%s_%s%s,%s,%s,%s_.jpg" % (matches[0], matches[1], matches[2], matches[3], matches[4], - matches[5], matches[6], matches[7]) + matches[5], matches[6], matches[7]) else: return image_url diff --git a/sickbeard/logger.py b/sickbeard/logger.py index f2febe7c96f73d5bb870b78555b9470506415a30..33a59ba66b1a031dd232d967a4a89c26f3c0220b 100644 --- a/sickbeard/logger.py +++ b/sickbeard/logger.py @@ -16,6 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with SickRage. If not, see <http://www.gnu.org/licenses/>. +# pylint: disable=W0703 from __future__ import with_statement import os @@ -31,6 +32,7 @@ import sickbeard from sickbeard import classes from sickrage.helper.common import dateTimeFormat from sickrage.helper.encoding import ek, ss +from sickrage.helper.exceptions import ex from github import Github, InputFileContent import codecs @@ -64,11 +66,12 @@ class CensoredFormatter(logging.Formatter, object): def format(self, record): """Strips censored items from string""" msg = super(CensoredFormatter, self).format(record) + # pylint: disable=W0612 for k, v in censoredItems.iteritems(): if v and len(v) > 0 and v in msg: msg = msg.replace(v, len(v) * '*') # Needed because Newznab apikey isn't stored as key=value in a section. - msg = re.sub(r'([&?]r|[&?]apikey|[&?]api_key)=[^&]*([&\w]?)',r'\1=**********\2', msg) + msg = re.sub(r'([&?]r|[&?]apikey|[&?]api_key)=[^&]*([&\w]?)', r'\1=**********\2', msg) return msg @@ -130,8 +133,8 @@ class Logger(object): for logger in self.loggers: logger.addHandler(rfh) - def shutdown(self): - + @staticmethod + def shutdown(): logging.shutdown() def log(self, msg, level=INFO, *args, **kwargs): @@ -158,16 +161,17 @@ class Logger(object): sys.exit(1) def submit_errors(self): + # pylint: disable=R0912,R0914,R0915 if not (sickbeard.GIT_USERNAME and sickbeard.GIT_PASSWORD and sickbeard.DEBUG and len(classes.ErrorViewer.errors) > 0): self.log('Please set your GitHub username and password in the config and enable debug. Unable to submit issue ticket to GitHub!') return try: - from versionChecker import CheckVersion + from sickbeard.versionChecker import CheckVersion checkversion = CheckVersion() - needs_update = checkversion.check_for_new_version() + checkversion.check_for_new_version() commits_behind = checkversion.updater.get_num_commits_behind() - except: + except Exception: self.log('Could not check if your SickRage is updated, unable to submit issue ticket to GitHub!') return @@ -193,10 +197,10 @@ class Logger(object): with ek(codecs.open, *[self.logFile, 'r', 'utf-8']) as f: log_data = f.readlines() - for i in range (1 , int(sickbeard.LOG_NR)): + for i in range(1, int(sickbeard.LOG_NR)): if os.path.isfile(self.logFile + "." + str(i)) and (len(log_data) <= 500): with ek(codecs.open, *[self.logFile + "." + str(i), 'r', 'utf-8']) as f: - log_data += f.readlines() + log_data += f.readlines() log_data = [line for line in reversed(log_data)] @@ -205,17 +209,17 @@ class Logger(object): try: title_Error = str(curError.title) if not len(title_Error) or title_Error == 'None': - title_Error = re.match("^[A-Z0-9\-\[\] :]+::\s*(.*)$", ss(str(curError.message))).group(1) + title_Error = re.match(r"^[A-Z0-9\-\[\] :]+::\s*(.*)$", ss(str(curError.message))).group(1) # if len(title_Error) > (1024 - len(u"[APP SUBMITTED]: ")): # 1000 just looks better than 1007 and adds some buffer if len(title_Error) > 1000: title_Error = title_Error[0:1000] except Exception as e: - self.log("Unable to get error title : " + sickbeard.exceptions.ex(e), ERROR) + self.log("Unable to get error title : " + ex(e), ERROR) gist = None - regex = "^(%s)\s+([A-Z]+)\s+([0-9A-Z\-]+)\s*(.*)$" % curError.time + regex = r"^(%s)\s+([A-Z]+)\s+([0-9A-Z\-]+)\s*(.*)$" % curError.time for i, x in enumerate(log_data): x = ss(x) match = re.match(regex, x) @@ -230,12 +234,12 @@ class Logger(object): gist = 'No ERROR found' message = u"### INFO\n" - message += u"Python Version: **" + sys.version[:120].replace('\n','') + "**\n" + message += u"Python Version: **" + sys.version[:120].replace('\n', '') + "**\n" message += u"Operating System: **" + platform.platform() + "**\n" if not 'Windows' in platform.platform(): try: message += u"Locale: " + locale.getdefaultlocale()[1] + "\n" - except: + except Exception: message += u"Locale: unknown" + "\n" message += u"Branch: **" + sickbeard.BRANCH + "**\n" message += u"Commit: SiCKRAGETV/SickRage@" + sickbeard.CUR_COMMIT_HASH + "\n" @@ -260,7 +264,7 @@ class Logger(object): comment = report.create_comment(message) if comment: issue_id = report.number - self.log('Commented on existing issue #%s successfully!' % issue_id ) + self.log('Commented on existing issue #%s successfully!' % issue_id) issue_found = True break @@ -268,7 +272,7 @@ class Logger(object): issue = gh.get_organization(gh_org).get_repo(gh_repo).create_issue(title_Error, message) if issue: issue_id = issue.number - self.log('Your issue ticket #%s was submitted successfully!' % issue_id ) + self.log('Your issue ticket #%s was submitted successfully!' % issue_id) # clear error from error list classes.ErrorViewer.errors.remove(curError) @@ -276,10 +280,12 @@ class Logger(object): self.submitter_running = False return issue_id except Exception as e: - self.log(sickbeard.exceptions.ex(e), ERROR) + self.log(ex(e), ERROR) self.submitter_running = False + +# pylint: disable=R0903 class Wrapper(object): instance = Logger() diff --git a/sickbeard/metadata/generic.py b/sickbeard/metadata/generic.py index 33f59e93b91744e192b3a87a69264f4e9ae28c7d..e1787077b424e26fd53d8d33b4f7347ad941b172 100644 --- a/sickbeard/metadata/generic.py +++ b/sickbeard/metadata/generic.py @@ -19,19 +19,21 @@ from __future__ import with_statement import os.path - -import xml.etree.cElementTree as etree - import re +try: + import xml.etree.cElementTree as etree +except ImportError: + import xml.etree.ElementTree as etree + import sickbeard from sickbeard import helpers -from sickbeard.metadata import helpers as metadata_helpers from sickbeard import logger -from sickbeard.exceptions import ex +from sickbeard.metadata import helpers as metadata_helpers from sickbeard.show_name_helpers import allPossibleShowNames from sickrage.helper.encoding import ek, ss +from sickrage.helper.exceptions import ex from tmdb_api.tmdb_api import TMDB @@ -39,7 +41,7 @@ import fanart from fanart.core import Request as fanartRequest -class GenericMetadata(): +class GenericMetadata: """ Base class for all metadata providers. Default behavior is meant to mostly follow KODI 12+ metadata standards. Has support for: diff --git a/sickbeard/metadata/kodi_12plus.py b/sickbeard/metadata/kodi_12plus.py index 17f8bb1edd9f8ccfdc5f411eb371fd80831f2da8..ca6787127c66d8303d3a1365263c3814c729f361 100644 --- a/sickbeard/metadata/kodi_12plus.py +++ b/sickbeard/metadata/kodi_12plus.py @@ -20,11 +20,14 @@ import datetime import sickbeard -from sickbeard import logger, exceptions, helpers -from sickbeard.exceptions import ex +from sickbeard import logger, helpers from sickrage.helper.common import dateFormat +from sickrage.helper.exceptions import ex, ShowNotFoundException -import xml.etree.cElementTree as etree +try: + import xml.etree.cElementTree as etree +except ImportError: + import xml.etree.ElementTree as etree class KODI_12PlusMetadata(generic.GenericMetadata): @@ -226,7 +229,7 @@ class KODI_12PlusMetadata(generic.GenericMetadata): t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS) myShow = t[ep_obj.show.indexerid] except sickbeard.indexer_shownotfound, e: - raise exceptions.ShowNotFoundException(e.message) + raise ShowNotFoundException(e.message) except sickbeard.indexer_error, e: logger.log(u"Unable to connect to " + sickbeard.indexerApi( ep_obj.show.indexer).name + " while creating meta files - skipping - " + ex(e), logger.ERROR) diff --git a/sickbeard/metadata/mede8er.py b/sickbeard/metadata/mede8er.py index c352ab48e1a2dcc9a5a6cce305e18d0635b1c3d3..93304b4a80f2b64e0009c15a8ed40bf32ca1dc24 100644 --- a/sickbeard/metadata/mede8er.py +++ b/sickbeard/metadata/mede8er.py @@ -23,15 +23,15 @@ import sickbeard import mediabrowser -from sickbeard import logger, exceptions, helpers -from sickbeard.exceptions import ex +from sickbeard import logger, helpers from sickrage.helper.common import dateFormat from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex, ShowNotFoundException try: import xml.etree.cElementTree as etree except ImportError: - import elementtree.ElementTree as etree + import xml.etree.ElementTree as etree class Mede8erMetadata(mediabrowser.MediaBrowserMetadata): @@ -239,7 +239,7 @@ class Mede8erMetadata(mediabrowser.MediaBrowserMetadata): t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS) myShow = t[ep_obj.show.indexerid] except sickbeard.indexer_shownotfound, e: - raise exceptions.ShowNotFoundException(e.message) + raise ShowNotFoundException(e.message) except sickbeard.indexer_error, e: logger.log(u"Unable to connect to TVDB while creating meta files - skipping - " + ex(e), logger.ERROR) return False diff --git a/sickbeard/metadata/mediabrowser.py b/sickbeard/metadata/mediabrowser.py index e9bffeade0a403f505c76c2c092b4bdeaae02c1d..85fcb79d959e9b0db00af87495483140a679ba84 100644 --- a/sickbeard/metadata/mediabrowser.py +++ b/sickbeard/metadata/mediabrowser.py @@ -24,12 +24,16 @@ import sickbeard import generic -from sickbeard import logger, exceptions, helpers -from sickbeard.exceptions import ex +from sickbeard import logger, helpers + from sickrage.helper.common import dateFormat from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex, ShowNotFoundException -import xml.etree.cElementTree as etree +try: + import xml.etree.cElementTree as etree +except ImportError: + import xml.etree.ElementTree as etree class MediaBrowserMetadata(generic.GenericMetadata): @@ -409,7 +413,7 @@ class MediaBrowserMetadata(generic.GenericMetadata): myShow = t[ep_obj.show.indexerid] except sickbeard.indexer_shownotfound, e: - raise exceptions.ShowNotFoundException(e.message) + raise ShowNotFoundException(e.message) except sickbeard.indexer_error, e: logger.log(u"Unable to connect to " + sickbeard.indexerApi( ep_obj.show.indexer).name + " while creating meta files - skipping - " + ex(e), logger.ERROR) diff --git a/sickbeard/metadata/tivo.py b/sickbeard/metadata/tivo.py index 0d2b53828b3fad605d3c6c2e837ac2fdf7cfb389..02b02b6ade6f94de3cb3bf5dcdb4a68288f6c4b0 100644 --- a/sickbeard/metadata/tivo.py +++ b/sickbeard/metadata/tivo.py @@ -24,10 +24,10 @@ import os import sickbeard -from sickbeard import logger, exceptions, helpers +from sickbeard import logger, helpers from sickbeard.metadata import generic -from sickbeard.exceptions import ex from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex, ShowNotFoundException class TIVOMetadata(generic.GenericMetadata): @@ -182,7 +182,7 @@ class TIVOMetadata(generic.GenericMetadata): t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS) myShow = t[ep_obj.show.indexerid] except sickbeard.indexer_shownotfound, e: - raise exceptions.ShowNotFoundException(str(e)) + raise ShowNotFoundException(str(e)) except sickbeard.indexer_error, e: logger.log(u"Unable to connect to " + sickbeard.indexerApi( ep_obj.show.indexer).name + " while creating meta files - skipping - " + str(e), logger.ERROR) diff --git a/sickbeard/metadata/wdtv.py b/sickbeard/metadata/wdtv.py index 530340ac45fc60cd42ed886ef0160125a75b4dc5..66e28b55c4e539add11497dd088dde329db7081b 100644 --- a/sickbeard/metadata/wdtv.py +++ b/sickbeard/metadata/wdtv.py @@ -24,12 +24,15 @@ import sickbeard import generic -from sickbeard import logger, exceptions, helpers -from sickbeard.exceptions import ex +from sickbeard import logger, helpers from sickrage.helper.common import dateFormat from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex, ShowNotFoundException -import xml.etree.cElementTree as etree +try: + import xml.etree.cElementTree as etree +except ImportError: + import xml.etree.ElementTree as etree class WDTVMetadata(generic.GenericMetadata): @@ -193,7 +196,7 @@ class WDTVMetadata(generic.GenericMetadata): t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS) myShow = t[ep_obj.show.indexerid] except sickbeard.indexer_shownotfound, e: - raise exceptions.ShowNotFoundException(e.message) + raise ShowNotFoundException(e.message) except sickbeard.indexer_error, e: logger.log(u"Unable to connect to " + sickbeard.indexerApi( ep_obj.show.indexer).name + " while creating meta files - skipping - " + ex(e), logger.ERROR) diff --git a/sickbeard/name_parser/parser.py b/sickbeard/name_parser/parser.py index 512aa2a221fda5028ba74f0da0c749e814e6b05e..2bf5d22f78737161f23976dc7c2eed894e8e4372 100644 --- a/sickbeard/name_parser/parser.py +++ b/sickbeard/name_parser/parser.py @@ -26,8 +26,8 @@ import regexes import sickbeard from sickbeard import logger, helpers, scene_numbering, common, scene_exceptions, db -from sickbeard.exceptions import ex from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex from dateutil import parser @@ -51,7 +51,8 @@ class NameParser(object): else: self._compile_regexes(self.ALL_REGEX) - def clean_series_name(self, series_name): + @staticmethod + def clean_series_name(series_name): """Cleans up series name by removing any . and _ characters, along with any trailing hyphens. @@ -66,13 +67,13 @@ class NameParser(object): Stolen from dbr's tvnamer """ - series_name = re.sub("(\D)\.(?!\s)(\D)", "\\1 \\2", series_name) - series_name = re.sub("(\d)\.(\d{4})", "\\1 \\2", series_name) # if it ends in a year then don't keep the dot - series_name = re.sub("(\D)\.(?!\s)", "\\1 ", series_name) - series_name = re.sub("\.(?!\s)(\D)", " \\1", series_name) + series_name = re.sub(r"(\D)\.(?!\s)(\D)", "\\1 \\2", series_name) + series_name = re.sub(r"(\d)\.(\d{4})", "\\1 \\2", series_name) # if it ends in a year then don't keep the dot + series_name = re.sub(r"(\D)\.(?!\s)", "\\1 ", series_name) + series_name = re.sub(r"\.(?!\s)(\D)", " \\1", series_name) series_name = series_name.replace("_", " ") - series_name = re.sub("-$", "", series_name) - series_name = re.sub("^\[.*\]", "", series_name) + series_name = re.sub(r"-$", "", series_name) + series_name = re.sub(r"^\[.*\]", "", series_name) return series_name.strip() def _compile_regexes(self, regexMode): @@ -155,7 +156,7 @@ class NameParser(object): try: result.air_date = parser.parse(air_date, fuzzy=True).date() result.score += 1 - except: + except Exception: continue if 'extra_info' in named_groups: @@ -346,19 +347,21 @@ class NameParser(object): b = getattr(second, attr) # if a is good use it - if a != None or (type(a) == list and len(a)): + if a != None or (isinstance(a, list) and a): return a # if not use b (if b isn't set it'll just be default) else: return b - def _unicodify(self, obj, encoding="utf-8"): + @staticmethod + def _unicodify(obj, encoding="utf-8"): if isinstance(obj, basestring): if not isinstance(obj, unicode): obj = unicode(obj, encoding, 'replace') return obj - def _convert_number(self, org_number): + @staticmethod + def _convert_number(org_number): """ Convert org_number into an integer org_number: integer or representation of a number: string or unicode @@ -373,11 +376,12 @@ class NameParser(object): else: number = 0 - except: + except Exception: # on error try converting from Roman numerals - roman_to_int_map = (('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), - ('XC', 90), ('L', 50), ('XL', 40), ('X', 10), - ('IX', 9), ('V', 5), ('IV', 4), ('I', 1) + roman_to_int_map = ( + ('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), + ('XC', 90), ('L', 50), ('XL', 40), ('X', 10), + ('IX', 9), ('V', 5), ('IV', 4), ('I', 1) ) roman_numeral = str(org_number).upper() @@ -480,7 +484,7 @@ class ParseResult(object): score=None, quality=None, version=None - ): + ): self.original_name = original_name @@ -587,10 +591,8 @@ class NameParserCache(object): def add(self, name, parse_result): self._previous_parsed[name] = parse_result - _current_cache_size = len(self._previous_parsed) - if _current_cache_size > self._cache_size: - for i in range(_current_cache_size - self._cache_size): - del self._previous_parsed[self._previous_parsed.keys()[0]] + while len(self._previous_parsed) > self._cache_size: + del self._previous_parsed[self._previous_parsed.keys()[0]] def get(self, name): if name in self._previous_parsed: diff --git a/sickbeard/name_parser/regexes.py b/sickbeard/name_parser/regexes.py index e43efb7ee90872996dc57d3480ae6cd62864e246..eaea3e20da6c3b8e3e6cadbf56e6761decde96d1 100644 --- a/sickbeard/name_parser/regexes.py +++ b/sickbeard/name_parser/regexes.py @@ -22,7 +22,7 @@ normal_regexes = [ ('standard_repeat', # Show.Name.S01E02.S01E03.Source.Quality.Etc-Group # Show Name - S01E02 - S01E03 - S01E04 - Ep Name - ''' + r''' ^(?P<series_name>.+?)[. _-]+ # Show_Name and separator s(?P<season_num>\d+)[. _-]* # S01 and optional separator e(?P<ep_num>\d+) # E02 and separator @@ -36,7 +36,7 @@ normal_regexes = [ ('fov_repeat', # Show.Name.1x02.1x03.Source.Quality.Etc-Group # Show Name - 1x02 - 1x03 - 1x04 - Ep Name - ''' + r''' ^(?P<series_name>.+?)[. _-]+ # Show_Name and separator (?P<season_num>\d+)x # 1x (?P<ep_num>\d+) # 02 and separator @@ -54,7 +54,7 @@ normal_regexes = [ # Show.Name.S01E02E03.Source.Quality.Etc-Group # Show Name - S01E02-03 - My Ep Name # Show.Name.S01.E02.E03 - ''' + r''' ^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator (\()?s(?P<season_num>\d+)[. _-]* # S01 and optional separator e(?P<ep_num>\d+)(\))? # E02 and separator @@ -70,7 +70,7 @@ normal_regexes = [ # Show Name - 1x02 - My Ep Name # Show_Name.1x02x03x04.Source_Quality_Etc-Group # Show Name - 1x02-03-04 - My Ep Name - ''' + r''' ^((?P<series_name>.+?)[\[. _-]+)? # Show_Name and separator (?P<season_num>\d+)x # 1x (?P<ep_num>\d+) # 02 and separator @@ -86,7 +86,7 @@ normal_regexes = [ ('scene_date_format', # Show.Name.2010.11.23.Source.Quality.Etc-Group # Show Name - 2010-11-23 - Ep Name - ''' + r''' ^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator (?P<air_date>(\d+[. _-]\d+[. _-]\d+)|(\d+\w+[. _-]\w+[. _-]\d+)) [. _-]*((?P<extra_info>.+?) # Source_Quality_Etc- @@ -98,7 +98,7 @@ normal_regexes = [ # Show.Name.100.Event.2010.11.23.Source.Quality.Etc-Group # Show.Name.2010.11.23.Source.Quality.Etc-Group # Show Name - 2010-11-23 - Ep Name - ''' + r''' ^(?P<series_name>.*?(UEFA|MLB|ESPN|WWE|MMA|UFC|TNA|EPL|NASCAR|NBA|NFL|NHL|NRL|PGA|SUPER LEAGUE|FORMULA|FIFA|NETBALL|MOTOGP).*?)[. _-]+ ((?P<series_num>\d{1,3})[. _-]+)? (?P<air_date>(\d+[. _-]\d+[. _-]\d+)|(\d+\w+[. _-]\w+[. _-]\d+))[. _-]+ @@ -108,7 +108,7 @@ normal_regexes = [ ('stupid', # tpz-abc102 - ''' + r''' (?P<release_group>.+?)-\w+?[\. ]? # tpz-abc (?!264) # don't count x264 (?P<season_num>\d{1,2}) # 1 @@ -117,7 +117,7 @@ normal_regexes = [ ('verbose', # Show Name Season 1 Episode 2 Ep Name - ''' + r''' ^(?P<series_name>.+?)[. _-]+ # Show Name and separator season[. _-]+ # season and separator (?P<season_num>\d+)[. _-]+ # 1 @@ -128,7 +128,7 @@ normal_regexes = [ ('season_only', # Show.Name.S01.Source.Quality.Etc-Group - ''' + r''' ^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator s(eason[. _-])? # S01/Season 01 (?P<season_num>\d+)[. _-]* # S01 and optional separator @@ -141,7 +141,7 @@ normal_regexes = [ ('no_season_multi_ep', # Show.Name.E02-03 # Show.Name.E02.2010 - ''' + r''' ^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator (e(p(isode)?)?|part|pt)[. _-]? # e, ep, episode, or part (?P<ep_num>(\d+|[ivx]+)) # first ep num @@ -157,7 +157,7 @@ normal_regexes = [ # Show.Name.E23.Test # Show.Name.Part.3.Source.Quality.Etc-Group # Show.Name.Part.1.and.Part.2.Blah-Group - ''' + r''' ^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator (e(p(isode)?)?|part|pt)[. _-]? # e, ep, episode, or part (?P<ep_num>(\d+|([ivx]+(?=[. _-])))) # first ep num @@ -175,7 +175,7 @@ normal_regexes = [ # Show Name - 01 - Ep Name # 01 - Ep Name # 01 - Ep Name - ''' + r''' ^((?P<series_name>.+?)(?:[. _-]{2,}|[. _]))? # Show_Name and separator (?P<ep_num>\d{1,3}) # 02 (?:-(?P<extra_ep_num>\d{1,3}))* # -03-04-05 etc @@ -188,7 +188,7 @@ normal_regexes = [ ('bare', # Show.Name.102.Source.Quality.Etc-Group - ''' + r''' ^(?P<series_name>.+?)[. _-]+ # Show_Name and separator (?P<season_num>\d{1,2}) # 1 (?P<ep_num>\d{2}) # 02 and separator @@ -200,7 +200,7 @@ normal_regexes = [ anime_regexes = [ ('anime_horriblesubs', # [HorribleSubs] Maria the Virgin Witch - 01 [720p].mkv - ''' + r''' ^(?:\[(?P<release_group>HorribleSubs)\][\s\.]) (?:(?P<series_name>.+?)[\s\.]-[\s\.]) (?P<ep_ab_num>((?!(1080|720|480)[pi]))\d{1,3}) @@ -211,7 +211,7 @@ anime_regexes = [ .*? '''), ('anime_ultimate', - """ + r''' ^(?:\[(?P<release_group>.+?)\][ ._-]*) (?P<series_name>.+?)[ ._-]+ (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) @@ -221,12 +221,12 @@ anime_regexes = [ (?:(?:(?:[\[\(])(?P<extra_info>\d{3,4}[xp]?\d{0,4}[\.\w\s-]*)(?:[\]\)]))|(?:\d{3,4}[xp])) (?:[ ._]?\[(?P<crc>\w+)\])? .*? - """), + '''), ('anime_ISLAND', # [ISLAND]One_Piece_679_[VOSTFR]_[V1]_[8bit]_[720p]_[EB7838FC].mp4 # [ISLAND]One_Piece_679_[VOSTFR]_[8bit]_[720p]_[EB7838FC].mp4 - ''' + r''' ^\[(?P<release_group>ISLAND?)\] # Release Group (?P<series_name>.+?)[ ._-]+ # Show_Name and separator (?P<ep_ab_num>\d{1,3})[ ._-]+ # Episode number @@ -243,7 +243,7 @@ anime_regexes = [ # [Kaerizaki-Fansub]_One_Piece_681_[VOSTFR][HD_1280x720]_V2.mp4 # [Kaerizaki-Fansub] High School DxD New 04 VOSTFR HD (1280x720) V2.mp4 # [Kaerizaki-Fansub] One Piece 603 VOSTFR PS VITA (960x544) V2.mp4 - ''' + r''' ^\[(?P<release_group>Kaerizaki-Fansub?)\][ ._-]* # Release Group and separator (?P<series_name>.+?)[ ._-]+ # Show_Name and separator (?P<ep_ab_num>((?!\[VOSTFR|VOSTFR))\d{1,3}) # Episode number @@ -261,7 +261,7 @@ anime_regexes = [ # [Group Name] Show Name.13 # [Group Name] Show Name - 13 # Show Name 13 - ''' + r''' ^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator (?P<series_name>.+?)[ ._-]+ # Show_Name and separator (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) # E01 @@ -273,10 +273,9 @@ anime_regexes = [ '''), ('anime_standard_round', - # TODO examples # [Stratos-Subs]_Infinite_Stratos_-_12_(1280x720_H.264_AAC)_[379759DB] # [ShinBunBu-Subs] Bleach - 02-03 (CX 1280x720 x264 AAC) - ''' + r''' ^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator (?P<series_name>.+?)[ ._-]+ # Show_Name and separator (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) # E01 @@ -289,7 +288,7 @@ anime_regexes = [ ('anime_slash', # [SGKK] Bleach 312v1 [720p/MKV] - ''' + r''' ^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator (?P<series_name>.+?)[ ._-]+ # Show_Name and separator (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) # E01 @@ -304,7 +303,7 @@ anime_regexes = [ # [Ayako]_Infinite_Stratos_-_IS_-_07_[H264][720p][EB7838FC] # [Ayako] Infinite Stratos - IS - 07v2 [H264][720p][44419534] # [Ayako-Shikkaku] Oniichan no Koto Nanka Zenzen Suki Janain Dakara ne - 10 [LQ][h264][720p] [8853B21C] - ''' + r''' ^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator (?P<series_name>.+?)[ ._]* # Show_Name and separator ([ ._-]+-[ ._-]+[A-Z]+[ ._-]+)?[ ._-]+ # funny stuff, this is sooo nuts ! this will kick me in the butt one day @@ -318,7 +317,7 @@ anime_regexes = [ '''), ('anime_codec_crc', - ''' + r''' ^(?:\[(?P<release_group>.*?)\][ ._-]*)? (?:(?P<series_name>.*?)[ ._-]*)? (?:(?P<ep_ab_num>(((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))[ ._-]*).+? @@ -331,7 +330,7 @@ anime_regexes = [ # Bleach - s16e03-04 - 313-314 # Bleach.s16e03-04.313-314 # Bleach s16e03e04 313-314 - ''' + r''' ^(?P<series_name>.+?)[ ._-]+ # start of string and series name and non optinal separator [sS](?P<season_num>\d+)[. _-]* # S01 and optional separator [eE](?P<ep_num>\d+) # epipisode E02 @@ -350,7 +349,7 @@ anime_regexes = [ # Bleach - s16e03-04 - 313-314 # Bleach.s16e03-04.313-314 # Bleach s16e03e04 313-314 - ''' + r''' ^(?P<series_name>.+?)[ ._-]+ # start of string and series name and non optinal separator (?P<season_num>\d+)[. _-]* # S01 and optional separator [xX](?P<ep_num>\d+) # epipisode E02 @@ -367,7 +366,7 @@ anime_regexes = [ ('anime_and_normal_reverse', # Bleach - 313-314 - s16e03-04 - ''' + r''' ^(?P<series_name>.+?)[ ._-]+ # start of string and series name and non optinal separator (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) # absolute number (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # "-" as separator and anditional absolute number, all optinal @@ -383,7 +382,7 @@ anime_regexes = [ ('anime_and_normal_front', # 165.Naruto Shippuuden.s08e014 - ''' + r''' ^(?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) # start of string and absolute number (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # "-" as separator and anditional absolute number, all optinal (v(?P<version>[0-9]))?[ ._-]+ # the version e.g. "v2" @@ -397,7 +396,7 @@ anime_regexes = [ ), ('anime_ep_name', - ''' + r''' ^(?:\[(?P<release_group>.+?)\][ ._-]*) (?P<series_name>.+?)[ ._-]+ (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) @@ -413,14 +412,14 @@ anime_regexes = [ ('anime_WarB3asT', # 003. Show Name - Ep Name.ext # 003-004. Show Name - Ep Name.ext - ''' + r''' ^(?P<ep_ab_num>\d{3,4})(-(?P<extra_ab_ep_num>\d{3,4}))?\.\s+(?P<series_name>.+?)\s-\s.* '''), ('anime_bare', # One Piece - 102 # [ACX]_Wolf's_Spirit_001.mkv - ''' + r''' ^(\[(?P<release_group>.+?)\][ ._-]*)? (?P<series_name>.+?)[ ._-]+ # Show_Name and separator (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) # E01 diff --git a/sickbeard/notifiers/boxcar.py b/sickbeard/notifiers/boxcar.py index 9bff9bf834a2b277c17078a2f95efdb10f7e6247..40be70aa9110f096fe9ba28b0adf409587243690 100644 --- a/sickbeard/notifiers/boxcar.py +++ b/sickbeard/notifiers/boxcar.py @@ -24,7 +24,7 @@ import sickbeard from sickbeard import logger from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD, NOTIFY_GIT_UPDATE, NOTIFY_GIT_UPDATE_TEXT -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex API_URL = "https://boxcar.io/devices/providers/fWc4sgSmpcN6JujtBmR6/notifications" @@ -36,12 +36,12 @@ class BoxcarNotifier: def _sendBoxcar(self, msg, title, email, subscribe=False): """ Sends a boxcar notification to the address provided - + msg: The message to send (unicode) title: The title of the message email: The email address to send the message to (or to subscribe with) subscribe: If true then instead of sending a message this function will send a subscription notification (optional, default is False) - + returns: True if the message succeeded, False otherwise """ @@ -122,7 +122,7 @@ class BoxcarNotifier: def notify_subtitle_download(self, ep_name, lang, title=notifyStrings[NOTIFY_SUBTITLE_DOWNLOAD]): if sickbeard.BOXCAR_NOTIFY_ONSUBTITLEDOWNLOAD: self._notifyBoxcar(title, ep_name + ": " + lang) - + def notify_git_update(self, new_version = "??"): if sickbeard.USE_BOXCAR: update_text=notifyStrings[NOTIFY_GIT_UPDATE_TEXT] diff --git a/sickbeard/notifiers/boxcar2.py b/sickbeard/notifiers/boxcar2.py index bcd5f6083d290c2c16120fa6133146036e7908e8..b6e9f468071b045e18e892ba8b8b0219dd36f960 100644 --- a/sickbeard/notifiers/boxcar2.py +++ b/sickbeard/notifiers/boxcar2.py @@ -24,7 +24,7 @@ import sickbeard from sickbeard import logger from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD, NOTIFY_GIT_UPDATE, NOTIFY_GIT_UPDATE_TEXT -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex API_URL = "https://new.boxcar.io/api/notifications" @@ -36,11 +36,11 @@ class Boxcar2Notifier: def _sendBoxcar2(self, msg, title, accesstoken): """ Sends a boxcar2 notification to the address provided - + msg: The message to send title: The title of the message - accesstoken: to send to this device - + accesstoken: to send to this device + returns: True if the message succeeded, False otherwise """ @@ -95,7 +95,7 @@ class Boxcar2Notifier: def notify_subtitle_download(self, ep_name, lang, title=notifyStrings[NOTIFY_SUBTITLE_DOWNLOAD]): if sickbeard.BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD: self._notifyBoxcar2(title, ep_name + ": " + lang) - + def notify_git_update(self, new_version = "??"): if sickbeard.USE_BOXCAR2: update_text=notifyStrings[NOTIFY_GIT_UPDATE_TEXT] @@ -108,7 +108,7 @@ class Boxcar2Notifier: title: The title of the notification to send message: The message string to send - accesstoken: to send to this device + accesstoken: to send to this device """ if not sickbeard.USE_BOXCAR2: diff --git a/sickbeard/notifiers/emby.py b/sickbeard/notifiers/emby.py index 238be4b0fc7926b4ec0ead9e6c1314fed6aa2c08..9ceef6bd74595e551d9badb7f026f1bc2592495b 100644 --- a/sickbeard/notifiers/emby.py +++ b/sickbeard/notifiers/emby.py @@ -22,14 +22,14 @@ import urllib2 import sickbeard from sickbeard import logger -from sickbeard.exceptions import ex - +from sickrage.helper.exceptions import ex try: import json except ImportError: import simplejson as json + class EMBYNotifier: def _notify_emby(self, message, host=None, emby_apikey=None): diff --git a/sickbeard/notifiers/growl.py b/sickbeard/notifiers/growl.py index ad9d22c84ec3b033abaf94b3eee26c2742ccfc6a..7b7d111dba8ba88a17cfbf6d20be2db86b41a4e1 100644 --- a/sickbeard/notifiers/growl.py +++ b/sickbeard/notifiers/growl.py @@ -20,9 +20,10 @@ import socket import sickbeard from sickbeard import logger, common -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex from libgrowl import gntp + class GrowlNotifier: sr_logo_url = 'https://raw.githubusercontent.com/SiCKRAGETV/SickRage/master/gui/slick/images/sickrage-shark-mascot.png' @@ -42,7 +43,7 @@ class GrowlNotifier: def notify_subtitle_download(self, ep_name, lang): if sickbeard.GROWL_NOTIFY_ONSUBTITLEDOWNLOAD: self._sendGrowl(common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD], ep_name + ": " + lang) - + def notify_git_update(self, new_version = "??"): if sickbeard.USE_GROWL: update_text=common.notifyStrings[common.NOTIFY_GIT_UPDATE_TEXT] @@ -177,7 +178,7 @@ class GrowlNotifier: register.add_notification(common.notifyStrings[common.NOTIFY_SNATCH], True) register.add_notification(common.notifyStrings[common.NOTIFY_DOWNLOAD], True) register.add_notification(common.notifyStrings[common.NOTIFY_GIT_UPDATE], True) - + if opts['password']: register.set_password(opts['password']) diff --git a/sickbeard/notifiers/kodi.py b/sickbeard/notifiers/kodi.py index 8c0720768ef67b3f65a4e2322d88e2e3f4539ad9..124804af2530c3b48c6cd81c10df1423890a8c00 100644 --- a/sickbeard/notifiers/kodi.py +++ b/sickbeard/notifiers/kodi.py @@ -26,7 +26,7 @@ import time import sickbeard from sickbeard import logger from sickbeard import common -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex from sickrage.helper.encoding import ss try: diff --git a/sickbeard/notifiers/nmj.py b/sickbeard/notifiers/nmj.py index 934fba4acd8416a9996990eb16243cba02f8b8b4..e86b81be0724119803ef681ec165ea9266157707 100644 --- a/sickbeard/notifiers/nmj.py +++ b/sickbeard/notifiers/nmj.py @@ -22,7 +22,7 @@ import telnetlib import re from sickbeard import logger -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex try: import xml.etree.cElementTree as etree @@ -34,9 +34,9 @@ class NMJNotifier: def notify_settings(self, host): """ Retrieves the settings from a NMJ/Popcorn hour - + host: The hostname/IP of the Popcorn Hour server - + Returns: True if the settings were retrieved successfully, False otherwise """ @@ -96,7 +96,7 @@ class NMJNotifier: def notify_subtitle_download(self, ep_name, lang): if sickbeard.USE_NMJ: self._notifyNMJ() - + def notify_git_update(self, new_version): return False # Not implemented, no reason to start scanner. @@ -107,11 +107,11 @@ class NMJNotifier: def _sendNMJ(self, host, database, mount=None): """ Sends a NMJ update command to the specified machine - + host: The hostname/IP to send the request to (no port) database: The database to send the requst to mount: The mount URL to use (optional) - + Returns: True if the request succeeded, False otherwise """ @@ -177,7 +177,7 @@ class NMJNotifier: def _notifyNMJ(self, host=None, database=None, mount=None, force=False): """ Sends a NMJ update command based on the SB config settings - + host: The host to send the command to (optional, defaults to the host in the config) database: The database to use (optional, defaults to the database in the config) mount: The mount URL (optional, defaults to the mount URL in the config) diff --git a/sickbeard/notifiers/plex.py b/sickbeard/notifiers/plex.py index d728f6daf23a29d8c490698d6746132a83349024..35f8aeaa14a73cd67da3fe48555805bbf0344634 100644 --- a/sickbeard/notifiers/plex.py +++ b/sickbeard/notifiers/plex.py @@ -25,12 +25,12 @@ import sickbeard from sickbeard import logger from sickbeard import common -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex try: import xml.etree.cElementTree as etree except ImportError: - import elementtree.ElementTree as etree + import xml.etree.ElementTree as etree class PLEXNotifier: diff --git a/sickbeard/notifiers/pushover.py b/sickbeard/notifiers/pushover.py index 6a76380cc5cc640a97a3145c3d0d725ae2f711c9..7a59b8feee1b791e5694a95dd72f15d6a59ba41e 100644 --- a/sickbeard/notifiers/pushover.py +++ b/sickbeard/notifiers/pushover.py @@ -17,6 +17,7 @@ # # You should have received a copy of the GNU General Public License # along with SickRage. If not, see <http://www.gnu.org/licenses/>. + import httplib import urllib, urllib2 import time @@ -24,7 +25,7 @@ import time import sickbeard from sickbeard import logger from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD, NOTIFY_GIT_UPDATE, NOTIFY_GIT_UPDATE_TEXT -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex API_URL = "https://api.pushover.net/1/messages.json" @@ -36,12 +37,12 @@ class PushoverNotifier: def _sendPushover(self, msg, title, sound=None, userKey=None, apiKey=None): """ Sends a pushover notification to the address provided - + msg: The message to send (unicode) title: The title of the message userKey: The pushover user id to send the message to (or to subscribe with) sound: The notification sound to use - + returns: True if the message succeeded, False otherwise """ @@ -141,12 +142,12 @@ class PushoverNotifier: def notify_subtitle_download(self, ep_name, lang, title=notifyStrings[NOTIFY_SUBTITLE_DOWNLOAD]): if sickbeard.PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD: self._notifyPushover(title, ep_name + ": " + lang) - + def notify_git_update(self, new_version = "??"): if sickbeard.USE_PUSHOVER: update_text=notifyStrings[NOTIFY_GIT_UPDATE_TEXT] title=notifyStrings[NOTIFY_GIT_UPDATE] - self._notifyPushover(title, update_text + new_version) + self._notifyPushover(title, update_text + new_version) def _notifyPushover(self, title, message, sound=None, userKey=None, apiKey=None, force=False): """ @@ -154,7 +155,7 @@ class PushoverNotifier: title: The title of the notification to send message: The message string to send - userKey: The userKey to send the notification to + userKey: The userKey to send the notification to sound: The notification sound to use force: Enforce sending, for instance for testing """ diff --git a/sickbeard/notifiers/pytivo.py b/sickbeard/notifiers/pytivo.py index 5734e6bc1d5cbd9bd30796b21560cc7e16bd3901..1fb2f631b91f86fa2c859e8df1bbe6bb828219f5 100644 --- a/sickbeard/notifiers/pytivo.py +++ b/sickbeard/notifiers/pytivo.py @@ -23,8 +23,8 @@ from urllib import urlencode from urllib2 import Request, urlopen, HTTPError from sickbeard import logger -from sickbeard.exceptions import ex from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex class pyTivoNotifier: diff --git a/sickbeard/notifiers/synoindex.py b/sickbeard/notifiers/synoindex.py index 58d696a2811141903122602f27abee11ee1eb5ab..95d3a14ed286b51bc68d95d50acda414ad3e5889 100644 --- a/sickbeard/notifiers/synoindex.py +++ b/sickbeard/notifiers/synoindex.py @@ -22,8 +22,8 @@ import subprocess import sickbeard from sickbeard import logger -from sickbeard.exceptions import ex from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex class synoIndexNotifier: diff --git a/sickbeard/notifiers/synologynotifier.py b/sickbeard/notifiers/synologynotifier.py index 16d38ab12f7ba07d599ba9a62ed3cfd24b2044b1..240c69fb266e9d8f47268df0d5876cc2a3bec2f6 100644 --- a/sickbeard/notifiers/synologynotifier.py +++ b/sickbeard/notifiers/synologynotifier.py @@ -21,9 +21,9 @@ import subprocess import sickbeard from sickbeard import logger -from sickbeard.exceptions import ex from sickbeard import common from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex class synologyNotifier: diff --git a/sickbeard/notifiers/trakt.py b/sickbeard/notifiers/trakt.py index 57a5c14e0908020e671f2f4ca7b3e6862895af48..a7f7f2c1c57943897489a29e6bb47b2245e29c8c 100644 --- a/sickbeard/notifiers/trakt.py +++ b/sickbeard/notifiers/trakt.py @@ -18,11 +18,12 @@ import sickbeard from sickbeard import logger -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex from libtrakt import TraktAPI from libtrakt.exceptions import traktException, traktServerBusy, traktAuthException + class TraktNotifier: """ A "notifier" for trakt.tv which keeps track of what has and hasn't been added to your library. diff --git a/sickbeard/notifiers/tweet.py b/sickbeard/notifiers/tweet.py index f699f55aaa6b3ff751f68b764299654e557b0846..2c462b1ed150beca4e20c4e5d16692de718d006d 100644 --- a/sickbeard/notifiers/tweet.py +++ b/sickbeard/notifiers/tweet.py @@ -19,7 +19,7 @@ import sickbeard from sickbeard import logger, common -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex # parse_qsl moved to urlparse module in v2.6 try: @@ -51,7 +51,7 @@ class TwitterNotifier: def notify_subtitle_download(self, ep_name, lang): if sickbeard.TWITTER_NOTIFY_ONSUBTITLEDOWNLOAD: self._notifyTwitter(common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD] + ' ' + ep_name + ": " + lang) - + def notify_git_update(self, new_version = "??"): if sickbeard.USE_TWITTER: update_text=common.notifyStrings[common.NOTIFY_GIT_UPDATE_TEXT] diff --git a/sickbeard/nzbSplitter.py b/sickbeard/nzbSplitter.py index 4713cff07ed98e5c588607c8e0dd1c3c98e19785..dac69455df3864adbaad3b82e62ed9e599cf9cea 100644 --- a/sickbeard/nzbSplitter.py +++ b/sickbeard/nzbSplitter.py @@ -20,15 +20,17 @@ from __future__ import with_statement import requests - -import xml.etree.cElementTree as etree -import xml.etree import re +try: + import xml.etree.cElementTree as etree +except ImportError: + import xml.etree.ElementTree as etree + from sickbeard import logger, classes, helpers from sickbeard.common import Quality -from sickbeard.exceptions import ex from sickrage.helper.encoding import ek, ss +from sickrage.helper.exceptions import ex from name_parser.parser import NameParser, InvalidNameException, InvalidShowException @@ -94,7 +96,7 @@ def createNZBString(fileElements, xmlns): for curFile in fileElements: rootElement.append(stripNS(curFile, xmlns)) - return xml.etree.ElementTree.tostring(ss(rootElement)) + return etree.tostring(ss(rootElement)) def saveNZB(nzbName, nzbString): diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py index 54bc70c7a49ac208a1f93f718f7e71434c8ad8f4..1bef2888c24e13c0052477f699cb4f5943ffc446 100644 --- a/sickbeard/postProcessor.py +++ b/sickbeard/postProcessor.py @@ -30,16 +30,16 @@ import sickbeard from sickbeard import db from sickbeard import common -from sickbeard import exceptions from sickbeard import helpers from sickbeard import history from sickbeard import logger from sickbeard import notifiers from sickbeard import show_name_helpers from sickbeard import failed_history -from sickbeard.exceptions import ex from sickbeard.name_parser.parser import NameParser, InvalidNameException, InvalidShowException from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import EpisodeNotFoundException, EpisodePostProcessingFailedException, ex +from sickrage.helper.exceptions import ShowDirectoryNotFoundException import adba from sickbeard.helpers import verify_freespace @@ -688,10 +688,10 @@ class PostProcessor(object): try: curEp = show.getEpisode(season, cur_episode) if not curEp: - raise exceptions.EpisodeNotFoundException() - except exceptions.EpisodeNotFoundException, e: + raise EpisodeNotFoundException() + except EpisodeNotFoundException, e: self._log(u"Unable to create episode: " + ex(e), logger.DEBUG) - raise exceptions.PostProcessingFailed() + raise EpisodePostProcessingFailedException() # associate all the episodes together under a single root episode if root_ep == None: @@ -869,7 +869,7 @@ class PostProcessor(object): if not show: self._log(u"This show isn't in your list, you need to add it to SB before post-processing an episode", logger.WARNING) - raise exceptions.PostProcessingFailed() + raise EpisodePostProcessingFailedException() elif season == None or not episodes: self._log(u"Not enough information to determine what episode this is", logger.DEBUG) self._log(u"Quitting post-processing", logger.DEBUG) @@ -952,7 +952,7 @@ class PostProcessor(object): if cur_ep.location: helpers.delete_empty_folders(ek(os.path.dirname, cur_ep.location), keep_dir=ep_obj.show._location) except (OSError, IOError): - raise exceptions.PostProcessingFailed("Unable to delete the existing files") + raise EpisodePostProcessingFailedException("Unable to delete the existing files") # set the status of the episodes # for curEp in [ep_obj] + ep_obj.relatedEps: @@ -968,7 +968,7 @@ class PostProcessor(object): # do the library update for synoindex notifiers.synoindex_notifier.addFolder(ep_obj.show._location) except (OSError, IOError): - raise exceptions.PostProcessingFailed("Unable to create the show directory: " + ep_obj.show._location) + raise EpisodePostProcessingFailedException("Unable to create the show directory: " + ep_obj.show._location) # get metadata for the show (but not episode because it hasn't been fully processed) ep_obj.show.writeMetadata(True) @@ -1020,8 +1020,8 @@ class PostProcessor(object): proper_absolute_path = ek(os.path.join, ep_obj.show.location, proper_path) dest_path = ek(os.path.dirname, proper_absolute_path) - except exceptions.ShowDirNotFoundException: - raise exceptions.PostProcessingFailed( + except ShowDirectoryNotFoundException: + raise EpisodePostProcessingFailedException( u"Unable to post-process an episode if the show dir doesn't exist, quitting") self._log(u"Destination folder for this episode: " + dest_path, logger.DEBUG) @@ -1048,12 +1048,12 @@ class PostProcessor(object): # move the episode and associated files to the show dir if self.process_method == "copy": if helpers.isFileLocked(self.file_path, False): - raise exceptions.PostProcessingFailed("File is locked for reading") + raise EpisodePostProcessingFailedException("File is locked for reading") self._copy(self.file_path, dest_path, new_base_name, sickbeard.MOVE_ASSOCIATED_FILES, sickbeard.USE_SUBTITLES and ep_obj.show.subtitles) elif self.process_method == "move": if helpers.isFileLocked(self.file_path, True): - raise exceptions.PostProcessingFailed("File is locked for reading/writing") + raise EpisodePostProcessingFailedException("File is locked for reading/writing") self._move(self.file_path, dest_path, new_base_name, sickbeard.MOVE_ASSOCIATED_FILES, sickbeard.USE_SUBTITLES and ep_obj.show.subtitles) elif self.process_method == "hardlink": @@ -1061,14 +1061,14 @@ class PostProcessor(object): sickbeard.USE_SUBTITLES and ep_obj.show.subtitles) elif self.process_method == "symlink": if helpers.isFileLocked(self.file_path, True): - raise exceptions.PostProcessingFailed("File is locked for reading/writing") + raise EpisodePostProcessingFailedException("File is locked for reading/writing") self._moveAndSymlink(self.file_path, dest_path, new_base_name, sickbeard.MOVE_ASSOCIATED_FILES, sickbeard.USE_SUBTITLES and ep_obj.show.subtitles) else: logger.log(u"Unknown process method: " + str(self.process_method), logger.ERROR) - raise exceptions.PostProcessingFailed("Unable to move the files to their new home") + raise EpisodePostProcessingFailedException("Unable to move the files to their new home") except (OSError, IOError): - raise exceptions.PostProcessingFailed("Unable to move the files to their new home") + raise EpisodePostProcessingFailedException("Unable to move the files to their new home") # download subtitles if sickbeard.USE_SUBTITLES and ep_obj.show.subtitles: diff --git a/sickbeard/processTV.py b/sickbeard/processTV.py index b4dfc42b4b7705d95c485e2c0644dc7f31e85418..1c41988a9a3b8d9fe334c55aecd599905c9e117b 100644 --- a/sickbeard/processTV.py +++ b/sickbeard/processTV.py @@ -24,13 +24,13 @@ import stat import sickbeard from sickbeard import postProcessor -from sickbeard import db, helpers, exceptions -from sickbeard.exceptions import ex +from sickbeard import db, helpers from sickbeard import logger from sickbeard.name_parser.parser import NameParser, InvalidNameException, InvalidShowException from sickbeard import common from sickbeard import failedProcessor from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import EpisodePostProcessingFailedException, ex, FailedPostProcessingFailedException from unrar2 import RarFile from unrar2.rar_exceptions import * @@ -545,7 +545,7 @@ def process_media(processPath, videoFiles, nzbName, process_method, force, is_pr processor = postProcessor.PostProcessor(cur_video_file_path, nzbName, process_method, is_priority) result.result = processor.process() process_fail_message = "" - except exceptions.PostProcessingFailed, e: + except EpisodePostProcessingFailedException, e: result.result = False process_fail_message = ex(e) @@ -601,7 +601,7 @@ def process_failed(dirName, nzbName, result): processor = failedProcessor.FailedProcessor(dirName, nzbName) result.result = processor.process() process_fail_message = "" - except exceptions.FailedProcessingFailed, e: + except FailedPostProcessingFailedException, e: result.result = False process_fail_message = ex(e) diff --git a/sickbeard/properFinder.py b/sickbeard/properFinder.py index 9a8e11b987619028e375edc6c25ead2c76c93c52..7e81bc12803eec87852305fcb4748f9e3e5ead5d 100644 --- a/sickbeard/properFinder.py +++ b/sickbeard/properFinder.py @@ -29,18 +29,17 @@ from search import pickBestResult import sickbeard from sickbeard import db -from sickbeard import exceptions -from sickbeard.exceptions import ex from sickbeard import helpers, logger from sickbeard import search from sickbeard.common import DOWNLOADED, SNATCHED, SNATCHED_PROPER, Quality, cpu_presets +from sickrage.helper.exceptions import AuthException, ex from sickrage.show.History import History from name_parser.parser import NameParser, InvalidNameException, InvalidShowException -class ProperFinder(): +class ProperFinder: def __init__(self): self.amActive = False @@ -91,7 +90,7 @@ class ProperFinder(): try: curPropers = curProvider.findPropers(search_date) - except exceptions.AuthException, e: + except AuthException, e: logger.log(u"Authentication error: " + ex(e), logger.ERROR) continue except Exception, e: diff --git a/sickbeard/providers/alpharatio.py b/sickbeard/providers/alpharatio.py index 2eb427fa854b3c29bfc9829c2f2cd63c74a26db9..fd035fa6222c160d8f7f2c390aa364d391ee6d79 100644 --- a/sickbeard/providers/alpharatio.py +++ b/sickbeard/providers/alpharatio.py @@ -30,12 +30,11 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex -import requests from sickbeard.bs4_parser import BS4Parser from unidecode import unidecode from sickbeard.helpers import sanitizeSceneName + class AlphaRatioProvider(generic.TorrentProvider): def __init__(self): @@ -43,6 +42,7 @@ class AlphaRatioProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "AlphaRatio") self.supportsBacklog = True + self.public = False self.enabled = False self.username = None diff --git a/sickbeard/providers/animenzb.py b/sickbeard/providers/animenzb.py index b6fac166607939f9152afa1265fb694c10792cda..d2ff88e659f90db32e227aee6e9449a1121780d9 100644 --- a/sickbeard/providers/animenzb.py +++ b/sickbeard/providers/animenzb.py @@ -36,6 +36,7 @@ class animenzb(generic.NZBProvider): generic.NZBProvider.__init__(self, "AnimeNZB") self.supportsBacklog = False + self.public = True self.supportsAbsoluteNumbering = True self.anime_only = True diff --git a/sickbeard/providers/bitsoup.py b/sickbeard/providers/bitsoup.py index 2bd5d74274a0f0224706850e4db04f317ae81d9a..3025b7ecb5241262623dac0ac58522d10fc682e9 100644 --- a/sickbeard/providers/bitsoup.py +++ b/sickbeard/providers/bitsoup.py @@ -21,7 +21,6 @@ import traceback import datetime import sickbeard import generic -import requests from sickbeard.common import Quality from sickbeard import logger @@ -30,10 +29,9 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex, AuthException from sickbeard.helpers import sanitizeSceneName from sickbeard.bs4_parser import BS4Parser -from unidecode import unidecode +from sickrage.helper.exceptions import AuthException class BitSoupProvider(generic.TorrentProvider): @@ -51,6 +49,7 @@ class BitSoupProvider(generic.TorrentProvider): self.url = self.urls['base_url'] self.supportsBacklog = True + self.public = False self.enabled = False self.username = None self.password = None diff --git a/sickbeard/providers/bluetigers.py b/sickbeard/providers/bluetigers.py index e470835f088d62af0416d6d65a662eaeeee4fb9d..e280265b56d960785d366f6de95ea7323134bdcb 100644 --- a/sickbeard/providers/bluetigers.py +++ b/sickbeard/providers/bluetigers.py @@ -31,10 +31,8 @@ from sickbeard import tvcache from sickbeard import show_name_helpers from sickbeard import db from sickbeard import helpers -from unidecode import unidecode from sickbeard import classes from sickbeard.helpers import sanitizeSceneName -from sickbeard.exceptions import ex class BLUETIGERSProvider(generic.TorrentProvider): @@ -42,6 +40,7 @@ class BLUETIGERSProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "BLUETIGERS") self.supportsBacklog = True + self.public = False self.enabled = False self.username = None self.password = None diff --git a/sickbeard/providers/btdigg.py b/sickbeard/providers/btdigg.py index c31bf240616f622dd76ee71030483264089eb8ba..f0be007a4a5981b0117a8031d5227e570b987929 100644 --- a/sickbeard/providers/btdigg.py +++ b/sickbeard/providers/btdigg.py @@ -35,6 +35,7 @@ class BTDIGGProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "BTDigg") self.supportsBacklog = True + self.public = True self.url = 'https://api.btdigg.org/' self.cache = BTDiggCache(self) diff --git a/sickbeard/providers/btn.py b/sickbeard/providers/btn.py index 5d1680eae3aaef503e2808d49ceb8c85eb65aa7d..70b7e8a3a293bc64e4acee477e4a00f52704bdcd 100644 --- a/sickbeard/providers/btn.py +++ b/sickbeard/providers/btn.py @@ -29,12 +29,12 @@ from sickbeard import scene_exceptions from sickbeard import logger from sickbeard import tvcache from sickbeard.helpers import sanitizeSceneName -from sickbeard.exceptions import ex, AuthException from sickbeard.common import MULTI_EP_RESULT from sickbeard.common import SEASON_RESULT from sickbeard import db from sickbeard.name_parser.parser import NameParser, InvalidNameException, InvalidShowException from sickbeard.common import Quality, cpu_presets +from sickrage.helper.exceptions import AuthException, ex import jsonrpclib from datetime import datetime @@ -45,6 +45,7 @@ class BTNProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "BTN") self.supportsBacklog = True + self.public = False self.supportsAbsoluteNumbering = True self.enabled = False diff --git a/sickbeard/providers/cpasbien.py b/sickbeard/providers/cpasbien.py index 984428d5a9fd9ca66c057fa035d9dad78f575a9e..3381fce7578f0fa7b14ccf80d5b951b0d18b3e95 100644 --- a/sickbeard/providers/cpasbien.py +++ b/sickbeard/providers/cpasbien.py @@ -42,6 +42,7 @@ class CpasbienProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "Cpasbien") self.supportsBacklog = True + self.public = True self.ratio = None self.url = "http://www.cpasbien.pw" diff --git a/sickbeard/providers/fnt.py b/sickbeard/providers/fnt.py index d7feb2e1344e6d95ca80fb8d1400b7bd2627a143..a86b796e513e4e1804cede53a91245415afe638d 100644 --- a/sickbeard/providers/fnt.py +++ b/sickbeard/providers/fnt.py @@ -33,7 +33,6 @@ from sickbeard import db from sickbeard import helpers from sickbeard import classes from sickbeard.helpers import sanitizeSceneName -from sickbeard.exceptions import ex class FNTProvider(generic.TorrentProvider): @@ -41,6 +40,7 @@ class FNTProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "FNT") self.supportsBacklog = True + self.public = False self.enabled = False self.username = None self.password = None diff --git a/sickbeard/providers/frenchtorrentdb.py b/sickbeard/providers/frenchtorrentdb.py index ee72a6ede24fc8ac2baff5857b2e2746ef9aadab..7d68c4777979fa24d6ee435870cd6216060e5137 100644 --- a/sickbeard/providers/frenchtorrentdb.py +++ b/sickbeard/providers/frenchtorrentdb.py @@ -40,6 +40,7 @@ class FrenchTorrentDBProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "FrenchTorrentDB") self.supportsBacklog = True + self.public = False self.urls = { 'base_url': 'http://www.frenchtorrentdb.com', diff --git a/sickbeard/providers/freshontv.py b/sickbeard/providers/freshontv.py index 4db36d8372e4008bb3f14f6e21eb91a11387828c..859e0a097f8baba9ffa11a8a6aa684d91c77341a 100644 --- a/sickbeard/providers/freshontv.py +++ b/sickbeard/providers/freshontv.py @@ -29,7 +29,7 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex, AuthException +from sickrage.helper.exceptions import AuthException import requests from sickbeard.bs4_parser import BS4Parser from unidecode import unidecode @@ -43,6 +43,7 @@ class FreshOnTVProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "FreshOnTV") self.supportsBacklog = True + self.public = False self.enabled = False self._uid = None diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py index 0c1c91f7c1d75133e71e2ad65f731433a77c1ac4..a1ef297fa1688331591c896c0b40826ebb0d9369 100644 --- a/sickbeard/providers/generic.py +++ b/sickbeard/providers/generic.py @@ -34,11 +34,11 @@ import sickbeard from sickbeard import helpers, classes, logger, db from sickbeard.common import MULTI_EP_RESULT, SEASON_RESULT from sickbeard import tvcache -from sickbeard.exceptions import ex from sickbeard.name_parser.parser import NameParser, InvalidNameException, InvalidShowException from sickbeard.common import Quality from sickbeard.common import user_agents from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex class GenericProvider: diff --git a/sickbeard/providers/hdbits.py b/sickbeard/providers/hdbits.py index e0472c7f3b773cc06e41ef38a3f96477b259d5f7..b8d3c128a0d4dca008a5e3fd18f563340f58c061 100644 --- a/sickbeard/providers/hdbits.py +++ b/sickbeard/providers/hdbits.py @@ -20,7 +20,7 @@ import generic from sickbeard import classes from sickbeard import logger, tvcache -from sickbeard.exceptions import AuthException +from sickrage.helper.exceptions import AuthException try: import json @@ -34,6 +34,7 @@ class HDBitsProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "HDBits") self.supportsBacklog = True + self.public = False self.enabled = False self.username = None diff --git a/sickbeard/providers/hdtorrents.py b/sickbeard/providers/hdtorrents.py index d6eec624ad32b14b3bb467f5e56d74c7fc59479c..b70ab3101f58ef9e03f6da79499280e518d21410 100644 --- a/sickbeard/providers/hdtorrents.py +++ b/sickbeard/providers/hdtorrents.py @@ -28,19 +28,21 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex, AuthException +from sickrage.helper.exceptions import AuthException import requests from BeautifulSoup import BeautifulSoup as soup from unidecode import unidecode from sickbeard.helpers import sanitizeSceneName from datetime import datetime + class HDTorrentsProvider(generic.TorrentProvider): def __init__(self): generic.TorrentProvider.__init__(self, "HDTorrents") self.supportsBacklog = True + self.public = False self.username = None self.password = None @@ -192,24 +194,24 @@ class HDTorrentsProvider(generic.TorrentProvider): seeders = int(cell.text) elif None is leechers and cell.get('class')[0] and cell.get('class')[0] in 'green' 'yellow' 'red': leechers = int(cell.text) - + # Skip torrents released before the episode aired (fakes) if re.match('..:..:.. ..:..:....', cells[6].text): if (datetime.strptime(cells[6].text, '%H:%M:%S %m/%d/%Y') - datetime.combine(epObj.airdate, datetime.min.time())).days < 0: continue - + # Need size for failed downloads handling if re.match('[0-9]+,?\.?[0-9]* [KkMmGg]+[Bb]+', cells[7].text): size = self._convertSize(cells[7].text) - + if not title or not url or not seeders or leechers is None or not size or \ seeders < self.minseed or leechers < self.minleech: continue - + item = title, url, seeders, leechers, size logger.log(u"Found result: " + title + " (" + searchURL + ")", logger.DEBUG) - + results.append(item) except: diff --git a/sickbeard/providers/hounddawgs.py b/sickbeard/providers/hounddawgs.py index a3d355406a578dec5411d16098370a1b051829b3..036c96aa230368016b132c7c254d231f27f34c13 100644 --- a/sickbeard/providers/hounddawgs.py +++ b/sickbeard/providers/hounddawgs.py @@ -21,7 +21,6 @@ import traceback import datetime import sickbeard import generic -import urllib from sickbeard.common import Quality from sickbeard import logger from sickbeard import tvcache @@ -29,10 +28,7 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex -import requests from sickbeard.bs4_parser import BS4Parser -from unidecode import unidecode from sickbeard.helpers import sanitizeSceneName @@ -43,6 +39,7 @@ class HoundDawgsProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "HoundDawgs") self.supportsBacklog = True + self.public = False self.enabled = False self.username = None diff --git a/sickbeard/providers/iptorrents.py b/sickbeard/providers/iptorrents.py index d2d0d6abfdd8aa69b285bb319e4bde7c5d5abbdd..8aa5e896ff109afe919a6712c7db2bc0327c6349 100644 --- a/sickbeard/providers/iptorrents.py +++ b/sickbeard/providers/iptorrents.py @@ -31,8 +31,7 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex, AuthException -import requests +from sickrage.helper.exceptions import AuthException from sickbeard.bs4_parser import BS4Parser from unidecode import unidecode from sickbeard.helpers import sanitizeSceneName @@ -46,6 +45,7 @@ class IPTorrentsProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "IPTorrents") self.supportsBacklog = True + self.public = False self.enabled = False self.username = None diff --git a/sickbeard/providers/kat.py b/sickbeard/providers/kat.py index 9560fc580999d5fea34414d7e7a46abd8e8dcc25..50fb3a9f3299b39d405b5dd6d6ddb03f432397ba 100644 --- a/sickbeard/providers/kat.py +++ b/sickbeard/providers/kat.py @@ -43,6 +43,7 @@ class KATProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "KickAssTorrents") self.supportsBacklog = True + self.public = True self.enabled = False self.confirmed = False diff --git a/sickbeard/providers/libertalia.py b/sickbeard/providers/libertalia.py index 97c720b618c816571280dc467f11464567610ef1..8424a0b9e978ea224537d2f78d62105164433e62 100644 --- a/sickbeard/providers/libertalia.py +++ b/sickbeard/providers/libertalia.py @@ -37,7 +37,7 @@ from sickbeard import helpers from sickbeard import classes from unidecode import unidecode from sickbeard.helpers import sanitizeSceneName -from sickbeard.exceptions import ex + class LibertaliaProvider(generic.TorrentProvider): @@ -46,6 +46,7 @@ class LibertaliaProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "Libertalia") self.supportsBacklog = True + self.public = False self.cj = cookielib.CookieJar() diff --git a/sickbeard/providers/morethantv.py b/sickbeard/providers/morethantv.py index b3e29900e89e088f57347618170fa8c8f41c194e..9560408783ad1ceaff9012ad3103a3df112407a8 100644 --- a/sickbeard/providers/morethantv.py +++ b/sickbeard/providers/morethantv.py @@ -32,7 +32,7 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex, AuthException +from sickrage.helper.exceptions import AuthException import requests from sickbeard.bs4_parser import BS4Parser from unidecode import unidecode @@ -46,6 +46,7 @@ class MoreThanTVProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "MoreThanTV") self.supportsBacklog = True + self.public = False self.enabled = False self._uid = None diff --git a/sickbeard/providers/newznab.py b/sickbeard/providers/newznab.py index f52925d910c5f745f90f1bfdfa079671d5ea7958..3c6c93d5d14f1045f15aaa511c666741700d8614 100644 --- a/sickbeard/providers/newznab.py +++ b/sickbeard/providers/newznab.py @@ -31,8 +31,8 @@ from sickbeard import scene_exceptions from sickbeard import logger from sickbeard import tvcache from sickbeard import db -from sickbeard.exceptions import AuthException from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import AuthException class NewznabProvider(generic.NZBProvider): diff --git a/sickbeard/providers/nextgen.py b/sickbeard/providers/nextgen.py index 8c59ee1e7823be78c2cbcc81c725bbc948c66b38..2c168c5c5007782a817c69fc02aa0c7dcf22b510 100644 --- a/sickbeard/providers/nextgen.py +++ b/sickbeard/providers/nextgen.py @@ -42,6 +42,7 @@ class NextGenProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "NextGen") self.supportsBacklog = True + self.public = False self.enabled = False self.username = None diff --git a/sickbeard/providers/nyaatorrents.py b/sickbeard/providers/nyaatorrents.py index a49627bbe9180b3f70aacf94c8a6dec9c73b4870..1a1b1129e94a9d452f1ac527923e1348608e73d4 100644 --- a/sickbeard/providers/nyaatorrents.py +++ b/sickbeard/providers/nyaatorrents.py @@ -34,6 +34,7 @@ class NyaaProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "NyaaTorrents") self.supportsBacklog = True + self.public = True self.supportsAbsoluteNumbering = True self.anime_only = True self.enabled = False diff --git a/sickbeard/providers/omgwtfnzbs.py b/sickbeard/providers/omgwtfnzbs.py index 71a7733214573399d6dafcf554f47c76984cc6ed..1f323381d49daf1c120e580e0e2e34383e2a7522 100644 --- a/sickbeard/providers/omgwtfnzbs.py +++ b/sickbeard/providers/omgwtfnzbs.py @@ -24,9 +24,9 @@ import generic from sickbeard import tvcache from sickbeard import classes from sickbeard import logger -from sickbeard.exceptions import AuthException from sickbeard import show_name_helpers from datetime import datetime +from sickrage.helper.exceptions import AuthException class OmgwtfnzbsProvider(generic.NZBProvider): @@ -41,6 +41,7 @@ class OmgwtfnzbsProvider(generic.NZBProvider): self.url = self.urls['base_url'] self.supportsBacklog = True + self.public = False def isEnabled(self): return self.enabled diff --git a/sickbeard/providers/rarbg.py b/sickbeard/providers/rarbg.py index 36c023abea78a8df19a6bb04de6cae2c9d2e5f5f..a399fe48cb7287895a9ab5721aadeeb01a3c6a94 100644 --- a/sickbeard/providers/rarbg.py +++ b/sickbeard/providers/rarbg.py @@ -19,7 +19,6 @@ import traceback import re -import datetime import generic import datetime import json @@ -34,8 +33,8 @@ from sickbeard import show_name_helpers from sickbeard import db from sickbeard import helpers from sickbeard import classes -from sickbeard.exceptions import ex from sickbeard.indexers.indexer_config import INDEXER_TVDB +from sickrage.helper.exceptions import ex class GetOutOfLoop(Exception): @@ -49,6 +48,7 @@ class RarbgProvider(generic.TorrentProvider): self.enabled = False self.supportsBacklog = True + self.public = True self.ratio = None self.minseed = None self.ranked = None diff --git a/sickbeard/providers/rsstorrent.py b/sickbeard/providers/rsstorrent.py index 13f5c64ae014edefddfaec7ef9dc5d14bf482ffd..76722a8c06cdff179ea0d7661ed964520b0f9c78 100644 --- a/sickbeard/providers/rsstorrent.py +++ b/sickbeard/providers/rsstorrent.py @@ -24,8 +24,8 @@ import generic from sickbeard import helpers from sickbeard import logger from sickbeard import tvcache -from sickbeard.exceptions import ex from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex import requests from bencode import bdecode diff --git a/sickbeard/providers/scc.py b/sickbeard/providers/scc.py index 4f5caea412366732f8dacc57c25383326454cb28..e70fceb5cdd5124c00c424783d34b4086f7c1753 100644 --- a/sickbeard/providers/scc.py +++ b/sickbeard/providers/scc.py @@ -31,8 +31,6 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex -import requests from sickbeard.bs4_parser import BS4Parser from unidecode import unidecode from sickbeard.helpers import sanitizeSceneName @@ -45,6 +43,7 @@ class SCCProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "SceneAccess") self.supportsBacklog = True + self.public = False self.enabled = False self.username = None diff --git a/sickbeard/providers/scenetime.py b/sickbeard/providers/scenetime.py index 515d91448bc4396a19eed81a47d6a786afb85d1e..acf01e7b4843d8357f05dff98aad7c8b7b8ee002 100644 --- a/sickbeard/providers/scenetime.py +++ b/sickbeard/providers/scenetime.py @@ -29,8 +29,6 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex -import requests from sickbeard.bs4_parser import BS4Parser from unidecode import unidecode from sickbeard.helpers import sanitizeSceneName @@ -43,6 +41,7 @@ class SceneTimeProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "SceneTime") self.supportsBacklog = True + self.public = False self.enabled = False self.username = None diff --git a/sickbeard/providers/shazbat.py b/sickbeard/providers/shazbat.py index 69a62376008902bfc05ee337127ae6901566e719..d1cb5aa92bb1cd1786361bb6f61740b03f34b481 100644 --- a/sickbeard/providers/shazbat.py +++ b/sickbeard/providers/shazbat.py @@ -18,9 +18,9 @@ import generic -from sickbeard.exceptions import AuthException from sickbeard import logger from sickbeard import tvcache +from sickrage.helper.exceptions import AuthException class ShazbatProvider(generic.TorrentProvider): @@ -29,6 +29,7 @@ class ShazbatProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "Shazbat.tv") self.supportsBacklog = False + self.public = False self.enabled = False self.passkey = None diff --git a/sickbeard/providers/speedcd.py b/sickbeard/providers/speedcd.py index 3c8d281bb59e6e9afb1373b29e770c869dc94ac1..4533e94d22c389bd1eba5f3a52f0a23778d062a1 100644 --- a/sickbeard/providers/speedcd.py +++ b/sickbeard/providers/speedcd.py @@ -28,8 +28,6 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex -import requests from sickbeard.helpers import sanitizeSceneName @@ -40,6 +38,7 @@ class SpeedCDProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "Speedcd") self.supportsBacklog = True + self.public = False self.enabled = False self.username = None diff --git a/sickbeard/providers/strike.py b/sickbeard/providers/strike.py index 9b55d426ffb767e7fbe8d2722c2f7259fa988262..18f39be7a024d26407c454e72ca3102356bb7b19 100644 --- a/sickbeard/providers/strike.py +++ b/sickbeard/providers/strike.py @@ -33,6 +33,7 @@ class STRIKEProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "Strike") self.supportsBacklog = True + self.public = True self.url = 'https://getstrike.net/' self.cache = StrikeCache(self) diff --git a/sickbeard/providers/t411.py b/sickbeard/providers/t411.py index e4a6847be1bf744e598416be40d01fef85d67d3b..acf9677a0538207ef6719d34d30bac9d14d72bad 100644 --- a/sickbeard/providers/t411.py +++ b/sickbeard/providers/t411.py @@ -25,8 +25,6 @@ from requests.auth import AuthBase import sickbeard import generic -import requests - from sickbeard.common import Quality from sickbeard import logger from sickbeard import tvcache @@ -35,7 +33,6 @@ from sickbeard import db from sickbeard import helpers from sickbeard import classes from sickbeard.helpers import sanitizeSceneName -from sickbeard.exceptions import ex class T411Provider(generic.TorrentProvider): @@ -43,6 +40,7 @@ class T411Provider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "T411") self.supportsBacklog = True + self.public = False self.enabled = False self.username = None self.password = None @@ -52,10 +50,10 @@ class T411Provider(generic.TorrentProvider): self.cache = T411Cache(self) - self.urls = {'base_url': 'http://www.t411.io/', - 'search': 'https://api.t411.io/torrents/search/%s?cid=%s&limit=100', - 'login_page': 'https://api.t411.io/auth', - 'download': 'https://api.t411.io/torrents/download/%s', + self.urls = {'base_url': 'http://www.t411.in/', + 'search': 'https://api.t411.in/torrents/search/%s?cid=%s&limit=100', + 'login_page': 'https://api.t411.in/auth', + 'download': 'https://api.t411.in/torrents/download/%s', } self.url = self.urls['base_url'] diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py index c00ec9a4bb8d24291cd38ae71b95b9488db68398..3cf73da813aef876a7909bdb412cdbfaf2cb691e 100644 --- a/sickbeard/providers/thepiratebay.py +++ b/sickbeard/providers/thepiratebay.py @@ -40,6 +40,7 @@ class ThePirateBayProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "ThePirateBay") self.supportsBacklog = True + self.public = True self.enabled = False self.ratio = None diff --git a/sickbeard/providers/titansoftv.py b/sickbeard/providers/titansoftv.py index f71fc29f2ea1eef727bfa5c5b91f9e3cdc731daa..0f1fa667de6b9b01e49688ecdaaf71978f3d8d4f 100644 --- a/sickbeard/providers/titansoftv.py +++ b/sickbeard/providers/titansoftv.py @@ -19,18 +19,18 @@ import urllib -import requests import generic from sickbeard import logger from sickbeard import tvcache from sickbeard.helpers import mapIndexersToShow -from sickbeard.exceptions import AuthException +from sickrage.helper.exceptions import AuthException class TitansOfTVProvider(generic.TorrentProvider): def __init__(self): generic.TorrentProvider.__init__(self, 'TitansOfTV') self.supportsBacklog = True + self.public = False self.supportsAbsoluteNumbering = True self.api_key = None self.ratio = None diff --git a/sickbeard/providers/tntvillage.py b/sickbeard/providers/tntvillage.py index 6690b693a5578258ddaef0a22e6f20e29494ef3c..4c357a674423cb0416088c08920588bb10324730 100644 --- a/sickbeard/providers/tntvillage.py +++ b/sickbeard/providers/tntvillage.py @@ -28,12 +28,11 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex, AuthException -from requests.exceptions import RequestException from sickbeard.bs4_parser import BS4Parser from unidecode import unidecode from sickbeard.helpers import sanitizeSceneName from sickbeard.name_parser.parser import NameParser, InvalidNameException, InvalidShowException +from sickrage.helper.exceptions import AuthException category_excluded = { 'Sport' : 22, @@ -69,6 +68,7 @@ class TNTVillageProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "TNTVillage") self.supportsBacklog = True + self.public = False self.enabled = False self._uid = None diff --git a/sickbeard/providers/tokyotoshokan.py b/sickbeard/providers/tokyotoshokan.py index e6917e5f82765673418b0924cb7d674d1c0a7674..c4266af2d6681e14975bb0c42cee83eef9740103 100644 --- a/sickbeard/providers/tokyotoshokan.py +++ b/sickbeard/providers/tokyotoshokan.py @@ -35,6 +35,7 @@ class TokyoToshokanProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "TokyoToshokan") self.supportsBacklog = True + self.public = True self.supportsAbsoluteNumbering = True self.anime_only = True self.enabled = False diff --git a/sickbeard/providers/torrentbytes.py b/sickbeard/providers/torrentbytes.py index 0fca46100bb3aff331e301203a145f2bfc0b36d6..95400ea00eea41691bbad992b760984e6431cbe0 100644 --- a/sickbeard/providers/torrentbytes.py +++ b/sickbeard/providers/torrentbytes.py @@ -29,8 +29,6 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex -import requests from sickbeard.bs4_parser import BS4Parser from unidecode import unidecode from sickbeard.helpers import sanitizeSceneName @@ -43,6 +41,7 @@ class TorrentBytesProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "TorrentBytes") self.supportsBacklog = True + self.public = False self.enabled = False self.username = None diff --git a/sickbeard/providers/torrentday.py b/sickbeard/providers/torrentday.py index fe711df62e391ac9a48dd891a9995c84fae1a38a..45e7119e40bc0e6ae4fe88037d2bc73edf42205e 100644 --- a/sickbeard/providers/torrentday.py +++ b/sickbeard/providers/torrentday.py @@ -26,7 +26,6 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex import requests from sickbeard.helpers import sanitizeSceneName @@ -38,6 +37,7 @@ class TorrentDayProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "TorrentDay") self.supportsBacklog = True + self.public = False self.enabled = False self._uid = None diff --git a/sickbeard/providers/torrentleech.py b/sickbeard/providers/torrentleech.py index ff888b4edb93f76256330d2719012155c6708249..d46ba094d32c4fbe6d14d3bf86eba309ee1f3f2d 100644 --- a/sickbeard/providers/torrentleech.py +++ b/sickbeard/providers/torrentleech.py @@ -30,7 +30,6 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex from sickbeard.bs4_parser import BS4Parser from unidecode import unidecode from sickbeard.helpers import sanitizeSceneName @@ -43,6 +42,7 @@ class TorrentLeechProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "TorrentLeech") self.supportsBacklog = True + self.public = False self.enabled = False self.username = None diff --git a/sickbeard/providers/transmitthenet.py b/sickbeard/providers/transmitthenet.py index ec35943724a6b189cf9143fe2fbdd4d566ae7e6c..b9113e3f98e889a2b1ef31aaf441835f5b4b1cca 100644 --- a/sickbeard/providers/transmitthenet.py +++ b/sickbeard/providers/transmitthenet.py @@ -18,7 +18,6 @@ import traceback import datetime import sickbeard import generic -import requests from sickbeard.common import Quality from sickbeard import logger @@ -27,10 +26,9 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex, AuthException from sickbeard.helpers import sanitizeSceneName from sickbeard.bs4_parser import BS4Parser -from unidecode import unidecode +from sickrage.helper.exceptions import AuthException from urllib import urlencode @@ -46,6 +44,7 @@ class TransmitTheNetProvider(generic.TorrentProvider): self.url = self.urls['base_url'] self.supportsBacklog = True + self.public = False self.enabled = False self.username = None self.password = None @@ -173,7 +172,7 @@ class TransmitTheNetProvider(generic.TorrentProvider): with BS4Parser(data) as html: torrent_rows = [] - + down_elems = html.findAll("img", {"alt": "Download Torrent"}) for down_elem in down_elems: if down_elem: diff --git a/sickbeard/providers/tvchaosuk.py b/sickbeard/providers/tvchaosuk.py index 66406b665eb074bf829ed8ef90bb75ea44cc1238..9ba9f2a49fc51304bcdca686ee6518af096e1828 100644 --- a/sickbeard/providers/tvchaosuk.py +++ b/sickbeard/providers/tvchaosuk.py @@ -14,7 +14,6 @@ # along with SickRage. If not, see <http://www.gnu.org/licenses/>. import re -import traceback import datetime import sickbeard import generic @@ -26,9 +25,9 @@ from sickbeard import db from sickbeard import classes from sickbeard import helpers from sickbeard import show_name_helpers -from sickbeard.exceptions import ex, AuthException from sickbeard.helpers import sanitizeSceneName from sickbeard.bs4_parser import BS4Parser +from sickrage.helper.exceptions import AuthException from urllib import urlencode @@ -47,6 +46,7 @@ class TVChaosUKProvider(generic.TorrentProvider): self.url = self.urls['base_url'] self.supportsBacklog = True + self.public = False self.enabled = False self.username = None self.password = None diff --git a/sickbeard/providers/womble.py b/sickbeard/providers/womble.py index 5983a89e2445be1262b0d038dbeeed2110adec13..4e11676858e6802ea2c8a4cffffe30673d2b4413 100644 --- a/sickbeard/providers/womble.py +++ b/sickbeard/providers/womble.py @@ -26,6 +26,7 @@ class WombleProvider(generic.NZBProvider): def __init__(self): generic.NZBProvider.__init__(self, "Womble's Index") self.enabled = False + self.public = True self.cache = WombleCache(self) self.urls = {'base_url': 'https://newshost.co.za/'} self.url = self.urls['base_url'] diff --git a/sickbeard/providers/xthor.py b/sickbeard/providers/xthor.py index f39771e71ffffa0dcd94bcb1eca3db0543327ff5..ebbfec0598b9143d820b04d178680a168f86457c 100644 --- a/sickbeard/providers/xthor.py +++ b/sickbeard/providers/xthor.py @@ -33,7 +33,7 @@ from sickbeard import helpers from unidecode import unidecode from sickbeard import classes from sickbeard.helpers import sanitizeSceneName -from sickbeard.exceptions import ex + class XthorProvider(generic.TorrentProvider): @@ -42,6 +42,7 @@ class XthorProvider(generic.TorrentProvider): generic.TorrentProvider.__init__(self, "Xthor") self.supportsBacklog = True + self.public = False self.cj = cookielib.CookieJar() diff --git a/sickbeard/rssfeeds.py b/sickbeard/rssfeeds.py index e117568b473e5d5011f803fa8e2fbdf55948af84..4e5620367596ce4d0bbfefdfdc85246f9a8972b9 100644 --- a/sickbeard/rssfeeds.py +++ b/sickbeard/rssfeeds.py @@ -6,8 +6,8 @@ import urllib import sickbeard from sickbeard import logger -from sickbeard.exceptions import ex from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex from feedcache.cache import Cache diff --git a/sickbeard/sab.py b/sickbeard/sab.py index 458863987a03d2f8c302d22f688d9bf1bf79cae0..9eb9cfdfbf6a9a5a535871537e900bab0da37454 100644 --- a/sickbeard/sab.py +++ b/sickbeard/sab.py @@ -17,8 +17,6 @@ # You should have received a copy of the GNU General Public License # along with SickRage. If not, see <http://www.gnu.org/licenses/>. - - import urllib, httplib import sickbeard @@ -33,13 +31,13 @@ except ImportError: from sickbeard.common import USER_AGENT from sickbeard import logger -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex def sendNZB(nzb): """ Sends an NZB to SABnzbd via the API. - + :param nzb: The NZBSearchResult object to send to SAB """ @@ -89,7 +87,7 @@ def sendNZB(nzb): logger.log(u"URL: " + url, logger.DEBUG) try: - # if we have the URL to an NZB then we've built up the SAB API URL already so just call it + # if we have the URL to an NZB then we've built up the SAB API URL already so just call it if nzb.resultType == "nzb": f = urllib.urlopen(url) @@ -228,7 +226,7 @@ def getSabAccesMethod(host=None, username=None, password=None, apikey=None): def testAuthentication(host=None, username=None, password=None, apikey=None): """ Sends a simple API request to SAB to determine if the given connection information is connect - + :param host: The host where SAB is running (incl port) :param username: The username to use for the HTTP request :param password: The password to use for the HTTP request @@ -257,4 +255,4 @@ def testAuthentication(host=None, username=None, password=None, apikey=None): return False, sabText return True, "Success" - + diff --git a/sickbeard/scene_numbering.py b/sickbeard/scene_numbering.py index ffb3d0fdb2667b92b771ec4caa11577797636455..6ad0a15d3a5571adfb9afa36a0b3237d9663c2e1 100644 --- a/sickbeard/scene_numbering.py +++ b/sickbeard/scene_numbering.py @@ -22,7 +22,6 @@ # @copyright: Dermot Buckley # - import time import datetime import traceback @@ -30,8 +29,9 @@ import traceback import sickbeard from sickbeard import logger from sickbeard import db -from sickbeard.exceptions import ex from sickbeard import helpers +from sickrage.helper.exceptions import ex + def get_scene_numbering(indexer_id, indexer, season, episode, fallback_to_xem=True): """ @@ -536,6 +536,7 @@ def xem_refresh(indexer_id, indexer, force=False): indexer).name + ": " + ex(e), logger.WARNING) logger.log(traceback.format_exc(), logger.DEBUG) + def fix_xem_numbering(indexer_id, indexer): """ Returns a dict of (season, episode) : (sceneSeason, sceneEpisode) mappings diff --git a/sickbeard/scheduler.py b/sickbeard/scheduler.py index f95f1ecaa8465e57268ddd97a82479a411050044..b3068f54d121d969273037d513d9bffaee20d51a 100644 --- a/sickbeard/scheduler.py +++ b/sickbeard/scheduler.py @@ -23,7 +23,7 @@ import threading import traceback from sickbeard import logger -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex class Scheduler(threading.Thread): diff --git a/sickbeard/search.py b/sickbeard/search.py index b11bd24662322d5ed082e70def54bf5df992f68b..090c8be24b6ef0a0edd1dbc3a49db054ddd710e7 100644 --- a/sickbeard/search.py +++ b/sickbeard/search.py @@ -29,7 +29,7 @@ import sickbeard from common import SNATCHED, SNATCHED_PROPER, SNATCHED_BEST, Quality, SEASON_RESULT, MULTI_EP_RESULT -from sickbeard import logger, db, show_name_helpers, exceptions, helpers +from sickbeard import logger, db, show_name_helpers, helpers from sickbeard import sab from sickbeard import nzbget from sickbeard import clients @@ -38,10 +38,10 @@ from sickbeard import notifiers from sickbeard import nzbSplitter from sickbeard import ui from sickbeard import failed_history -from sickbeard.exceptions import ex from sickbeard.providers.generic import GenericProvider from sickbeard import common from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import AuthException, ex def _downloadResult(result): @@ -387,7 +387,7 @@ def searchForNeededEpisodes(): curFoundResults = {} try: curFoundResults = curProvider.searchRSS(episodes) - except exceptions.AuthException, e: + except AuthException, e: logger.log(u"Authentication error: " + ex(e), logger.ERROR) continue except Exception, e: @@ -486,7 +486,7 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False): try: searchResults = curProvider.findSearchResults(show, episodes, search_mode, manualSearch, downCurQuality) - except exceptions.AuthException, e: + except AuthException, e: logger.log(u"Authentication error: " + ex(e), logger.ERROR) break except Exception, e: diff --git a/sickbeard/showUpdater.py b/sickbeard/showUpdater.py index 4485dfd7a738fdfc0b120f315487bdf76937ae81..b55ab3dde6ea04526c33c2c5055ea5c43f7afc76 100644 --- a/sickbeard/showUpdater.py +++ b/sickbeard/showUpdater.py @@ -21,20 +21,20 @@ import threading import sickbeard from sickbeard import logger -from sickbeard import exceptions from sickbeard import ui -from sickbeard.exceptions import ex from sickbeard import db from sickbeard import network_timezones from sickbeard import failed_history +from sickrage.helper.exceptions import CantRefreshShowException, CantUpdateShowException, ex -class ShowUpdater(): + +class ShowUpdater: def __init__(self): self.lock = threading.Lock() self.amActive = False def run(self, force=False): - + self.amActive = True update_datetime = datetime.datetime.now() @@ -74,7 +74,7 @@ class ShowUpdater(): if curShow.should_update(update_date=update_date) or curShow.indexerid in stale_should_update: try: piList.append(sickbeard.showQueueScheduler.action.updateShow(curShow, True)) # @UndefinedVariable - except exceptions.CantUpdateException as e: + except CantUpdateShowException as e: logger.log("Unable to update show: {0}".format(str(e)),logger.DEBUG) else: logger.log( @@ -82,13 +82,13 @@ class ShowUpdater(): logger.DEBUG) piList.append(sickbeard.showQueueScheduler.action.refreshShow(curShow, True)) # @UndefinedVariable - except (exceptions.CantUpdateException, exceptions.CantRefreshException), e: + except (CantUpdateShowException, CantRefreshShowException), e: logger.log(u"Automatic update failed: " + ex(e), logger.ERROR) ui.ProgressIndicators.setIndicator('dailyUpdate', ui.QueueProgressIndicator("Daily Update", piList)) logger.log(u"Completed full update on all shows") - + self.amActive = False def __del__(self): diff --git a/sickbeard/show_queue.py b/sickbeard/show_queue.py index a92af691fd873ce943e7a6509917e77d746a6433..86da31a79a9e4dccd1fd7e6a9bd46de4bd70f1b4 100644 --- a/sickbeard/show_queue.py +++ b/sickbeard/show_queue.py @@ -25,16 +25,18 @@ import sickbeard from imdb import _exceptions as imdb_exceptions from sickbeard.common import WANTED from sickbeard.tv import TVShow -from sickbeard import exceptions from sickbeard import logger from sickbeard import notifiers from sickbeard import ui from sickbeard import generic_queue from sickbeard import name_cache -from sickbeard.exceptions import ex from sickbeard.blackandwhitelist import BlackAndWhiteList +from sickrage.helper.exceptions import CantRefreshShowException, CantRemoveShowException, CantUpdateShowException +from sickrage.helper.exceptions import EpisodeDeletedException, ex, MultipleShowObjectsException +from sickrage.helper.exceptions import ShowDirectoryNotFoundException from libtrakt import TraktAPI + class ShowQueue(generic_queue.GenericQueue): def __init__(self): generic_queue.GenericQueue.__init__(self) @@ -82,15 +84,15 @@ class ShowQueue(generic_queue.GenericQueue): def updateShow(self, show, force=False): if self.isBeingAdded(show): - raise exceptions.CantUpdateException( + raise CantUpdateShowException( str(show.name) + u" is still being added, wait until it is finished before you update.") if self.isBeingUpdated(show): - raise exceptions.CantUpdateException( + raise CantUpdateShowException( str(show.name) + u" is already being updated by Post-processor or manually started, can't update again until it's done.") if self.isInUpdateQueue(show): - raise exceptions.CantUpdateException( + raise CantUpdateShowException( str(show.name) + u" is in process of being updated by Post-processor or manually started, can't update again until it's done.") if not force: @@ -105,7 +107,7 @@ class ShowQueue(generic_queue.GenericQueue): def refreshShow(self, show, force=False): if self.isBeingRefreshed(show) and not force: - raise exceptions.CantRefreshException("This show is already being refreshed, not refreshing again.") + raise CantRefreshShowException("This show is already being refreshed, not refreshing again.") if (self.isBeingUpdated(show) or self.isInUpdateQueue(show)) and not force: logger.log( @@ -152,7 +154,7 @@ class ShowQueue(generic_queue.GenericQueue): def removeShow(self, show, full=False): if self._isInQueue(show, ShowQueueActions.REMOVE): - raise sickbeard.exceptions.CantRemoveException("This show is already queued to be removed") + raise CantRemoveShowException("This show is already queued to be removed") # remove other queued actions for this show. for x in self.queue: @@ -380,7 +382,7 @@ class QueueItemAdd(ShowQueueItem): self._finishEarly() return - except exceptions.MultipleShowObjectsException: + except MultipleShowObjectsException: logger.log(u"The show in " + self.showDir + " is already in your show list, skipping", logger.WARNING) ui.notifications.error('Show skipped', "The show in " + self.showDir + " is already in your show list") self._finishEarly() @@ -510,7 +512,7 @@ class QueueItemRename(ShowQueueItem): try: show_loc = self.show.location - except exceptions.ShowDirNotFoundException: + except ShowDirectoryNotFoundException: logger.log(u"Can't perform rename on " + self.show.name + " when the show dir is missing.", logger.WARNING) return @@ -623,7 +625,7 @@ class QueueItemUpdate(ShowQueueItem): curEp = self.show.getEpisode(curSeason, curEpisode) try: curEp.deleteEpisode() - except exceptions.EpisodeDeletedException: + except EpisodeDeletedException: pass # save show again, in case episodes have changed @@ -638,11 +640,13 @@ class QueueItemUpdate(ShowQueueItem): sickbeard.showQueueScheduler.action.refreshShow(self.show, self.force) self.finish() + class QueueItemForceUpdate(QueueItemUpdate): def __init__(self, show=None): ShowQueueItem.__init__(self, ShowQueueActions.FORCEUPDATE, show) self.force = True + class QueueItemRemove(ShowQueueItem): def __init__(self, show=None, full=False): ShowQueueItem.__init__(self, ShowQueueActions.REMOVE, show) diff --git a/sickbeard/subtitles.py b/sickbeard/subtitles.py index 3ad8e467873a67e20a2447c216951f2041e87272..3bb9cc2e4c70d23ef0548c70510750d97836d168 100644 --- a/sickbeard/subtitles.py +++ b/sickbeard/subtitles.py @@ -19,11 +19,11 @@ import datetime import sickbeard from sickbeard.common import * -from sickbeard.exceptions import ex from sickbeard import logger from sickbeard import db from sickrage.helper.common import dateTimeFormat from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex import subliminal import babelfish import subprocess diff --git a/sickbeard/traktChecker.py b/sickbeard/traktChecker.py index f19dc994df320713cd7aa8ef7079d230cbce2e8c..7d0d4e11ef0a20e30ede2e12e4a481c091f3120b 100644 --- a/sickbeard/traktChecker.py +++ b/sickbeard/traktChecker.py @@ -21,7 +21,6 @@ import traceback import datetime import sickbeard -from sickbeard.exceptions import ex from sickbeard import logger from sickbeard import helpers from sickbeard import search_queue @@ -31,6 +30,7 @@ from sickbeard.common import SKIPPED from sickbeard.common import UNKNOWN from sickbeard.common import WANTED from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex from common import Quality from libtrakt import * from libtrakt.exceptions import traktException diff --git a/sickbeard/tv.py b/sickbeard/tv.py index d7329b217501e3fd65671f265f24ddc9b6b18df8..31059dfd32fa319e0f92415d50a7896f80955bb0 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -28,7 +28,10 @@ import traceback import sickbeard -import xml.etree.cElementTree as etree +try: + import xml.etree.cElementTree as etree +except ImportError: + import xml.etree.ElementTree as etree from name_parser.parser import NameParser, InvalidNameException, InvalidShowException @@ -41,8 +44,7 @@ except ImportError: from imdb import imdb from sickbeard import db -from sickbeard import helpers, exceptions, logger -from sickbeard.exceptions import ex +from sickbeard import helpers, logger from sickbeard import image_cache from sickbeard import notifiers from sickbeard import postProcessor @@ -54,6 +56,10 @@ from sickbeard import network_timezones from sickbeard.indexers.indexer_config import INDEXER_TVRAGE from sickrage.helper.common import dateTimeFormat from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import EpisodeDeletedException, EpisodeNotFoundException, ex +from sickrage.helper.exceptions import MultipleEpisodesInDatabaseException, MultipleShowsInDatabaseException +from sickrage.helper.exceptions import MultipleShowObjectsException, NoNFOException, ShowDirectoryNotFoundException +from sickrage.helper.exceptions import ShowNotFoundException from dateutil.tz import * from common import Quality, Overview, statusStrings @@ -118,7 +124,7 @@ class TVShow(object): otherShow = helpers.findCertainShow(sickbeard.showList, self.indexerid) if otherShow != None: - raise exceptions.MultipleShowObjectsException("Can't create a show if it already exists") + raise MultipleShowObjectsException("Can't create a show if it already exists") self.loadFromDB() @@ -184,7 +190,7 @@ class TVShow(object): if ek(os.path.isdir, self._location): return self._location else: - raise exceptions.ShowDirNotFoundException("Show folder doesn't exist, you shouldn't be using it") + raise ShowDirectoryNotFoundException("Show folder doesn't exist, you shouldn't be using it") def _setLocation(self, newLocation): logger.log(u"Setter sets location to " + newLocation, logger.DEBUG) @@ -193,7 +199,7 @@ class TVShow(object): dirty_setter("_location")(self, newLocation) self._isDirGood = True else: - raise exceptions.NoNFOException("Invalid folder for the show!") + raise NoNFOException("Invalid folder for the show!") location = property(_getLocation, _setLocation) @@ -424,10 +430,10 @@ class TVShow(object): logger.log(str(self.indexerid) + u": Creating episode from " + mediaFile, logger.DEBUG) try: curEpisode = self.makeEpFromFile(ek(os.path.join, self._location, mediaFile)) - except (exceptions.ShowNotFoundException, exceptions.EpisodeNotFoundException), e: + except (ShowNotFoundException, EpisodeNotFoundException), e: logger.log(u"Episode " + mediaFile + " returned an exception: " + ex(e), logger.ERROR) continue - except exceptions.EpisodeDeletedException: + except EpisodeDeletedException: logger.log(u"The episode deleted itself when I tried making an object for it", logger.DEBUG) if curEpisode is None: @@ -517,7 +523,7 @@ class TVShow(object): try: curEp = self.getEpisode(curSeason, curEpisode) if not curEp: - raise exceptions.EpisodeNotFoundException + raise EpisodeNotFoundException # if we found out that the ep is no longer on TVDB then delete it from our database too if deleteEp: @@ -526,7 +532,7 @@ class TVShow(object): curEp.loadFromDB(curSeason, curEpisode) curEp.loadFromIndexer(tvapi=t, cachedSeason=cachedSeasons[curSeason]) scannedEps[curSeason][curEpisode] = True - except exceptions.EpisodeDeletedException: + except EpisodeDeletedException: logger.log(u"Tried loading an episode from the DB that should have been deleted, skipping it", logger.DEBUG) continue @@ -572,14 +578,14 @@ class TVShow(object): try: ep = self.getEpisode(season, episode) if not ep: - raise exceptions.EpisodeNotFoundException - except exceptions.EpisodeNotFoundException: + raise EpisodeNotFoundException + except EpisodeNotFoundException: logger.log("%s: %s object for S%02dE%02d is incomplete, skipping this episode" % (self.indexerid, sickbeard.indexerApi(self.indexer).name, season, episode)) continue else: try: ep.loadFromIndexer(tvapi=t) - except exceptions.EpisodeDeletedException: + except EpisodeDeletedException: logger.log(u"The episode was deleted, skipping the rest of the load") continue @@ -665,8 +671,8 @@ class TVShow(object): try: curEp = self.getEpisode(season, episode, file) if not curEp: - raise exceptions.EpisodeNotFoundException - except exceptions.EpisodeNotFoundException: + raise EpisodeNotFoundException + except EpisodeNotFoundException: logger.log(str(self.indexerid) + u": Unable to figure out what this file is, skipping", logger.ERROR) continue @@ -770,7 +776,7 @@ class TVShow(object): sqlResults = myDB.select("SELECT * FROM tv_shows WHERE indexer_id = ?", [self.indexerid]) if len(sqlResults) > 1: - raise exceptions.MultipleDBShowsException() + raise MultipleShowsInDatabaseException() elif len(sqlResults) == 0: logger.log(str(self.indexerid) + ": Unable to find the show in the database") return @@ -1042,7 +1048,7 @@ class TVShow(object): (('Deleted', 'Trashed')[sickbeard.TRASH_REMOVE_SHOW], self._location)) - except exceptions.ShowDirNotFoundException: + except ShowDirectoryNotFoundException: logger.log(u"Show folder does not exist, no need to %s %s" % (action, self._location), logger.WARNING) except OSError, e: logger.log(u'Unable to %s %s: %s / %s' % (action, self._location, repr(e), str(e)), logger.WARNING) @@ -1081,8 +1087,8 @@ class TVShow(object): try: curEp = self.getEpisode(season, episode) if not curEp: - raise exceptions.EpisodeDeletedException - except exceptions.EpisodeDeletedException: + raise EpisodeDeletedException + except EpisodeDeletedException: logger.log(u"The episode was deleted while we were refreshing it, moving on to the next one", logger.DEBUG) continue @@ -1566,19 +1572,19 @@ class TVEpisode(object): if ek(os.path.isfile, self.location): try: self.loadFromNFO(self.location) - except exceptions.NoNFOException: + except NoNFOException: logger.log(u"%s: There was an error loading the NFO for episode S%02dE%02d" % (self.show.indexerid, season, episode), logger.ERROR) # if we tried loading it from NFO and didn't find the NFO, try the Indexers if not self.hasnfo: try: result = self.loadFromIndexer(season, episode) - except exceptions.EpisodeDeletedException: + except EpisodeDeletedException: result = False # if we failed SQL *and* NFO, Indexers then fail if not result: - raise exceptions.EpisodeNotFoundException("Couldn't find episode S%02dE%02d" % (season, episode)) + raise EpisodeNotFoundException("Couldn't find episode S%02dE%02d" % (season, episode)) def loadFromDB(self, season, episode): logger.log(u"%s: Loading episode details from DB for episode %s S%02dE%02d" % (self.show.indexerid, self.show.name, season, episode), logger.DEBUG) @@ -1588,7 +1594,7 @@ class TVEpisode(object): [self.show.indexerid, season, episode]) if len(sqlResults) > 1: - raise exceptions.MultipleDBEpisodesException("Your DB has two records for the same show somehow.") + raise MultipleEpisodesInDatabaseException("Your DB has two records for the same show somehow.") elif len(sqlResults) == 0: logger.log(u"%s: Episode S%02dE%02d not found in the database" % (self.show.indexerid, self.season, self.episode), logger.DEBUG) return False @@ -1847,7 +1853,7 @@ class TVEpisode(object): logger.log( u"Failed to rename your episode's NFO file - you need to delete it or fix it: " + ex(e), logger.ERROR) - raise exceptions.NoNFOException("Error in NFO format") + raise NoNFOException("Error in NFO format") for epDetails in showXML.getiterator('episodedetails'): if epDetails.findtext('season') is None or int(epDetails.findtext('season')) != self.season or \ @@ -1858,7 +1864,7 @@ class TVEpisode(object): continue if epDetails.findtext('title') is None or epDetails.findtext('aired') is None: - raise exceptions.NoNFOException("Error in NFO format (missing episode title or airdate)") + raise NoNFOException("Error in NFO format (missing episode title or airdate)") self.name = epDetails.findtext('title') self.episode = int(epDetails.findtext('episode')) @@ -1958,7 +1964,7 @@ class TVEpisode(object): self.season) + " AND episode=" + str(self.episode) myDB.action(sql) - raise exceptions.EpisodeDeletedException() + raise EpisodeDeletedException() def get_sql(self, forceSave=False): """ diff --git a/sickbeard/tvcache.py b/sickbeard/tvcache.py index a7ed5ee91cee84000ebf349fc57d0e6aa86415c5..fcfa20fea0eacc1707340e49f72399126e1b361c 100644 --- a/sickbeard/tvcache.py +++ b/sickbeard/tvcache.py @@ -29,12 +29,11 @@ from sickbeard import db from sickbeard import logger from sickbeard.common import Quality from sickbeard import helpers -from sickbeard.exceptions import ex -from sickbeard.exceptions import AuthException from sickbeard.rssfeeds import RSSFeeds from name_parser.parser import NameParser, InvalidNameException, InvalidShowException from sickbeard import show_name_helpers from sickrage.helper.encoding import ss +from sickrage.helper.exceptions import AuthException, ex class CacheDBConnection(db.DBConnection): diff --git a/sickbeard/versionChecker.py b/sickbeard/versionChecker.py index dc60962d9b375bf0600805a77969de3031227b46..e49d2eaddfaa0f764dba6ba2a3de8a39008020bc 100644 --- a/sickbeard/versionChecker.py +++ b/sickbeard/versionChecker.py @@ -31,8 +31,8 @@ import sickbeard from sickbeard import notifiers from sickbeard import ui from sickbeard import logger, helpers -from sickbeard.exceptions import ex from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex import requests import shutil @@ -103,7 +103,7 @@ class CheckVersion: ui.notifications.message('Backup', 'Config backup failed, aborting update') return False except Exception as e: - logger.log('Update: Config backup failed. Error: {0}'.format(ex(e)),logger.ERROR) + logger.log('Update: Config backup failed. Error: %s' % ex(e), logger.ERROR) ui.notifications.message('Backup', 'Config backup failed, aborting update') return False @@ -217,6 +217,7 @@ class CheckVersion: else: return 'downgrade' except Exception: + raise return 'error' def find_install_type(self): @@ -579,7 +580,7 @@ class GitUpdateManager(UpdateManager): output, err, exit_status = self._run_git(self._git_path, 'checkout -f ' + self.branch) # @UnusedVariable if exit_status == 0: - output, err, exit_status = self._run_git(self._git_path, 'submodule update --init --recursive --force') + output, err, exit_status = self._run_git(self._git_path, 'submodule update --init --recursive') if exit_status == 0: self._find_installed_version() diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index ea72436c942bf3f53710a2112a5c4404e55f79a3..4659f5db1489bfcef009b79fc40ee8126758cb3b 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -29,6 +29,7 @@ import traceback import sickbeard from sickrage.helper.common import dateFormat, dateTimeFormat, timeFormat from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import CantUpdateShowException, ex, ShowDirectoryNotFoundException from sickrage.helper.quality import get_quality_string from sickrage.media.ShowFanArt import ShowFanArt from sickrage.media.ShowNetworkLogo import ShowNetworkLogo @@ -41,13 +42,12 @@ from sickrage.system.Restart import Restart from sickrage.system.Shutdown import Shutdown from versionChecker import CheckVersion -from sickbeard import db, logger, exceptions, ui, helpers +from sickbeard import db, logger, ui, helpers from sickbeard import search_queue from sickbeard import image_cache from sickbeard import classes from sickbeard import processTV from sickbeard import network_timezones, sbdatetime -from sickbeard.exceptions import ex from sickbeard.common import DOWNLOADED from sickbeard.common import FAILED from sickbeard.common import IGNORED @@ -739,7 +739,7 @@ class CMD_Episode(ApiCall): showPath = None try: showPath = showObj.location - except sickbeard.exceptions.ShowDirNotFoundException: + except ShowDirectoryNotFoundException: pass if bool(self.fullPath) == True and showPath: @@ -1844,7 +1844,7 @@ class CMD_Show(ApiCall): try: showDict["location"] = showObj.location - except sickbeard.exceptions.ShowDirNotFoundException: + except ShowDirectoryNotFoundException: showDict["location"] = "" showDict["language"] = showObj.lang @@ -2730,7 +2730,7 @@ class CMD_ShowUpdate(ApiCall): try: sickbeard.showQueueScheduler.action.updateShow(showObj, True) # @UndefinedVariable return _responds(RESULT_SUCCESS, msg=str(showObj.name) + " has queued to be updated") - except exceptions.CantUpdateException as e: + except CantUpdateShowException as e: logger.log("API::Unable to update show: {0}".format(str(e)),logger.DEBUG) return _responds(RESULT_FAILURE, msg="Unable to update " + str(showObj.name)) diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index a40d30a7bb051f86b0495dcc4b4c03e735e61286..c0e3e1d0d81c7e84c739c6c05c9260844be507bd 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -29,7 +29,7 @@ from sickbeard import config, sab from sickbeard import clients from sickbeard import notifiers, processTV from sickbeard import ui -from sickbeard import logger, helpers, exceptions, classes, db +from sickbeard import logger, helpers, classes, db from sickbeard import search_queue from sickbeard import naming from sickbeard import subtitles @@ -38,7 +38,6 @@ from sickbeard.providers import newznab, rsstorrent from sickbeard.common import Quality, Overview, statusStrings, qualityPresetStrings, cpu_presets from sickbeard.common import SNATCHED, UNAIRED, IGNORED, ARCHIVED, WANTED, FAILED, SKIPPED from sickbeard.common import SD, HD720p, HD1080p -from sickbeard.exceptions import ex from sickbeard.blackandwhitelist import BlackAndWhiteList, short_group_names from sickbeard.browser import foldersAtPath from sickbeard.scene_numbering import get_scene_numbering, set_scene_numbering, get_scene_numbering_for_show, \ @@ -53,6 +52,8 @@ import adba from libtrakt import TraktAPI from libtrakt.exceptions import traktException from sickrage.helper.encoding import ek, ss +from sickrage.helper.exceptions import CantRefreshShowException, CantUpdateShowException, ex +from sickrage.helper.exceptions import MultipleShowObjectsException, NoNFOException, ShowDirectoryNotFoundException from sickrage.media.ShowBanner import ShowBanner from sickrage.media.ShowFanArt import ShowFanArt from sickrage.media.ShowNetworkLogo import ShowNetworkLogo @@ -1167,7 +1168,7 @@ class Home(WebRoot): try: showLoc = (showObj.location, True) - except sickbeard.exceptions.ShowDirNotFoundException: + except ShowDirectoryNotFoundException: showLoc = (showObj._location, False) show_message = '' @@ -1410,7 +1411,7 @@ class Home(WebRoot): showObj.flatten_folders = flatten_folders try: sickbeard.showQueueScheduler.action.refreshShow(showObj) - except exceptions.CantRefreshException, e: + except CantRefreshShowException, e: errors.append("Unable to refresh this show: " + ex(e)) showObj.paused = paused @@ -1440,12 +1441,12 @@ class Home(WebRoot): showObj.location = location try: sickbeard.showQueueScheduler.action.refreshShow(showObj) - except exceptions.CantRefreshException, e: + except CantRefreshShowException, e: errors.append("Unable to refresh this show:" + ex(e)) # grab updated info from TVDB # showObj.loadEpisodesFromIndexer() # rescan the episodes in the new folder - except exceptions.NoNFOException: + except NoNFOException: errors.append( "The folder at <tt>%s</tt> doesn't contain a tvshow.nfo - copy your files to that folder before you change the directory in SickRage." % location) @@ -1457,21 +1458,21 @@ class Home(WebRoot): try: sickbeard.showQueueScheduler.action.updateShow(showObj, True) time.sleep(cpu_presets[sickbeard.CPU_PRESET]) - except exceptions.CantUpdateException as e: + except CantUpdateShowException as e: errors.append("Unable to update show: {0}".format(str(e))) if do_update_exceptions: try: sickbeard.scene_exceptions.update_scene_exceptions(showObj.indexerid, exceptions_list) # @UndefinedVdexerid) time.sleep(cpu_presets[sickbeard.CPU_PRESET]) - except exceptions.CantUpdateException, e: + except CantUpdateShowException, e: errors.append("Unable to force an update on scene exceptions of the show.") if do_update_scene_numbering: try: sickbeard.scene_numbering.xem_refresh(showObj.indexerid, showObj.indexer) time.sleep(cpu_presets[sickbeard.CPU_PRESET]) - except exceptions.CantUpdateException, e: + except CantUpdateShowException, e: errors.append("Unable to force an update on scene numbering of the show.") if directCall: @@ -1541,7 +1542,7 @@ class Home(WebRoot): # force the update try: sickbeard.showQueueScheduler.action.updateShow(showObj, bool(force)) - except exceptions.CantUpdateException, e: + except CantUpdateShowException, e: ui.notifications.error("Unable to update this show.", ex(e)) # just give it some time @@ -1778,7 +1779,7 @@ class Home(WebRoot): try: show_loc = showObj.location # @UnusedVariable - except exceptions.ShowDirNotFoundException: + except ShowDirectoryNotFoundException: return self._genericMessage("Error", "Can't rename episodes when the show dir is missing.") ep_obj_rename_list = [] @@ -1824,7 +1825,7 @@ class Home(WebRoot): try: show_loc = show_obj.location # @UnusedVariable - except exceptions.ShowDirNotFoundException: + except ShowDirectoryNotFoundException: return self._genericMessage("Error", "Can't rename episodes when the show dir is missing.") if eps is None: @@ -2391,7 +2392,7 @@ class HomeAddShows(Home): else: trending_shows += [show] - except exceptions.MultipleShowObjectsException: + except MultipleShowObjectsException: continue if sickbeard.TRAKT_BLACKLIST_NAME != '': @@ -2445,7 +2446,7 @@ class HomeAddShows(Home): else: trending_shows += [show] - except exceptions.MultipleShowObjectsException: + except MultipleShowObjectsException: continue if sickbeard.TRAKT_BLACKLIST_NAME != '': @@ -3331,7 +3332,7 @@ class Manage(Home, WebRoot): try: sickbeard.showQueueScheduler.action.updateShow(showObj, True) updates.append(showObj.name) - except exceptions.CantUpdateException, e: + except CantUpdateShowException, e: errors.append("Unable to update show: {0}".format(str(e))) # don't bother refreshing shows that were updated anyway @@ -3339,7 +3340,7 @@ class Manage(Home, WebRoot): try: sickbeard.showQueueScheduler.action.refreshShow(showObj) refreshes.append(showObj.name) - except exceptions.CantRefreshException, e: + except CantRefreshShowException, e: errors.append("Unable to refresh show " + showObj.name + ": " + ex(e)) if curShowID in toRename: diff --git a/sickrage/helper/exceptions.py b/sickrage/helper/exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..f3e92fa7f5ea97d313db0f5c47f10021b6ba360e --- /dev/null +++ b/sickrage/helper/exceptions.py @@ -0,0 +1,139 @@ +# This file is part of SickRage. +# +# URL: https://www.sickrage.tv +# Git: https://github.com/SiCKRAGETV/SickRage.git +# +# SickRage is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SickRage is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SickRage. If not, see <http://www.gnu.org/licenses/>. + +from sickrage.helper.encoding import ss + + +def ex(e): + """ + :param e: The exception to convert into a unicode string + :return: A unicode string from the exception text if it exists + """ + + message = u'' + + if not e or not e.args: + return message + + for arg in e.args: + if arg is not None: + if isinstance(arg, (str, unicode)): + fixed_arg = ss(arg) + else: + try: + fixed_arg = u'error %s' % ss(str(arg)) + except Exception: + fixed_arg = None + + if fixed_arg: + if not message: + message = fixed_arg + else: + message = '%s : %s' % (message, fixed_arg) + + return message + + +class SickRageException(Exception): + """ + Generic SickRage Exception - should never be thrown, only sub-classed + """ + + +class AuthException(SickRageException): + """ + Your authentication information are incorrect + """ + + +class CantRefreshShowException(SickRageException): + """ + The show can't be refreshed right now + """ + + +class CantRemoveShowException(SickRageException): + """ + The show can't removed right now + """ + + +class CantUpdateShowException(SickRageException): + """ + The show can't be updated right now + """ + + +class EpisodeDeletedException(SickRageException): + """ + This episode has been deleted + """ + + +class EpisodeNotFoundException(SickRageException): + """ + The episode wasn't found on the Indexer + """ + + +class EpisodePostProcessingFailedException(SickRageException): + """ + The episode post-processing failed + """ + + +class FailedPostProcessingFailedException(SickRageException): + """ + The failed post-processing failed + """ + + +class MultipleEpisodesInDatabaseException(SickRageException): + """ + Multiple episodes were found in the database! The database must be fixed first + """ + + +class MultipleShowsInDatabaseException(SickRageException): + """ + Multiple shows were found in the database! The database must be fixed first + """ + + +class MultipleShowObjectsException(SickRageException): + """ + Multiple objects for the same show were found! Something is very wrong + """ + + +class NoNFOException(SickRageException): + """ + No NFO was found + """ + + +class ShowDirectoryNotFoundException(SickRageException): + """ + The show directory was not found + """ + + +class ShowNotFoundException(SickRageException): + """ + The show wasn't found on the Indexer + """ diff --git a/sickrage/media/GenericMedia.py b/sickrage/media/GenericMedia.py index 43b5a10c892b2b1670a3326f5b14c833799ecaa3..076db3ba82ae2017301e549986db4d1cba4ce0ac 100644 --- a/sickrage/media/GenericMedia.py +++ b/sickrage/media/GenericMedia.py @@ -21,9 +21,9 @@ import sickbeard from abc import abstractmethod from mimetypes import guess_type from os.path import isfile, join, normpath -from sickbeard.exceptions import MultipleShowObjectsException from sickbeard.helpers import findCertainShow from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import MultipleShowObjectsException class GenericMedia: diff --git a/sickrage/show/Show.py b/sickrage/show/Show.py index 4784fa0a60095add8159ba8608b5ad5ed1c4e5e1..a574ecdac49715ce96c2d9ef8ef430909bf017f4 100644 --- a/sickrage/show/Show.py +++ b/sickrage/show/Show.py @@ -18,8 +18,9 @@ import sickbeard -from sickbeard.exceptions import CantRefreshException, CantRemoveException, ex, MultipleShowObjectsException from sickbeard.helpers import findCertainShow +from sickrage.helper.exceptions import CantRefreshShowException, CantRemoveShowException, ex +from sickrage.helper.exceptions import MultipleShowObjectsException class Show: @@ -44,7 +45,7 @@ class Show: try: sickbeard.showQueueScheduler.action.removeShow(show, bool(remove_files)) - except CantRemoveException as exception: + except CantRemoveShowException as exception: return ex(exception), show return None, show @@ -91,7 +92,7 @@ class Show: try: sickbeard.showQueueScheduler.action.refreshShow(show) - except CantRefreshException as exception: + except CantRefreshShowException as exception: return ex(exception), show return None, show diff --git a/tests/encoding_tests.py b/tests/encoding_tests.py index fddb33e4f58c4dbb0694db7e15042d36726b2cb7..0caf4b3e8317d849a1416142b18b68d24bc57398 100644 --- a/tests/encoding_tests.py +++ b/tests/encoding_tests.py @@ -8,9 +8,9 @@ sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '../l sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) import sickbeard -from sickbeard.exceptions import ex from sickbeard.helpers import sanitizeFileName from sickrage.helper.encoding import ek +from sickrage.helper.exceptions import ex class EncodingTests(unittest.TestCase): diff --git a/tests/issue_submitter_tests.py b/tests/issue_submitter_tests.py index 0337a212e745315622410861bd1e14fd4953699d..36d1bfe28a5c57c95587fb35a42691476be999b6 100644 --- a/tests/issue_submitter_tests.py +++ b/tests/issue_submitter_tests.py @@ -21,20 +21,20 @@ from __future__ import with_statement import unittest import sys, os.path -from configobj import ConfigObj + +from sickbeard import logger +from sickrage.helper.exceptions import ex sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '../lib'))) sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -import sickbeard -import test_lib as test def error(): try: raise Exception('FAKE EXCEPTION') except Exception as e: - sickbeard.logger.log("FAKE ERROR: " + sickbeard.exceptions.ex(e), sickbeard.logger.ERROR) - sickbeard.logger.submit_errors() + logger.log("FAKE ERROR: " + ex(e), logger.ERROR) + logger.submit_errors() raise diff --git a/tests/ssl_sni_tests.py b/tests/ssl_sni_tests.py index ac6452fbaeb75d5a97363e367ff124dbcc1a1a7b..88303cc8cdcd1683983c81d7d64451aee06f1de7 100644 --- a/tests/ssl_sni_tests.py +++ b/tests/ssl_sni_tests.py @@ -25,7 +25,8 @@ sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '..') import requests import sickbeard.providers as providers import certifi -from sickbeard.exceptions import ex +from sickrage.helper.exceptions import ex + class SNI_Tests(unittest.TestCase): def test_SNI_URLS(self): diff --git a/tests/test_lib.py b/tests/test_lib.py index 04238bf8a3de846c56821a709a5b4443701ea468..fa6c10c934a118640d6bb5654b49ca0b822024e8 100644 --- a/tests/test_lib.py +++ b/tests/test_lib.py @@ -20,7 +20,6 @@ from __future__ import with_statement import unittest -import sqlite3 from configobj import ConfigObj import sys, os.path @@ -209,7 +208,8 @@ def tearDown_test_db(): # os.remove(file_name) # except Exception as e: # print 'ERROR: Failed to remove ' + file_name -# print ex(e) +# print exception(e) + def setUp_test_episode_file(): if not os.path.exists(FILEDIR):