mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-05-08 12:36:11 +02:00
Remove AO3 login rather that try to update with extra .json call for token.
This commit is contained in:
parent
993bd416a2
commit
bf5e95f4c0
5 changed files with 19 additions and 110 deletions
|
|
@ -993,17 +993,10 @@ website_encodings:Windows-1252,utf8,iso-8859-1
|
|||
website_encodings:Windows-1252,utf8
|
||||
|
||||
[archiveofourown.org]
|
||||
## Some sites require login (or login for some rated stories) The
|
||||
## program can prompt you, or you can save it in config. In
|
||||
## commandline version, this should go in your personal.ini, not
|
||||
## defaults.ini.
|
||||
#username:YourName
|
||||
#password:yourpassword
|
||||
|
||||
## In order to get bookmarktags and bookmarksummary, you need to login
|
||||
## all the time. This defaults to off to save time and network
|
||||
## traffic. Requires valid AO3 username and password when true.
|
||||
#always_login:false
|
||||
## AO3 login mechanism removed due to vastly increased complexity.
|
||||
## Rather than a token on the html page, AO3 changed to a scheme where
|
||||
## the on-page CSRF token is passed to a token_dispenser.json URL to
|
||||
## get the token then passed to login.
|
||||
|
||||
## Some sites also require the user to confirm they are adult for
|
||||
## adult content. In commandline version, this should go in your
|
||||
|
|
@ -1035,7 +1028,7 @@ website_encodings:Windows-1252,utf8
|
|||
## entry) as the composite offreeformtags, ao3categories in
|
||||
## include_in_genre. If there's ever more than 4 series, add
|
||||
## series04,series04Url etc.
|
||||
extra_valid_entries:fandoms,freeformtags,freefromtags,ao3categories,comments,kudos,hits,bookmarks,collections,byline,bookmarktags,bookmarksummary,series00,series01,series02,series03,series00Url,series01Url,series02Url,series03Url,series00HTML,series01HTML,series02HTML,series03HTML
|
||||
extra_valid_entries:fandoms,freeformtags,freefromtags,ao3categories,comments,kudos,hits,bookmarks,collections,byline,series00,series01,series02,series03,series00Url,series01Url,series02Url,series03Url,series00HTML,series01HTML,series02HTML,series03HTML
|
||||
fandoms_label:Fandoms
|
||||
freeformtags_label:Freeform Tags
|
||||
freefromtags_label:Freeform Tags
|
||||
|
|
@ -1046,10 +1039,6 @@ hits_label:Hits
|
|||
collections_label:Collections
|
||||
## Count of bookmarks on story by all users
|
||||
bookmarks_label:Bookmarks
|
||||
## Tags & Summary from *your* bookmark on the story. Only collected
|
||||
## if always_login:true
|
||||
bookmarktags_label:My Bookmark Tags
|
||||
bookmarksummary_label:My Bookmark Summary
|
||||
series00HTML_label:Series
|
||||
series01HTML_label:Additional Series
|
||||
series02HTML_label:Additional Series
|
||||
|
|
@ -1076,7 +1065,7 @@ include_in_category:fandoms
|
|||
include_in_freefromtags:freeformtags
|
||||
|
||||
## adds to titlepage_entries instead of replacing it.
|
||||
#extra_titlepage_entries: fandoms,freeformtags,ao3categories,comments,kudos,hits,bookmarks,bookmarktags,bookmarksummary,series01HTML,series02HTML,series03HTML,byline
|
||||
#extra_titlepage_entries: fandoms,freeformtags,ao3categories,comments,kudos,hits,bookmarks,series01HTML,series02HTML,series03HTML,byline
|
||||
|
||||
## adds to include_subject_tags instead of replacing it.
|
||||
#extra_subject_tags:fandoms,freeformtags,ao3categories
|
||||
|
|
|
|||
|
|
@ -92,38 +92,6 @@ class ArchiveOfOurOwnOrgAdapter(BaseSiteAdapter):
|
|||
else:
|
||||
return False
|
||||
|
||||
def performLogin(self, url, data):
|
||||
|
||||
params = {}
|
||||
if self.password:
|
||||
params['user_session[login]'] = self.username
|
||||
params['user_session[password]'] = self.password
|
||||
else:
|
||||
params['user_session[login]'] = self.getConfig("username")
|
||||
params['user_session[password]'] = self.getConfig("password")
|
||||
params['user_session[remember_me]'] = '1'
|
||||
params['commit'] = 'Log in'
|
||||
params['utf8'] = u'\x2713' # utf8 *is* required now. hex code works better than actual character for some reason. u'✓'
|
||||
|
||||
# token now comes from meta.
|
||||
# <meta name="csrf-token" content="/Li4mJ1w1AENhQq8EPVIklFwCDP5eaTHNRWPlWkehu2d1iuRzgsOHYGCX+uhjmlKnd1A9VisCdqmeTmBmXZkBg=="/>
|
||||
params['authenticity_token'] = data.split('meta name="csrf-token" content="')[1].split('"')[0]
|
||||
|
||||
loginUrl = 'https://' + self.getSiteDomain() + '/user_sessions'
|
||||
logger.info("Will now login to URL (%s) as (%s)" % (loginUrl,
|
||||
params['user_session[login]']))
|
||||
|
||||
d = self._postUrl(loginUrl, params)
|
||||
#logger.info(d)
|
||||
|
||||
if "Successfully logged in" not in d : #Member Account
|
||||
logger.info("Failed to login to URL %s as %s" % (loginUrl,
|
||||
params['user_session[login]']))
|
||||
raise exceptions.FailedToLogin(url,params['user_session[login]'])
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def use_pagecache(self):
|
||||
'''
|
||||
adapters that will work with the page cache need to implement
|
||||
|
|
@ -160,15 +128,13 @@ class ArchiveOfOurOwnOrgAdapter(BaseSiteAdapter):
|
|||
if "Sorry, we couldn't find the work you were looking for." in data:
|
||||
raise exceptions.StoryDoesNotExist(self.url)
|
||||
|
||||
# need to log in for this one, or always_login.
|
||||
if self.needToLoginCheck(data) or \
|
||||
( self.getConfig("always_login") and 'href="/logout"' not in data ):
|
||||
## except don't log in if already logged in (cached
|
||||
## responses in calibre job). already logged in if
|
||||
## there's no authenticity_token in data.
|
||||
self.performLogin(url,data)
|
||||
data = self._fetchUrl(url,usecache=False)
|
||||
meta = self._fetchUrl(metaurl,usecache=False)
|
||||
if self.needToLoginCheck(data):
|
||||
## AO3 login mechanism removed due to vastly increased
|
||||
## complexity. Rather than a token on the html page, AO3
|
||||
## changed to a scheme where the on-page CSRF token is
|
||||
## passed to a token_dispenser.json URL to get the token
|
||||
## then passed to login.
|
||||
raise exceptions.AccessDenied("AO3 doesn't allow download of (%s) without login and user/password login by automated tools such as FanFicFare is blocked by AO3 site." % self.url)
|
||||
|
||||
# use BeautifulSoup HTML parser to make everything easier to find.
|
||||
soup = self.make_soup(data)
|
||||
|
|
@ -184,15 +150,6 @@ class ArchiveOfOurOwnOrgAdapter(BaseSiteAdapter):
|
|||
a = soup.find('a', href=re.compile(r"/works/\d+$"))
|
||||
self.story.setMetadata('title',stripHTML(a))
|
||||
|
||||
if self.getConfig("always_login"):
|
||||
try:
|
||||
self.story.extendList('bookmarktags',
|
||||
metasoup.find('input',id='bookmark_tag_string')['value'].split(', '))
|
||||
except KeyError:
|
||||
pass
|
||||
self.story.setMetadata('bookmarksummary',
|
||||
stripHTML(metasoup.find('textarea',id='bookmark_notes')))
|
||||
|
||||
# Find authorid and URL from... author url.
|
||||
alist = soup.findAll('a', href=re.compile(r"/users/\w+/pseuds/\w+"))
|
||||
if len(alist) < 1: # ao3 allows for author 'Anonymous' with no author link.
|
||||
|
|
|
|||
|
|
@ -202,7 +202,6 @@ def get_valid_set_options():
|
|||
'include_author_notes':(['fimfiction.net'],None,boollist),
|
||||
'do_update_hook':(['fimfiction.net',
|
||||
'archiveofourown.org'],None,boollist),
|
||||
'always_login':(['archiveofourown.org'],None,boollist),
|
||||
'use_archived_author':(['archiveofourown.org'],None,boollist),
|
||||
'use_view_full_work':(['archiveofourown.org'],None,boollist),
|
||||
|
||||
|
|
@ -333,7 +332,6 @@ def get_valid_keywords():
|
|||
'do_update_hook',
|
||||
'use_archived_author',
|
||||
'use_view_full_work',
|
||||
'always_login',
|
||||
'exclude_notes',
|
||||
'exclude_editor_signature',
|
||||
'extra_logpage_entries',
|
||||
|
|
|
|||
|
|
@ -1015,17 +1015,10 @@ website_encodings:Windows-1252,utf8,iso-8859-1
|
|||
website_encodings:Windows-1252,utf8
|
||||
|
||||
[archiveofourown.org]
|
||||
## Some sites require login (or login for some rated stories) The
|
||||
## program can prompt you, or you can save it in config. In
|
||||
## commandline version, this should go in your personal.ini, not
|
||||
## defaults.ini.
|
||||
#username:YourName
|
||||
#password:yourpassword
|
||||
|
||||
## In order to get bookmarktags and bookmarksummary, you need to login
|
||||
## all the time. This defaults to off to save time and network
|
||||
## traffic. Requires valid AO3 username and password when true.
|
||||
#always_login:false
|
||||
## AO3 login mechanism removed due to vastly increased complexity.
|
||||
## Rather than a token on the html page, AO3 changed to a scheme where
|
||||
## the on-page CSRF token is passed to a token_dispenser.json URL to
|
||||
## get the token then passed to login.
|
||||
|
||||
## Some sites also require the user to confirm they are adult for
|
||||
## adult content. In commandline version, this should go in your
|
||||
|
|
@ -1057,7 +1050,7 @@ website_encodings:Windows-1252,utf8
|
|||
## entry) as the composite offreeformtags, ao3categories in
|
||||
## include_in_genre. If there's ever more than 4 series, add
|
||||
## series04,series04Url etc.
|
||||
extra_valid_entries:fandoms,freeformtags,freefromtags,ao3categories,comments,kudos,hits,bookmarks,collections,byline,bookmarktags,bookmarksummary,series00,series01,series02,series03,series00Url,series01Url,series02Url,series03Url,series00HTML,series01HTML,series02HTML,series03HTML
|
||||
extra_valid_entries:fandoms,freeformtags,freefromtags,ao3categories,comments,kudos,hits,bookmarks,collections,byline,series00,series01,series02,series03,series00Url,series01Url,series02Url,series03Url,series00HTML,series01HTML,series02HTML,series03HTML
|
||||
fandoms_label:Fandoms
|
||||
freeformtags_label:Freeform Tags
|
||||
freefromtags_label:Freeform Tags
|
||||
|
|
@ -1068,10 +1061,6 @@ hits_label:Hits
|
|||
collections_label:Collections
|
||||
## Count of bookmarks on story by all users
|
||||
bookmarks_label:Bookmarks
|
||||
## Tags & Summary from *your* bookmark on the story. Only collected
|
||||
## if always_login:true
|
||||
bookmarktags_label:My Bookmark Tags
|
||||
bookmarksummary_label:My Bookmark Summary
|
||||
series00HTML_label:Series
|
||||
series01HTML_label:Additional Series
|
||||
series02HTML_label:Additional Series
|
||||
|
|
@ -1098,7 +1087,7 @@ include_in_category:fandoms
|
|||
include_in_freefromtags:freeformtags
|
||||
|
||||
## adds to titlepage_entries instead of replacing it.
|
||||
#extra_titlepage_entries: fandoms,freeformtags,ao3categories,comments,kudos,hits,bookmarks,bookmarktags,bookmarksummary,series01HTML,series02HTML,series03HTML,byline
|
||||
#extra_titlepage_entries: fandoms,freeformtags,ao3categories,comments,kudos,hits,bookmarks,series01HTML,series02HTML,series03HTML,byline
|
||||
|
||||
## adds to include_subject_tags instead of replacing it.
|
||||
#extra_subject_tags:fandoms,freeformtags,ao3categories
|
||||
|
|
|
|||
|
|
@ -42,30 +42,6 @@ def get_urls_from_page(url,configuration=None,normalize=False):
|
|||
try:
|
||||
adapter = adapters.getAdapter(configuration,url,anyurl=True)
|
||||
|
||||
# special stuff to log into archiveofourown.org, if possible.
|
||||
# Unlike most that show the links to 'adult' stories, but protect
|
||||
# them, AO3 doesn't even show them if not logged in. Only works
|
||||
# with saved user/pass--not going to prompt for list.
|
||||
## Sept 2017 - AO3 doesn't appear to require view_adult or
|
||||
## login to see 'adult' links in list now.
|
||||
## 'Restricted' (user-only) stories/lists will not work. I
|
||||
## tried, but couldn't get login working from here for unknown
|
||||
## reasons.
|
||||
# if 'archiveofourown.org' in url:
|
||||
# if adapter.getConfig("username"):
|
||||
# if adapter.getConfig("is_adult"):
|
||||
# if '?' in url:
|
||||
# addurl = "&view_adult=true"
|
||||
# else:
|
||||
# addurl = "?view_adult=true"
|
||||
# else:
|
||||
# addurl=""
|
||||
# # just to get an authenticity_token.
|
||||
# data = adapter._fetchUrl(url+addurl)
|
||||
# # 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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue