From 7872b250347fa2862e3e9dd50af4515d570cbc22 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Mon, 23 Dec 2013 17:45:08 -0500 Subject: [PATCH] Minor tweak to ffnet fix in case they change it back, sleep on ffnet meta lookup. --- fanficdownloader/adapters/adapter_fanfictionnet.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fanficdownloader/adapters/adapter_fanfictionnet.py b/fanficdownloader/adapters/adapter_fanfictionnet.py index 5be9ef7..c16ab6b 100644 --- a/fanficdownloader/adapters/adapter_fanfictionnet.py +++ b/fanficdownloader/adapters/adapter_fanfictionnet.py @@ -72,6 +72,13 @@ class FanFictionNetSiteAdapter(BaseSiteAdapter): def getSiteURLPattern(self): return r"https?://(www|m)?\.fanfiction\.net/s/\d+(/\d+)?(/|/[^/]+)?/?$" + def _fetchUrl(self,url): + time.sleep(1.0) ## ffnet(and, I assume, fpcom) tends to fail + ## more if hit too fast. This is in + ## additional to what ever the + ## slow_down_sleep_time setting is. + return BaseSiteAdapter._fetchUrl(self,url) + def extractChapterUrlsAndMetadata(self): # fetch the chapter. From that we will get almost all the @@ -157,7 +164,7 @@ class FanFictionNetSiteAdapter(BaseSiteAdapter): - a = soup.find('a', href='https://www.fictionratings.com/') + a = soup.find('a', href=re.compile(r'https?://www\.fictionratings\.com/')) rating = a.string if 'Fiction' in rating: # if rating has 'Fiction ', strip that out for consistency with past. rating = rating[8:] @@ -275,7 +282,7 @@ class FanFictionNetSiteAdapter(BaseSiteAdapter): return def getChapterText(self, url): - time.sleep(5.0) ## ffnet(and, I assume, fpcom) tends to fail + time.sleep(4.0) ## ffnet(and, I assume, fpcom) tends to fail ## more if hit too fast. This is in ## additional to what ever the ## slow_down_sleep_time setting is.