From d52024eabef146b6a87ce2ba68141dcf8c4a9b35 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Sat, 10 Feb 2018 11:04:19 +0100 Subject: [PATCH 1/2] Fix API endpoints for sg.exceptions and exceptions. --- sickbeard/webapi.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index 979de401..f1c7a6d6 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -1409,14 +1409,22 @@ class CMD_SickGearExceptions(ApiCall): """ display scene exceptions for all or a given show """ myDB = db.DBConnection(row_type="dict") - if self.indexerid == None: - sqlResults = myDB.select("SELECT show_name, indexer_id AS 'indexerid' FROM scene_exceptions") + if self.indexerid is None: + sqlResults = myDB.select("SELECT s.indexer, se.show_name, se.indexer_id AS 'indexerid' " + "FROM scene_exceptions AS se INNER JOIN tv_shows as s " + "ON se.indexer_id == s.indexer_id") scene_exceptions = {} for row in sqlResults: indexerid = row["indexerid"] - if not indexerid in scene_exceptions: - scene_exceptions[indexerid] = [] - scene_exceptions[indexerid].append(row["show_name"]) + indexer = row["indexer"] + if self.sickbeard_call: + if indexerid not in scene_exceptions: + scene_exceptions[indexerid] = [] + scene_exceptions[indexerid].append(row["show_name"]) + else: + if indexerid not in scene_exceptions.get(indexer, {}): + scene_exceptions.setdefault(indexer, {})[indexerid] = [] + scene_exceptions.setdefault(indexer, {})[indexerid].append(row["show_name"]) else: showObj = helpers.find_show_by_id(sickbeard.showList, {self.indexer: self.indexerid}) From d9e03aa1fb603df2f3b95b5e712d3fff8baf27b3 Mon Sep 17 00:00:00 2001 From: JackDandy Date: Wed, 18 Apr 2018 13:52:01 +0100 Subject: [PATCH 2/2] Change improve searching torrent provider BTScene. Change improve text for abandoned show IDs. Change DRY refactor provider result creation. Change catch failures to shutdown Emby socket. --- CHANGES.md | 8 +++++++- gui/slick/interfaces/default/history.tmpl | 2 +- sickbeard/notifiers/emby.py | 5 ++++- sickbeard/providers/btscene.py | 16 +++++++++++++++- sickbeard/providers/ettv.py | 11 +---------- sickbeard/providers/generic.py | 12 +++++++++++- sickbeard/providers/pisexy.py | 9 --------- sickbeard/providers/potuk.py | 9 --------- sickbeard/webserve.py | 9 ++++++--- 9 files changed, 45 insertions(+), 36 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6dd7e0a1..d9d70559 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,10 @@ -### 0.15.12 (2018-04-17 14:10:00 UTC) +### 0.15.13 (2018-04-18 13:50:00 UTC) + +* Fix API endpoints for sg.exceptions and exceptions +* Change improve searching torrent provider BTScene + + +### 0.15.12 (2018-04-17 14:10:00 UTC) * Fix ETTV torrent provider diff --git a/gui/slick/interfaces/default/history.tmpl b/gui/slick/interfaces/default/history.tmpl index 0952d089..3f4f674e 100644 --- a/gui/slick/interfaces/default/history.tmpl +++ b/gui/slick/interfaces/default/history.tmpl @@ -462,7 +462,7 @@
  1. Install the SickGear repo to access its Kodi Add-on
      -
    • in Filemanager, add a source for SickGear with <ip>:<port>/kodi/ (e.g. 192.168.0.10:$sg_port/kodi/)
      +
    • in Filemanager, add a source with <ip>:<port>/kodi/ (e.g. http://192.168.0.10:$sg_port/kodi/)
      and name it for example, SickGear. You will need to allow Unknown Sources if not already
    • in System/Add-ons, "Install from zip file", in the folder list, select the SickGear source
    • select the repository.sickgear in the folder listing, and install the repository zip
      diff --git a/sickbeard/notifiers/emby.py b/sickbeard/notifiers/emby.py index 28ed9c51..d7069736 100644 --- a/sickbeard/notifiers/emby.py +++ b/sickbeard/notifiers/emby.py @@ -103,7 +103,10 @@ class EmbyNotifier(Notifier): except (StandardError, Exception): pass if not sock_issue: - cs.shutdown(SHUT_RDWR) + try: + cs.shutdown(SHUT_RDWR) + except (StandardError, Exception): + pass return result def _check_config(self, hosts=None, apikeys=None): diff --git a/sickbeard/providers/btscene.py b/sickbeard/providers/btscene.py index 8229e055..46519893 100644 --- a/sickbeard/providers/btscene.py +++ b/sickbeard/providers/btscene.py @@ -65,7 +65,7 @@ class BTSceneProvider(generic.TorrentProvider): 'mPblqN2ctQnY', 'vlWduM2 YPtU', 'nYoRXahZPm L', '15PSZuV2 YzR', 'WYrN 2PbsJmb', '==wZ y9mL sx']], ]]] - self.url_vars = {'search': '?q=%s&category=series&order=1', 'browse': 'lastdaycat/type/Series/', + self.url_vars = {'search': '?q=%s&order=1', 'browse': 'lastdaycat/type/Series/', 'get': 'torrentdownload.php?id=%s'} self.url_tmpl = {'config_provider_home_uri': '%(home)s', 'search': '%(vars)s', 'browse': '%(home)s%(vars)s', 'get': '%(home)s%(vars)s'} @@ -165,5 +165,19 @@ class BTSceneProvider(generic.TorrentProvider): def _episode_strings(self, ep_obj, **kwargs): return super(BTSceneProvider, self)._episode_strings(ep_obj, sep_date='.', **kwargs) + def get_data(self, url): + result = None + resp = self.get_url(url, timeout=90) + if self.should_skip(): + return result + + try: + result = resp + if re.search('(?i)\s+html', resp[0:30]): + result = re.findall('(?i)"(magnet:[^"]+?)"', resp)[0] + except IndexError: + pass + return result + provider = BTSceneProvider() diff --git a/sickbeard/providers/ettv.py b/sickbeard/providers/ettv.py index 87b5a905..0d5e9ee7 100644 --- a/sickbeard/providers/ettv.py +++ b/sickbeard/providers/ettv.py @@ -134,19 +134,10 @@ class ETTVProvider(generic.TorrentProvider): return result try: - result = re.findall('(?i)"(magnet:[^"]+?)">', html)[0] + result = re.findall('(?i)"(magnet:[^"]+?)"', html)[0] except IndexError: logger.log('Failed no magnet in response', logger.DEBUG) return result - def get_result(self, episodes, url): - result = None - - if url: - result = super(ETTVProvider, self).get_result(episodes, url) - result.get_data_func = self.get_data - - return result - provider = ETTVProvider() diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py index a92410d2..4d733d17 100644 --- a/sickbeard/providers/generic.py +++ b/sickbeard/providers/generic.py @@ -668,7 +668,7 @@ class GenericProvider(object): cache_file = ek.ek(os.path.join, cache_dir, base_name) self.session.headers['Referer'] = url - if cached or helpers.download_file(url, cache_file, session=self.session): + if cached or helpers.download_file(url, cache_file, session=self.session, allow_redirects='/it' not in url): if self._verify_download(cache_file): logger.log(u'Downloaded %s result from %s' % (self.name, url)) @@ -1675,3 +1675,13 @@ class TorrentProvider(GenericProvider): self.ping_skip = ((60*60)/self.ping_freq, None)[self._authorised()] self._sleep_with_stop(self.ping_freq) + + def get_result(self, episodes, url): + result = None + + if url: + result = super(TorrentProvider, self).get_result(episodes, url) + if hasattr(self, 'get_data'): + result.get_data_func = self.get_data + + return result diff --git a/sickbeard/providers/pisexy.py b/sickbeard/providers/pisexy.py index 7b78a02c..4e1516c8 100644 --- a/sickbeard/providers/pisexy.py +++ b/sickbeard/providers/pisexy.py @@ -121,14 +121,5 @@ class PiSexyProvider(generic.TorrentProvider): logger.log('Failed no torrent in response', logger.DEBUG) return result - def get_result(self, episodes, url): - result = None - - if url: - result = super(PiSexyProvider, self).get_result(episodes, url) - result.get_data_func = self.get_data - - return result - provider = PiSexyProvider() diff --git a/sickbeard/providers/potuk.py b/sickbeard/providers/potuk.py index c0ae0849..9bda91ac 100644 --- a/sickbeard/providers/potuk.py +++ b/sickbeard/providers/potuk.py @@ -146,15 +146,6 @@ class PotUKProvider(generic.TorrentProvider): logger.log('Failed no torrent in response', logger.DEBUG) return result - def get_result(self, episodes, url): - result = None - - if url: - result = super(PotUKProvider, self).get_result(episodes, url) - result.get_data_func = self.get_data - - return result - def ui_string(self, key): return ('%s_digest' % self.get_id()) == key and 'use... \'bbuserid=xx; bbpassword=yy\'' or '' diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 71283dc9..7ce5034c 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -1732,7 +1732,8 @@ class Home(MainHandler): last_found = ('', ' since %s' % sbdatetime.sbdatetime.fromordinal( showObj.last_found_on_indexer).sbfdate())[1 < showObj.last_found_on_indexer] show_message = ( - 'The master ID of this show has been abandoned%s, ' % last_found + 'The master ID of this show has been abandoned%s, ' % last_found + 'replace it here' % ( sickbeard.WEB_ROOT, show, show) + ('', '
      %s' % show_message)[0 < len(show_message)]) @@ -2206,8 +2207,10 @@ class Home(MainHandler): # noinspection PyUnresolvedReferences last_found = ('', ' since %s' % sbdatetime.sbdatetime.fromordinal( showObj.last_found_on_indexer).sbfdate())[1 < showObj.last_found_on_indexer] - show_message = 'The master ID of this show has been abandoned%s
      search for ' % last_found + \ - 'a replacement in the "Related show IDs" section of the "Other" tab' + show_message = ( + 'The master ID of this show has been abandoned%s' % last_found + + '
      search for a replacement in the "Related show IDs" section of the "Other" tab') t.show_message = show_message