diff --git a/package.json b/package.json
index e186658..7b94202 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@bobaboard/ao3.js",
- "version": "0.10.0",
+ "version": "0.11.0",
"description": "A NodeJS API for scraping AO3 data",
"type": "module",
"types": "./dist/index.d.ts",
diff --git a/src/series/getters.ts b/src/series/getters.ts
index 0d05030..bb9a725 100644
--- a/src/series/getters.ts
+++ b/src/series/getters.ts
@@ -1,7 +1,6 @@
import { Author, Series, SeriesWorkSummary } from "types/entities";
-import { SeriesPage, WorkPage } from "../page-loaders";
import { CheerioAPI, load } from "cheerio";
-import { getWorkDetailsFromUrl, getWorkUrl } from "src/urls";
+import { SeriesPage, WorkPage } from "../page-loaders";
import {
getWorkBookmarkCount,
getWorkHits,
@@ -11,6 +10,7 @@ import {
getWorkTotalChapters,
getWorkWordCount,
} from "src/works/work-getters";
+import { getWorkDetailsFromUrl, getWorkUrl } from "src/urls";
const monthMap: { [month: string]: string } = {
Jan: "01",
@@ -65,7 +65,7 @@ export const getSeriesDescription = (
export const getSeriesNotes = ($seriesPage: SeriesPage): string | null => {
const notes = $seriesPage("dl.series dd:nth-of-type(5)");
if (notes.prevAll().first().text().trim() === "Notes:") {
- return notes.html().trim();
+ return notes.html()!.trim();
} else {
return null;
}
@@ -136,7 +136,7 @@ const getSeriesWork = (workHtml: string): SeriesWorkSummary => {
const publishedChapters = getWorkPublishedChapters($$work);
const url = $work("a[href*='/works/']").attr("href") as string;
- const id = getWorkDetailsFromUrl({ url }).workId
+ const id = getWorkDetailsFromUrl({ url }).workId;
return {
id,
diff --git a/src/works/work-getters.ts b/src/works/work-getters.ts
index 9bfe1e6..dfde02c 100644
--- a/src/works/work-getters.ts
+++ b/src/works/work-getters.ts
@@ -152,9 +152,9 @@ export const getWorkSeries = ($workPage: WorkPage): BasicSeries[] => {
const link = seriesHtml.find("a:not(.next, .previous)");
series[index] = {
- id: link.attr("href").replace("/series/", ""),
+ id: link.attr("href")!.replace("/series/", ""),
name: link.text().trim(),
- index: matches.length > 0 ? parseInt(matches[0]) : -1,
+ index: matches!.length > 0 ? parseInt(matches![0]) : -1,
};
});
diff --git a/tests/mocks/data/series/1728802/index.html b/tests/mocks/data/series/1728802/index.html
new file mode 100644
index 0000000..28ddaa9
--- /dev/null
+++ b/tests/mocks/data/series/1728802/index.html
@@ -0,0 +1,487 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ angsty oneshots/short stories - Anonymous - Marvel Cinematic Universe, Spider-Man (Tom Holland Movies) [Archive of Our Own]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ While we've done our best to make the core functionality of this site accessible without javascript, it will work better with it enabled. Please consider turning it on!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+angsty oneshots/short stories
+
+
+
+
+
+
Series Metadata
+
+
+Creator:
+Anonymous
+Series Begun:
+2020-05-03
+Series Updated:
+2020-06-08
+Description:
+basically just peter whump lmao
+Stats:
+
+
+Words:
+24,722
+Works:
+3
+Complete:
+No
+Bookmarks:
+16
+
+
+
+
+
Listing Series
+
+
+
+
+
+Tags
+
+
+Summary
+
+Six days ago, Tony found Peter in that alley in Brooklyn, laying amongst the trashbags, beaten, and nearly dead.
AKA Peter is the victim of a violent crime outside of the suit and is left with a brain injury and no memory of the attack. It’s up to Tony to figure out what happened.
+
+Series
+
+
+
+Language:
+English
+Words:
+5,245
+Chapters:
+1/1
+Collections:
+1
+
+
+Kudos:
+484
+Bookmarks:
+67
+Hits:
+6,386
+
+
+
+
+
+
+Tags
+
+
+Summary
+
+After being brought back from the dead, Peter is still struggling to adjust. With Tony distant, a host of disheartening physical symptoms, and a newfound knowledge of the impermanence of life, how could one expect him to? But when he falls sick, will Tony step up? Will Peter find the will to fight? Or will they both treat death as what it truly is- inevitable?
+
+Series
+
+
+
+Language:
+English
+Words:
+15,548
+Chapters:
+1/1
+Collections:
+1
+
+
+Kudos:
+349
+Bookmarks:
+82
+Hits:
+6,016
+
+
+
+
+
+
+Tags
+
+
+Summary
+
+When Tony went to track down Spider-man, he found a brilliant fourteen-year-old boy who’d been bouncing through foster homes his whole life. Though things looked fine on the surface, Tony wasn’t sure he trusted this Mr. Westcott.
+
+Series
+
+
+
+Language:
+English
+Words:
+3,929
+Chapters:
+1/1
+Collections:
+1
+
+
+Kudos:
+937
+Bookmarks:
+105
+Hits:
+9,515
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/mocks/data/series/2270465/index.html b/tests/mocks/data/series/2270465/index.html
new file mode 100644
index 0000000..98ad3ae
--- /dev/null
+++ b/tests/mocks/data/series/2270465/index.html
@@ -0,0 +1,665 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ OG Titan - MyHero - Batman - All Media Types, Nightwing (Comics), Red Hood and the Outlaws (Comics), Teen Titans (Comics), Titans (Comics) [Archive of Our Own]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ While we've done our best to make the core functionality of this site accessible without javascript, it will work better with it enabled. Please consider turning it on!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+OG Titan
+
+
+
+
+
+
Series Metadata
+
+
+Creator:
+MyHero
+Series Begun:
+2021-04-11
+Series Updated:
+2023-02-13
+Description:
+My potentially related stories about the relationship between the OG Titans. Probably focused on Dick Grayson.
+Stats:
+
+
+Words:
+30,044
+Works:
+6
+Complete:
+No
+Bookmarks:
+177
+
+
+
+
+
Listing Series
+
+
+
+
+
+Tags
+
+
+Summary
+
+Donna Troy regularly dreams about kidnapping her Wonder Twin, Dick Grayson, and running away to a better life. She wants to put him in a safe little apartment in Paris, or drag him to London, or disappear into the wilderness, or move out to the Kent farm. She dreams of taking him away to New York, cutting all the toxic people from his life and helping him grow.
Donna dreams to give Dick a better life but knows in her soul that he would never go. She knows that Dick would never be able to walk away from the others because it goes against his very being.
Donna is terrified of the possible day where Dick honestly takes her up on the offer to run away. It terrifies her because deep in her heart, because she knows if he ever truly says yes, that means they have finally broken him. And for all her strength, Donna doesn't know if she would be able to put him back to together again.
But still she dreams, of them running away because it's those small moments that keeps her from burning the world as she follows him through this Hell.
+
+Series
+
+
+
+Language:
+English
+Words:
+2,733
+Chapters:
+1/1
+
+
+Kudos:
+1,122
+Bookmarks:
+177
+Hits:
+8,816
+
+
+
+
+
+
+Tags
+
+
+Summary
+
+It started with a group text from Garth, between him, Wally, Roy, and Donna.
Tuesday 8:37pm Fish-R-Us: Code Burgundy - D
It ended with Roy starting to realize just how far he has wondered from his family due to misguided anger. And maybe he starts to do something about it, the first step is to find out find the missing pieces. He along with Jason (who was first reluctant then determined) are on a mission for the truth to the "death" of Dick Grayson.
+
+Series
+
+
+
+Language:
+English
+Words:
+17,141
+Chapters:
+12 /?
+Collections:
+6
+
+
+Kudos:
+2,623
+Bookmarks:
+561
+Hits:
+51,324
+
+
+
+
+
+
+Tags
+
+
+Summary
+
+Three times Cassandra witnessed the friendship between Dick and Donna without Donna even being there. And the one time Donna was there in person.
Wonder Twins might not be in the same city, but they aren't any less wonderful.
+
+Series
+
+
+
+Language:
+English
+Words:
+3,021
+Chapters:
+1/1
+
+
+Kudos:
+1,218
+Bookmarks:
+192
+Hits:
+9,755
+
+
+
+
+
+
+Tags
+
+
+Summary
+
+It started with a tweet. Actually it started with a Teen Titan case from back in the day that became a hobby and just a healthy outlit. It came back into their lives with a tweet.
Inspired by Everyday one headcanon about Nightwing by TrikaLika (Chapter 38. Band)
+
+Series
+
+
+
+Language:
+English
+Words:
+832
+Chapters:
+1/1
+
+
+Kudos:
+567
+Bookmarks:
+70
+Hits:
+4,922
+
+
+
+
+
+
+Tags
+
+
+Summary
+
+Dick knew about Donna's daydreams about him walking away. And maybe in his darkest moments, Dick has a few of his own. But now, as he and Donna board the plane to travel across the world, he wonders if he will ever make it back. This isn't how either of them expected it to go, but maybe that's the silver lining to the otherwise dark situation.
Aka... It didn't take his death to finally make Dick walk away from Gotham, but he might not be able to say the same in a year.
The cure was still early stages of development, considered experimental at best. The Bats were the least of their concerns. Dick knows things will never be the same, assuming he lives at all.
+
+Series
+
+
+
+Language:
+English
+Words:
+5,727
+Chapters:
+2 /3
+Collections:
+1
+
+
+Kudos:
+993
+Bookmarks:
+150
+Hits:
+8,641
+
+
+
+
+
+
+Tags
+
+
+Summary
+
+Dick feels the distance between Bludhaven and Gotham like a crater in his chest. His family were light-years away, across the inkey Gotham Bay. The distant lights were sparkling stars in the smog.
He had hope. The Titans were his tethers, pulling him from the blackhole centered in his Bludhaven appartment.
Aka
Friends that sing together stay together
+
+Series
+
+
+
+Language:
+English
+Words:
+590
+Chapters:
+1/1
+
+
+Kudos:
+242
+Bookmarks:
+28
+Hits:
+1,121
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/mocks/data/series/2817877/index.html b/tests/mocks/data/series/2817877/index.html
new file mode 100644
index 0000000..2291da7
--- /dev/null
+++ b/tests/mocks/data/series/2817877/index.html
@@ -0,0 +1,688 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ *Insert Fandom* but Social Media (one-shots) - Anonymous - Batman - All Media Types, Dream SMP RPF, Five Nights at Freddy's, Five Nights at Freddy's (Movie 2023), Marvel Cinematic Universe, Minecraft (Video Game), The Avengers (Marvel Movies), Turning Red (2022), Video Blogging RPF, 呪術廻戦 | Jujutsu Kaisen (Anime), 呪術廻戦 | Jujutsu Kaisen (Manga) [Archive of Our Own]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ While we've done our best to make the core functionality of this site accessible without javascript, it will work better with it enabled. Please consider turning it on!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+*Insert Fandom* but Social Media (one-shots)
+
+
+
+
+
+
Series Metadata
+
+
+Creator:
+Anonymous
+Series Begun:
+2021-10-29
+Series Updated:
+2023-11-01
+Description:
+Find out which series I am going to write a Social Media fic about *jazz hands*
+Notes:
+Part 1: Turning Red and Avengers fusion Part 2-3: DSMP Fandom (2* is a Batman crossover) Part 4: FNAF Fandom Part 5: Jujutsu Kaisen
+Stats:
+
+
+Words:
+16,938
+Works:
+5
+Complete:
+Yes
+Bookmarks:
+93
+
+
+
+
+
Listing Series
+
+
+
+
+
+Tags
+
+
+Summary
+
+
+Thor is a himbo 🔨 @janey
+
+ Replying to @ironmanass
+
+Oh, isn't this the girl that Tony Stark was slapped by ?
+Canada dry soda @kmshottie
+
+ Replying to @ironmanass and @janey
+
+*mother… it was the girl's mother that slapped him
+Rain is my name @dontwearitout
+
+ Replying to @ironmanass @janey and @kmshottie
+
+It was pretty iconic
+ What if Turning Red and the MCU existed in the same timline?
+
+Series
+
+
+
+Language:
+English
+Words:
+1,963
+Chapters:
+1/1
+Collections:
+1
+
+
+Kudos:
+395
+Bookmarks:
+49
+Hits:
+2,992
+
+
+
+
+
+
+Tags
+
+
+Summary
+
+
+superman isn't a god @metropolisisoverated
+
+Replying to @TubboBeloved_
+
+Um, shouldn't we notify the the government of this??
+Tubbo Underscore-Beloved @TubboBeloved_
+
+Replying to @TubboBeloved_ and @metropolisisoverated
+
+You can, but they can't stop me
+superman isn't a god @metropolisisoverated
+
+Replying to @TubboBeloved_ and @metropolisisoverated
+
+Is- is that a threat
+Tubbo Underscore-Beloved @TubboBeloved_
+
+ Replying to @TubboBeloved_ and @metropolisisoverated
+
+It's a promise
+ Ranboo just wanted to post a picture of his son - Micheal. This somehow ends with Twitter learning about a place called The SMP.
+
+Series
+
+
+
+Language:
+English
+Words:
+3,488
+Chapters:
+1/1
+Collections:
+1
+
+
+Kudos:
+1,083
+Bookmarks:
+186
+Hits:
+10,173
+
+
+
+
+
+
+Tags
+
+
+Summary
+
+
+Respect the drip karen @vineruntilIdie
+
+ Replying to @TubboBU
+
+Excited to see how you make nukes work out in the lore 😂😂
+TubboBU ☑ @TubboBU
+
+ Replying to @TubboBU and @vineruntilIdie
+
+Lore??
+ Outsider POV but it's Twitter looking into the DSMP if it were a real country and the creators were still creators, but also no-one believes them
or; What If The SMP Was a Real Country?
+
+Series
+
+
+
+Language:
+English
+Words:
+4,709
+Chapters:
+2 /2
+Collections:
+1
+
+
+Kudos:
+1,037
+Bookmarks:
+231
+Hits:
+8,770
+
+
+
+
+
+
+Tags
+
+
+Summary
+
+
+Yellow disk bitch @exclmatiomemma
+
+ Replying to @redhearing
+
+What the fuck does Utah have??
+Daycare is hell @gonnapee
+
+ Replying to @redhearing
+
+Killer robots
+Yellow disk bitch @exclmatiomemma
+
+ Replying to @redhearing
+
+THEY HAVE WHAT-
+ or; How Social media would react if FNAF was a real location/company
+
+Series
+
+
+
+Language:
+English
+Words:
+4,528
+Chapters:
+2 /2
+Collections:
+1
+
+
+Kudos:
+1,754
+Bookmarks:
+298
+Hits:
+11,864
+
+
+
+
+
+
+Tags
+
+
+Summary
+
+
+Itadori is hungry
+
+@realpinkette
+
+
+Replying to @realpinkette
+
+Won another battle!
+Megumi @realbluenette
+
+ Replying to @realpinkette
+
+Hurry up and get to class, Itadori
+ What if curses did show up when you took pictures?
Or: Social media finds out about the Jiujitsu world
+
+Series
+
+
+
+Language:
+English
+Words:
+2,250
+Chapters:
+1/1
+Collections:
+4
+
+
+Kudos:
+467
+Bookmarks:
+91
+Hits:
+3,725
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/mocks/data/series/2946579/index.html b/tests/mocks/data/series/2946579/index.html
new file mode 100644
index 0000000..95c63b1
--- /dev/null
+++ b/tests/mocks/data/series/2946579/index.html
@@ -0,0 +1,424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Twitterchat Saga - Anonymous - Marvel Cinematic Universe, The Avengers (Marvel) - All Media Types [Archive of Our Own]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ While we've done our best to make the core functionality of this site accessible without javascript, it will work better with it enabled. Please consider turning it on!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Twitterchat Saga
+
+
+
+
+
+
Series Metadata
+
+
+Creator:
+Anonymous
+Series Begun:
+2022-02-18
+Series Updated:
+2022-06-26
+Stats:
+
+
+Words:
+30,585
+Works:
+2
+Complete:
+No
+
+
+
+
+
Listing Series
+
+
+
+
+
+Tags
+
+
+Summary
+
+Tips for making an Avengers Group Chat: Don't. It ends in chaos and at least one broken window a week. And a lot, a lot, of popcorn.
~~~
Tony: Scott, are you alright? Sent with Friday
Scott: thanks for asking
Tony: And? Sent with Friday
Scott: no
Scott: your really caring by the way. even took out your phone for me
Tony: WAIT IT SHOWED
Steve: Thars how it feels.
+
+Series
+
+
+
+Language:
+English
+Words:
+11,466
+Chapters:
+20 /?
+Collections:
+1
+
+
+Kudos:
+125
+Bookmarks:
+12
+Hits:
+2,591
+
+
+
+
+
+
+Tags
+
+
+Summary
+
+Avengers GC context fic turned extras fic turned twitter fic because I refuse to have anything other than the chat in the main one.
+
+Series
+
+
+
+Language:
+English
+Words:
+19,119
+Chapters:
+19 /?
+Collections:
+1
+
+
+Kudos:
+48
+Bookmarks:
+3
+Hits:
+2,231
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/mocks/handlers.ts b/tests/mocks/handlers.ts
index c004f94..4141d3f 100644
--- a/tests/mocks/handlers.ts
+++ b/tests/mocks/handlers.ts
@@ -3,6 +3,7 @@ import allHandlers from "./handlers/all";
import feedHandlers from "./handlers/tags/feed";
import nameHandlers from "./handlers/tags/name";
import profileHandlers from "./handlers/users/profile";
+import seriesHandlers from "./handlers/series";
import tagWorksHandlers from "./handlers/tags/works";
import workPageHandlers from "./handlers/works";
import worksHandlers from "./handlers/works";
@@ -17,5 +18,6 @@ export default [
nameHandlers,
workPageHandlers,
worksNavigateHandlers,
+ seriesHandlers,
allHandlers,
];
diff --git a/tests/mocks/handlers/series/index.ts b/tests/mocks/handlers/series/index.ts
new file mode 100644
index 0000000..d80ec90
--- /dev/null
+++ b/tests/mocks/handlers/series/index.ts
@@ -0,0 +1,25 @@
+import { fileURLToPath } from "url";
+import filenamify from "filenamify";
+import fs from "fs";
+import path from "path";
+import { rest } from "msw";
+
+const SERIES_DATA_DIR = path.resolve(
+ fileURLToPath(import.meta.url),
+ "../../../data/series"
+);
+
+export default rest.all(
+ "https://archiveofourown.org/series/:series_id",
+ (req, res, ctx) => {
+ const html = fs.readFileSync(
+ path.resolve(
+ SERIES_DATA_DIR,
+ filenamify(req.params.series_id as string),
+ "index.html"
+ )
+ );
+
+ return res(ctx.set("Content-Type", "text/html"), ctx.body(html));
+ }
+);
diff --git a/tests/series.test.ts b/tests/series.test.ts
index 5f935f1..e3998b9 100644
--- a/tests/series.test.ts
+++ b/tests/series.test.ts
@@ -9,9 +9,9 @@ describe("Fetches series information", () => {
expect(series).toMatchObject({
id: "2270465",
name: "OG Titan",
- begunAt: "2021-04-11",
+ startedAt: "2021-04-11",
updatedAt: "2023-02-13",
- creators: [{ username: "MyHero", pseud: "MyHero" }],
+ authors: [{ username: "MyHero", pseud: "MyHero" }],
description:
"My potentially related stories about the relationship between the OG Titans. Probably focused on Dick Grayson.
",
notes: null,
@@ -354,22 +354,6 @@ describe("Fetches series information", () => {
stats: { bookmarks: 28, kudos: 242, hits: 1 },
},
],
- workTitles: [
- "Away from all of Reality",
- "Code B",
- "Donna Troy Loves You",
- "Rockin Robin",
- "Realistic Exit Strategy",
- "You starting down the road leaving me again",
- ],
- workUrls: [
- "https://archiveofourown.org/works/30604247",
- "https://archiveofourown.org/works/30794750",
- "https://archiveofourown.org/works/30914645",
- "https://archiveofourown.org/works/31221131",
- "https://archiveofourown.org/works/35757790",
- "https://archiveofourown.org/works/44149795",
- ],
});
});
diff --git a/types/entities.ts b/types/entities.ts
index 49eea27..f27adb7 100644
--- a/types/entities.ts
+++ b/types/entities.ts
@@ -41,7 +41,13 @@ export interface User {
export interface SeriesWorkSummary
extends Omit<
WorkSummary,
- "category" | "publishedAt" | "rating" | "tags" | "stats" | "locked"
+ | "category"
+ | "publishedAt"
+ | "rating"
+ | "tags"
+ | "stats"
+ | "locked"
+ | "series"
> {
url: string;
tags: Omit;