diff --git a/calibre-plugin/fff_plugin.py b/calibre-plugin/fff_plugin.py index fb45988..4f3b785 100644 --- a/calibre-plugin/fff_plugin.py +++ b/calibre-plugin/fff_plugin.py @@ -528,7 +528,8 @@ class FanFicFarePlugin(InterfaceAction): def get_urls_from_page(self,url): logger.debug("get_urls_from_page URL:%s"%url) - if 'archiveofourown.org' in url: + ## some sites hide mature links unless logged in. + if 'archiveofourown.org' in url or 'fimfiction.net' in url: configuration = get_fff_config(url) else: configuration = None diff --git a/fanficfare/adapters/adapter_buffynfaithnet.py b/fanficfare/adapters/adapter_buffynfaithnet.py index 4b402db..ab371bc 100644 --- a/fanficfare/adapters/adapter_buffynfaithnet.py +++ b/fanficfare/adapters/adapter_buffynfaithnet.py @@ -127,7 +127,7 @@ class BuffyNFaithNetAdapter(BaseSiteAdapter): comment_url=None, rest={'HttpOnly': None}, rfc2109=False) - self.cookiejar.set_cookie(cookie) + self.get_cookiejar().set_cookie(cookie) self.setHeader() try: diff --git a/fanficfare/adapters/adapter_fimfictionnet.py b/fanficfare/adapters/adapter_fimfictionnet.py index 38eccee..f01d2aa 100644 --- a/fanficfare/adapters/adapter_fimfictionnet.py +++ b/fanficfare/adapters/adapter_fimfictionnet.py @@ -68,23 +68,26 @@ class FimFictionNetSiteAdapter(BaseSiteAdapter): this and change it to True. ''' return True + + def set_adult_cookie(self): + cookie = cl.Cookie(version=0, name='view_mature', value='true', + port=None, port_specified=False, + domain=self.getSiteDomain(), domain_specified=False, domain_initial_dot=False, + path='/', path_specified=True, + secure=False, + expires=time.time()+10000, + discard=False, + comment=None, + comment_url=None, + rest={'HttpOnly': None}, + rfc2109=False) + self.get_cookiejar().set_cookie(cookie) def doExtractChapterUrlsAndMetadata(self,get_cover=True): if self.is_adult or self.getConfig("is_adult"): - cookie = cl.Cookie(version=0, name='view_mature', value='true', - port=None, port_specified=False, - domain=self.getSiteDomain(), domain_specified=False, domain_initial_dot=False, - path='/story', path_specified=True, - secure=False, - expires=time.time()+10000, - discard=False, - comment=None, - comment_url=None, - rest={'HttpOnly': None}, - rfc2109=False) - self.cookiejar.set_cookie(cookie) - + self.set_adult_cookie() + ##--------------------------------------------------------------------------------------------------- ## Get the story's title page. Check if it exists. diff --git a/fanficfare/adapters/adapter_portkeyorg.py b/fanficfare/adapters/adapter_portkeyorg.py index 549a8f0..85e573d 100644 --- a/fanficfare/adapters/adapter_portkeyorg.py +++ b/fanficfare/adapters/adapter_portkeyorg.py @@ -106,7 +106,7 @@ class PortkeyOrgAdapter(BaseSiteAdapter): # XXX comment_url=None, rest={'HttpOnly': None}, rfc2109=False) - self.cookiejar.set_cookie(cookie) + self.get_cookiejar().set_cookie(cookie) try: data = self._fetchUrl(url) diff --git a/fanficfare/geturls.py b/fanficfare/geturls.py index 9a7434c..feff4b5 100644 --- a/fanficfare/geturls.py +++ b/fanficfare/geturls.py @@ -60,6 +60,10 @@ def get_urls_from_page(url,configuration=None,normalize=False): # login the session. adapter.performLogin(url,data) # get the list page with logged in session. + + if 'fimfiction.net' in url and adapter.getConfig("is_adult"): + data = adapter._fetchUrl(url) + adapter.set_adult_cookie() # this way it uses User-Agent or other special settings. Only AO3 # is doing login.