mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2025-12-23 09:14:18 +01:00
Abstract stripURLParameters into the adapters for coming buffynfaithnet adapter.
This commit is contained in:
parent
3346f0962c
commit
1346e9bc7a
3 changed files with 10 additions and 6 deletions
|
|
@ -108,7 +108,6 @@ import adapter_jlaunlimitedcom
|
|||
import adapter_qafficcom
|
||||
import adapter_efpfanficnet
|
||||
|
||||
|
||||
## This bit of complexity allows adapters to be added by just adding
|
||||
## importing. It eliminates the long if/else clauses we used to need
|
||||
## to pick out the adapter.
|
||||
|
|
@ -172,10 +171,6 @@ def getClassFor(url):
|
|||
## remove any trailing '#' locations.
|
||||
fixedurl = re.sub(r"#.*$","",fixedurl)
|
||||
|
||||
## remove any trailing '&' parameters--?sid=999 will be left.
|
||||
## that's all that any of the current adapters need or want.
|
||||
fixedurl = re.sub(r"&.*$","",fixedurl)
|
||||
|
||||
parsedUrl = up.urlparse(fixedurl)
|
||||
domain = parsedUrl.netloc.lower()
|
||||
if( domain != parsedUrl.netloc ):
|
||||
|
|
@ -192,6 +187,8 @@ def getClassFor(url):
|
|||
cls = getClassFromList("www."+domain)
|
||||
fixedurl = fixedurl.replace("http://","http://www.")
|
||||
|
||||
fixedurl = cls.stripURLParameters(fixedurl)
|
||||
|
||||
return (cls,fixedurl)
|
||||
|
||||
def getClassFromList(domain):
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class SquidgeOrgPejaAdapter(BaseSiteAdapter):
|
|||
# The site domain. Does have www here, if it uses it.
|
||||
return 'www.squidge.org'
|
||||
|
||||
@classmethod # must be @staticmethod, don't remove it.
|
||||
@classmethod # must be @classmethod, don't remove it.
|
||||
def getConfigSection(cls):
|
||||
# The config section name. Only override if != site domain.
|
||||
return cls.getSiteDomain()+'/peja'
|
||||
|
|
|
|||
|
|
@ -255,6 +255,13 @@ class BaseSiteAdapter(Configurable):
|
|||
"Only needs to be overriden if != site domain."
|
||||
return cls.getSiteDomain()
|
||||
|
||||
@classmethod
|
||||
def stripURLParameters(cls,url):
|
||||
"Only needs to be overriden if URL contains more than one parameter"
|
||||
## remove any trailing '&' parameters--?sid=999 will be left.
|
||||
## that's all that any of the current adapters need or want.
|
||||
return re.sub(r"&.*$","",url)
|
||||
|
||||
## URL pattern validation is done *after* picking an adaptor based
|
||||
## on domain instead of *as* the adaptor selector so we can offer
|
||||
## the user example(s) for that particular site.
|
||||
|
|
|
|||
Loading…
Reference in a new issue