[ao3] detect member-only and adult works (#6013)
This commit is contained in:
@@ -116,7 +116,17 @@ class Ao3WorkExtractor(Ao3Extractor):
|
|||||||
|
|
||||||
work_id = self.groups[0]
|
work_id = self.groups[0]
|
||||||
url = "{}/works/{}".format(self.root, work_id)
|
url = "{}/works/{}".format(self.root, work_id)
|
||||||
extr = text.extract_from(self.request(url).text)
|
response = self.request(url, notfound="work")
|
||||||
|
|
||||||
|
if response.url.endswith("/users/login?restricted=true"):
|
||||||
|
raise exception.AuthorizationError(
|
||||||
|
"Login required to access member-only works")
|
||||||
|
page = response.text
|
||||||
|
if len(page) < 20000 and \
|
||||||
|
'<h2 class="landmark heading">Adult Content Warning</' in page:
|
||||||
|
raise exception.StopExtraction("Adult Content")
|
||||||
|
|
||||||
|
extr = text.extract_from(page)
|
||||||
|
|
||||||
chapters = {}
|
chapters = {}
|
||||||
cindex = extr(' id="chapter_index"', "</ul>")
|
cindex = extr(' id="chapter_index"', "</ul>")
|
||||||
|
|||||||
Reference in New Issue
Block a user