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:
parent
73df5d5cb3
commit
dfa298dd3b
1 changed files with 5 additions and 2 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue