diff --git a/gui/slick/interfaces/default/inc_top.tmpl b/gui/slick/interfaces/default/inc_top.tmpl index 3c2bce53b60caea47066456b74654a009334fd43..44edefcc4dc731690e5031e3d2b480ee8efa5f10 100644 --- a/gui/slick/interfaces/default/inc_top.tmpl +++ b/gui/slick/interfaces/default/inc_top.tmpl @@ -102,7 +102,7 @@ \$("#SubMenu a:contains('Trim History')").addClass('btn trimhistory').html('<span class="ui-icon ui-icon-trash pull-left"></span> Trim History'); \$("#SubMenu a[href$='/errorlogs/clearerrors/']").addClass('btn').html('<span class="ui-icon ui-icon-trash pull-left"></span> Clear Errors'); #if sickbeard.GIT_USERNAME and sickbeard.GIT_PASSWORD: - \$("#SubMenu a[href$='/errorlogs/submit_errors/']").addClass('btn').html('<span class="ui-icon ui-icon-arrowreturnthick-1-n pull-left"></span> Submit Errors'); + \$("#SubMenu a[href$='/errorlogs/submit_errors/']").addClass('btn submiterrors').html('<span class="ui-icon ui-icon-arrowreturnthick-1-n pull-left"></span> Submit Errors'); #end if \$("#SubMenu a:contains('Re-scan')").addClass('btn').html('<span class="ui-icon ui-icon-refresh pull-left"></span> Re-scan'); \$("#SubMenu a:contains('Backlog Overview')").addClass('btn').html('<span class="ui-icon ui-icon-refresh pull-left"></span> Backlog Overview'); diff --git a/gui/slick/js/confirmations.js b/gui/slick/js/confirmations.js index 66f38c03177cc4bff5ff462f3e2b10b90ae4d86e..3b6e77471b046f5011743e8e5311355a63966ed7 100644 --- a/gui/slick/js/confirmations.js +++ b/gui/slick/js/confirmations.js @@ -105,5 +105,25 @@ $(document).ready(function () { } }); }); - -}); \ No newline at end of file + + $('a.submiterrors').bind("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">You should trigger 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/lib/feedparser/feedparser.py b/lib/feedparser/feedparser.py index 97f2a7f2bf3c3e9cfeb6a9040ac3038c449fbbe9..9e80c7cbb035b6e87c167134cb8221da74a5b726 100644 --- a/lib/feedparser/feedparser.py +++ b/lib/feedparser/feedparser.py @@ -3674,7 +3674,10 @@ def parse(url_file_stream_or_string, etag=None, modified=None, agent=None, refer if f and data and http_headers: if gzip and 'gzip' in http_headers.get('content-encoding', ''): try: - data = gzip.GzipFile(fileobj=_StringIO(data)).read() + attempts = 0 + while(data[0] == '\x1f' and data[1] == '\x8b' and attempts < 3): + attempts += 1 + data = gzip.GzipFile(fileobj=_StringIO(data)).read() except (IOError, struct.error), e: # IOError can occur if the gzip header is bad. # struct.error can occur if the data is damaged. diff --git a/sickbeard/db.py b/sickbeard/db.py index 2df18e5d493637821602901c2ef207ed70017663..798a319b5e65f3d474eabcf93329592f4bc7050a 100644 --- a/sickbeard/db.py +++ b/sickbeard/db.py @@ -57,12 +57,7 @@ class DBConnection(object): db_locks[self.filename] = threading.Lock() self.connection = sqlite3.connect(dbFilename(self.filename, self.suffix), 20, check_same_thread=False) - - # Lets test without this for awhile. If non-unicode data is getting to the DB, fix it at the source. - # There are too many places we convert when we don't need to, - # sqlite, browsers, python, everything understands unicode - - #self.connection.text_factory = self._unicode_text_factory + self.connection.text_factory = self._unicode_text_factory db_cons[self.filename] = self.connection else: @@ -235,27 +230,10 @@ class DBConnection(object): def _unicode_text_factory(self, x): try: - # Already unicode, empty string, or ascii - x = unicode(x) - except Exception: - try: - # most common encoding from web - x = unicode(x, 'utf-8') - except Exception: - try: - # most common from web if utf-8 fails - x = unicode(x, 'latin-1') - except Exception: - try: - # try system encoding before trusting chardet - x = unicode(x, sickbeard.SYS_ENCODING) - except Exception: - try: - # Chardet can be wrong, so try it last before ignoring - x = unicode(x, chardet.detect(x).get('encoding')) - except Exception: - x = unicode(x, sickbeard.SYS_ENCODING, errors="ignore") - return x + # Just revert to the old code for now, until we can fix unicode + return unicode(x, 'utf-8') + except: + return unicode(x, sickbeard.SYS_ENCODING,errors="ignore") def _dict_factory(self, cursor, row): d = {} diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index ccbe9686e377424713739e70d93dbfb3b236fd31..aaf1be330f66a871f73a10ac98407b290abb353f 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -50,6 +50,19 @@ import xmltodict import subprocess +try: + from io import BytesIO as _StringIO +except ImportError: + try: + from cStringIO import StringIO as _StringIO + except ImportError: + from StringIO import StringIO as _StringIO + +try: + import gzip +except ImportError: + gzip = None + from sickbeard.exceptions import MultipleShowObjectsException, ex from sickbeard import logger, classes from sickbeard.common import USER_AGENT, cpu_presets, mediaExtensions, subtitleExtensions @@ -1382,6 +1395,11 @@ def getURL(url, post_data=None, params={}, headers={}, timeout=30, session=None, logger.log(traceback.format_exc(), logger.WARNING) return + attempts = 0 + while(gzip and resp.content[0] == '\x1f' and resp.content[1] == '\x8b' and attempts < 3): + attempts += 1 + resp._content = gzip.GzipFile(fileobj=_StringIO(resp.content)).read() + return resp.content if not json else resp.json() diff --git a/sickbeard/providers/hdtorrents.py b/sickbeard/providers/hdtorrents.py index 73062435395af162e52d73536d1515bb0d6378ba..1989fbc43ea316b37ecc181a50c055dfd747a12e 100644 --- a/sickbeard/providers/hdtorrents.py +++ b/sickbeard/providers/hdtorrents.py @@ -121,7 +121,7 @@ class HDTorrentsProvider(generic.TorrentProvider): def _get_episode_search_strings(self, ep_obj, add_string=''): if not ep_obj: - return search_strings + return [] search_strings = [] for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py index 93c58d6ef3290e1b42c0f8db92819063611cbc37..2e229ff9badb51ad87c29beb4cf45d4709ab09aa 100644 --- a/sickbeard/providers/thepiratebay.py +++ b/sickbeard/providers/thepiratebay.py @@ -239,7 +239,7 @@ class ThePirateBayProvider(generic.TorrentProvider): if not data: continue - re_title_url = self.proxy._buildRE(self.re_title_url) + re_title_url = self.proxy._buildRE(self.re_title_url).replace('&f=norefer', '') matches = re.compile(re_title_url, re.DOTALL).finditer(urllib.unquote(data)) for torrent in matches: title = torrent.group('title').replace('_', diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index b6d1d11bcfd9f9e2fe27cce515b8e23adddd1786..9ce1076fd44e54b1d2717f54d3e3d06621589212 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -5047,7 +5047,7 @@ class ErrorLogs(WebRoot): def ErrorLogsMenu(self): menu = [ {'title': 'Clear Errors', 'path': 'errorlogs/clearerrors/'}, - {'title': 'Submit Errors', 'path': 'errorlogs/submit_errors/', 'requires': self.haveErrors}, + {'title': 'Submit Errors', 'path': 'errorlogs/submit_errors/', 'requires': self.haveErrors, 'confirm': True}, ] return menu