diff --git a/fanficdownloader/adapters/__init__.py b/fanficdownloader/adapters/__init__.py index 7d3117ed..c09b7d5d 100644 --- a/fanficdownloader/adapters/__init__.py +++ b/fanficdownloader/adapters/__init__.py @@ -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): diff --git a/fanficdownloader/adapters/adapter_squidgeorgpeja.py b/fanficdownloader/adapters/adapter_squidgeorgpeja.py index 6416d5f9..d4a39aa3 100644 --- a/fanficdownloader/adapters/adapter_squidgeorgpeja.py +++ b/fanficdownloader/adapters/adapter_squidgeorgpeja.py @@ -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' diff --git a/fanficdownloader/adapters/base_adapter.py b/fanficdownloader/adapters/base_adapter.py index 3cfc7ef4..8f051d4a 100644 --- a/fanficdownloader/adapters/base_adapter.py +++ b/fanficdownloader/adapters/base_adapter.py @@ -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.