Save AO3 links to folders, not tar.gz bundles
- ID
b945087- date
2024-03-16 18:08:23+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
75c7b91- message
Save AO3 links to folders, not tar.gz bundles- changed files
1 file, 4 additions, 7 deletions
Changed files
web/save_ao3_links.py (2160) → web/save_ao3_links.py (2077)
diff --git a/web/save_ao3_links.py b/web/save_ao3_links.py
index b1d9f37..a4d5a65 100755
--- a/web/save_ao3_links.py
+++ b/web/save_ao3_links.py
@@ -28,7 +28,7 @@ def save_ao3_url(url: str):
# Check if the fic is already downloaded -- if it is, nothing to do.
if any(
- name.startswith(f"{ao3_id}-") and name.endswith(".tar.gz")
+ name.startswith(f"{ao3_id}-") and os.path.isdir(BACKUP_ROOT / name)
for name in os.listdir(BACKUP_ROOT)
):
return
@@ -66,14 +66,11 @@ def save_ao3_url(url: str):
except FileNotFoundError:
return
- out_path = BACKUP_ROOT / f"{ao3_id}-{title}.tar.gz"
+ out_dir = BACKUP_ROOT / f"{ao3_id}-{title}"
- with tarfile.open(out_path, "w:gz") as tf:
- tf.add(tmp_dir, arcname=ao3_id)
+ os.rename(tmp_dir, out_dir)
- shutil.rmtree(tmp_dir)
-
- print(f" ~> {out_path}")
+ print(f" ~> {out_dir}")
def wget(*args):