Skip to content

Commit

Permalink
[ao3] parse 'series' metadata (#6013)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Sep 17, 2024
1 parent 6b8628b commit 064bc89
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions gallery_dl/extractor/ao3.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ def items(self):
}
data["language"] = util.code_to_language(data["lang"])

series = data["series"]
if series:
extr = text.extract_from(series)
data["series"] = {
"prev" : extr(' class="previous" href="/works/', '"'),
"index": extr(' class="position">Part ', " "),
"id" : extr(' href="/series/', '"'),
"name" : text.unescape(extr(">", "<")),
"next" : extr(' class="next" href="/works/', '"'),
}
else:
data["series"] = None

yield Message.Directory, data
for fmt in self.formats:
try:
Expand Down
8 changes: 8 additions & 0 deletions test/results/ao3.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
"lang" : "en",
"language" : "English",
"likes" : range(1000, 2000),
"series" : {
"id" : "4237024",
"prev" : "",
"next" : "57205801",
"index": "1",
"name" : "The Wildcard Universe",
},
"title" : "The Wildcard",
"views" : range(34000, 50000),
"words" : 217549,
Expand Down Expand Up @@ -172,6 +179,7 @@
"#category": ("", "ao3", "user-works"),
"#class" : ao3.Ao3UserWorksExtractor,
"#urls" : (
"https://archiveofourown.org/works/58979287",
"https://archiveofourown.org/works/55035061",
"https://archiveofourown.org/works/52704457",
"https://archiveofourown.org/works/52502743",
Expand Down

0 comments on commit 064bc89

Please sign in to comment.