diff --git a/CHANGES.md b/CHANGES.md index 2c06b1f..beec02c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,9 @@ -### 0.21.46 (2020-09-16 20:00:00 UTC) +### 0.21.47 (2020-09-xx xx:xx:00 UTC) + +* Change add warning to logs for enabled providers where `cf_clearance` cookie is missing + + +### 0.21.46 (2020-09-16 20:00:00 UTC) * Fix TorrentDay and IPTorrents. Important: user must add browser cookie `cf_clearance` to provider 'Cookies' setting. If `cf_clearance` not found in browser, log out, delete site cookies, refresh browser, `cf_clearance` will be created. diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py index 9aa888d..a9a6b47 100644 --- a/sickbeard/providers/generic.py +++ b/sickbeard/providers/generic.py @@ -1291,21 +1291,36 @@ class GenericProvider(object): cookies = self.cookies if not (cookies and re.match(r'^(?:\w+=[^;\s]+[;\s]*)+$', cookies)): - return False + return False, None + + if self.enabled: + ui_string_method = getattr(self, 'ui_string', None) + if callable(ui_string_method): + pid = self.get_id() + # `cookie_str_only` prevents circular call via _valid_home() in ui_string_method + key = ('%s_digest' % pid, 'cookie_str_only')[ + pid in ('ptfiles', 'scenetime', 'torrentday', 'torrentleech')] + reqd = 'cf_clearance' + if reqd in ui_string_method(key) and reqd not in cookies: + return False, \ + u'%(p)s Cookies setting require %(r)s. If %(r)s not found in browser, log out,' \ + u' delete site cookies, refresh browser, %(r)s should be created' % \ + dict(p=self.name, r='\'%s\'' % reqd) cj = requests.utils.add_dict_to_cookiejar(self.session.cookies, dict([x.strip().split('=') for x in cookies.split(';') if '' != x])), for item in cj: if not isinstance(item, requests.cookies.RequestsCookieJar): - return False + return False, None - return True + return True, None def _check_cookie(self): - if self.check_auth_cookie(): - return True, None + success, err_msg = self.check_auth_cookie() + if success or (not success and err_msg): + return success, err_msg return False, 'Cookies not correctly formatted key=value pairs e.g. uid=xx;pass=yy)' @@ -1789,7 +1804,7 @@ class TorrentProvider(GenericProvider): success, msg = self._check_cookie() if not success: self.cookies = None - logger.log(u'%s: [%s]' % (msg, self.cookies), logger.WARNING) + logger.log(u'%s' % msg, logger.WARNING) return url_base = getattr(self, 'url_base', None) diff --git a/sickbeard/providers/ptf.py b/sickbeard/providers/ptf.py index 3a05d1a..22a0365 100644 --- a/sickbeard/providers/ptf.py +++ b/sickbeard/providers/ptf.py @@ -154,11 +154,13 @@ class PTFProvider(generic.TorrentProvider): return results def ui_string(self, key): + cookies = 'use... \'session_key=xx\'' + if 'cookie_str_only' == key: + return cookies if 'ptfiles_digest' == key and self._valid_home(): current_url = getattr(self, 'urls', {}).get('config_provider_home_uri') - return ('use... \'session_key=xx\'' + - (current_url and (' from a session logged in at %s' % - (anon_url(current_url), current_url.strip('/'))) or '')) + return (cookies + (current_url and (' from a session logged in at %s' % + (anon_url(current_url), current_url.strip('/'))) or '')) return '' diff --git a/sickbeard/providers/scenetime.py b/sickbeard/providers/scenetime.py index a637688..7478283 100644 --- a/sickbeard/providers/scenetime.py +++ b/sickbeard/providers/scenetime.py @@ -160,11 +160,13 @@ class SceneTimeProvider(generic.TorrentProvider): return results def ui_string(self, key): + cookies = 'use... \'uid=xx; pass=yy\'' + if 'cookie_str_only' == key: + return cookies if 'scenetime_digest' == key and self._valid_home(): current_url = getattr(self, 'urls', {}).get('config_provider_home_uri') - return ('use... \'uid=xx; pass=yy\'' + - (current_url and (' from a session logged in at %s' % - (anon_url(current_url), current_url.strip('/'))) or '')) + return (cookies + (current_url and (' from a session logged in at %s' % + (anon_url(current_url), current_url.strip('/'))) or '')) return '' diff --git a/sickbeard/providers/torrentday.py b/sickbeard/providers/torrentday.py index 076a1d1..2a558cd 100644 --- a/sickbeard/providers/torrentday.py +++ b/sickbeard/providers/torrentday.py @@ -165,11 +165,13 @@ class TorrentDayProvider(generic.TorrentProvider): return super(TorrentDayProvider, self)._episode_strings(ep_obj, sep_date='.', date_or=True, **kwargs) def ui_string(self, key): + cookies = 'use... \'uid=xx; pass=yy; cf_clearance=zz\'' + if 'cookie_str_only' == key: + return cookies if 'torrentday_digest' == key and self._valid_home(): current_url = getattr(self, 'urls', {}).get('config_provider_home_uri') - return ('use... \'uid=xx; pass=yy; cf_clearance=zz\'' + - (current_url and ('
from a session logged in at %s' % - (anon_url(current_url), current_url.strip('/'))) or '')) + return (cookies + (current_url and ('
from a session logged in at %s' % + (anon_url(current_url), current_url.strip('/'))) or '')) return '' diff --git a/sickbeard/providers/torrentleech.py b/sickbeard/providers/torrentleech.py index e0b4ce7..cf43955 100644 --- a/sickbeard/providers/torrentleech.py +++ b/sickbeard/providers/torrentleech.py @@ -150,7 +150,10 @@ class TorrentLeechProvider(generic.TorrentProvider): return super(TorrentLeechProvider, self)._episode_strings(ep_obj, sep_date='|', **kwargs) def ui_string(self, key): - return 'torrentleech_digest' == key and self._valid_home() and 'use... \'tluid=xx; tlpass=yy\'' or '' + cookies = 'use... \'tluid=xx; tlpass=yy\'' + if 'cookie_str_only' == key: + return cookies + return 'torrentleech_digest' == key and self._valid_home() and cookies or '' provider = TorrentLeechProvider() diff --git a/sickbeard/rssfeeds.py b/sickbeard/rssfeeds.py index 0f9fd03..7acf37e 100644 --- a/sickbeard/rssfeeds.py +++ b/sickbeard/rssfeeds.py @@ -15,7 +15,10 @@ class RSSFeeds(object): def get_feed(self, url, **kwargs): - if self.provider and self.provider.check_auth_cookie(): + if self.provider: + success, err_msg = self.provider.check_auth_cookie() + if not success: + return response = self.provider.get_url(url, **kwargs) if not self.provider.should_skip() and response: try: