Fix a linting issue; add support for AO3 collections
- ID
c891f71- date
2024-03-16 18:10:04+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
b945087- message
Fix a linting issue; add support for AO3 collections- changed files
2 files, 8 additions, 1 deletion
Changed files
web/save_ao3_links.py (2077) → web/save_ao3_links.py (2236)
diff --git a/web/save_ao3_links.py b/web/save_ao3_links.py
index a4d5a65..1ac99ab 100755
--- a/web/save_ao3_links.py
+++ b/web/save_ao3_links.py
@@ -5,7 +5,6 @@ import pathlib
import shutil
import subprocess
import sys
-import tarfile
import hyperlink
@@ -19,6 +18,13 @@ def get_ao3_id(url: str) -> str:
if u.path[0] == "works" and u.path[1].isnumeric():
return u.path[1]
+ elif (
+ len(u.path) >= 4
+ and u.path[0] == "collections"
+ and u.path[2] == "works"
+ and u.path[3].isnumeric()
+ ):
+ return u.path[3]
else:
raise ValueError(url)
web/test_save_ao3_links.py (451) → web/test_save_ao3_links.py (536)
diff --git a/web/test_save_ao3_links.py b/web/test_save_ao3_links.py
index b3b5b92..72916a7 100644
--- a/web/test_save_ao3_links.py
+++ b/web/test_save_ao3_links.py
@@ -12,6 +12,7 @@ from save_ao3_links import get_ao3_id
"https://archiveofourown.org/works/1234/chapters/5678?view_adult=true",
"1234",
),
+ ("https://archiveofourown.org/collections/yuletide2022/works/1234", "1234"),
],
)
def test_get_ao3_id(url, ao3_id):