From 56401e6dfa2ae6f4914ec0a00a20a03e06630dbd Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Fri, 10 Jun 2016 09:52:02 -0500 Subject: [PATCH] Allow old showpost.php chapter URLs in base_xenforoforum. --- fanficfare/adapters/base_xenforoforum_adapter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fanficfare/adapters/base_xenforoforum_adapter.py b/fanficfare/adapters/base_xenforoforum_adapter.py index 995e36e..e7684d0 100644 --- a/fanficfare/adapters/base_xenforoforum_adapter.py +++ b/fanficfare/adapters/base_xenforoforum_adapter.py @@ -228,11 +228,15 @@ class BaseXenForoForumAdapter(BaseSiteAdapter): if ( url.startswith(self.getURLPrefix()) or url.startswith('http://'+self.getSiteDomain()) or - url.startswith('https://'+self.getSiteDomain()) ) and ('/posts/' in url or '/threads/' in url): + url.startswith('https://'+self.getSiteDomain()) ) and \ + ( '/posts/' in url or '/threads/' in url or 'showpost.php' in url): # brute force way to deal with SB's http->https change when hardcoded http urls. url = url.replace('http://'+self.getSiteDomain(),self.getURLPrefix()) + # http://forums.spacebattles.com/showpost.php?p=4755532&postcount=9 + url = re.sub(r'showpost\.php\?p=([0-9]+)(&postcount=[0-9]+)?',r'/posts/\1/',url) + url = re.sub(r'(^[\'"]+|[\'"]+$)','',url) # strip leading or trailing '" from incorrect quoting. url = re.sub(r'like$','',url) # strip 'like' if incorrect 'like' link instead of proper post URL.