1
0
Fork 0
mirror of https://github.com/kemayo/leech synced 2026-01-04 06:39:12 +01:00

Better error message for restricted AO3 stories

This commit is contained in:
David Lynch 2021-03-21 23:17:29 -05:00
parent 73df5d5cb3
commit dfa298dd3b

View file

@ -5,7 +5,7 @@ import datetime
import re
import requests_cache
from bs4 import BeautifulSoup
from . import register, Site, Section, Chapter
from . import register, Site, Section, Chapter, SiteException
logger = logging.getLogger(__name__)
@ -32,7 +32,7 @@ class ArchiveOfOurOwn(Site):
'user[remember_me]': '1',
'utf8': form.find(attrs={'name': 'utf8'})['value'],
'authenticity_token': form.find(attrs={'name': 'authenticity_token'})['value'],
'commit': 'Log In',
'commit': 'Log in',
}
# I feel the session *should* handle this cookies bit for me. But
# it doesn't. And I don't know why.
@ -52,6 +52,9 @@ class ArchiveOfOurOwn(Site):
logger.info("Extracting full work @ %s", url)
soup = self._soup(url)
if not soup.find(id='workskin'):
raise SiteException("Can't find the story text; you may need to log in or flush the cache")
story = Section(
title=soup.select('#workskin > .preface .title')[0].text.strip(),
author=soup.select('#workskin .preface .byline a')[0].text.strip(),