From 15b3a02edb533a704dec2ed2c850d1a363cacc5f Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Tue, 29 Aug 2017 11:02:02 -0500 Subject: [PATCH] Add delays for base_xenforoforum_adapter. --- calibre-plugin/plugin-defaults.ini | 6 ++++++ fanficfare/adapters/base_xenforoforum_adapter.py | 14 ++++++++++++++ fanficfare/defaults.ini | 6 ++++++ 3 files changed, 26 insertions(+) diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index 737320a2..b076fd67 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -463,6 +463,12 @@ add_to_extra_titlepage_entries:,storynotes [base_xenforoforum] +## We've been requested by the site(s) admin to rein in hits. If you +## download fewer stories less often you can likely get by with +## reducing this sleep. There's also a hard-coded 2sec sleep in +## addition to whatever slow_down_sleep_time is. +slow_down_sleep_time:4 + ## exclude emoji and default avatars. cover_exclusion_regexp:(/styles/|xenforo/avatars/avatar.*\.png) diff --git a/fanficfare/adapters/base_xenforoforum_adapter.py b/fanficfare/adapters/base_xenforoforum_adapter.py index 5dc7be91..abe1df92 100644 --- a/fanficfare/adapters/base_xenforoforum_adapter.py +++ b/fanficfare/adapters/base_xenforoforum_adapter.py @@ -84,6 +84,20 @@ class BaseXenForoForumAdapter(BaseSiteAdapter): ## need to accept http and https still. return re.escape(self.getURLPrefix()).replace("https","https?")+r"/(?Pthreads|posts)/(.+\.)?(?P\d+)/?[^#]*?(#post-(?P\d+))?$" + def _fetchUrlOpened(self, url, + parameters=None, + usecache=True, + extrasleep=2.0, + referer=None): + ## We've been requested by the site(s) admin to rein in hits. + ## This is in additional to what ever the slow_down_sleep_time + ## setting is. + return BaseSiteAdapter._fetchUrlOpened(self,url, + parameters=parameters, + usecache=usecache, + extrasleep=extrasleep, + referer=referer) + ## For adapters, especially base_xenforoforum to override. Make ## sure to return unchanged URL if it's NOT a chapter URL. This ## is most helpful for xenforoforum because threadmarks use diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index 8fa9264f..9ebc33cb 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -478,6 +478,12 @@ add_to_extra_titlepage_entries:,storynotes [base_xenforoforum] +## We've been requested by the site(s) admin to rein in hits. If you +## download fewer stories less often you can likely get by with +## reducing this sleep. There's also a hard-coded 2sec sleep in +## addition to whatever slow_down_sleep_time is. +slow_down_sleep_time:4 + ## exclude emoji and default avatars. cover_exclusion_regexp:(/styles/|xenforo/avatars/avatar.*\.png)