summaryrefslogtreecommitdiffstats
path: root/extra/sitemap/generate_sitemap_indices.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2020-08-19 22:55:05 -0700
committerBryan Newbold <bnewbold@robocracy.org>2020-08-19 22:56:31 -0700
commit5f282a6267182214080ca36bcec4da1755589b46 (patch)
treec6f9bd5a84da9e1c2e53aa6af2931df6f9110e60 /extra/sitemap/generate_sitemap_indices.py
parent88a99387e09c7c43803129e72215ef3f6b4cafc6 (diff)
downloadfatcat-5f282a6267182214080ca36bcec4da1755589b46.tar.gz
fatcat-5f282a6267182214080ca36bcec4da1755589b46.zip
iterate on sitemap generation
Diffstat (limited to 'extra/sitemap/generate_sitemap_indices.py')
-rwxr-xr-xextra/sitemap/generate_sitemap_indices.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/extra/sitemap/generate_sitemap_indices.py b/extra/sitemap/generate_sitemap_indices.py
new file mode 100755
index 00000000..9766ac1f
--- /dev/null
+++ b/extra/sitemap/generate_sitemap_indices.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+import sys
+import glob
+import datetime
+
+def index_entity(entity_type, output):
+
+ now = datetime.datetime.now().isoformat()
+ print("""<?xml version="1.0" encoding="UTF-8"?>""", file=output)
+ print("""<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">""", file=output)
+
+ for filename in glob.glob(f"sitemap-{entity_type}-*.txt.gz"):
+ print(" <sitemap>", file=output)
+ print(f" <loc>https://fatcat.wiki/{filename}</loc>", file=output)
+ print(f" <lastmod>{now}</lastmod>", file=output)
+ print(" </sitemap>", file=output)
+
+ print("</sitemapindex>", file=output)
+
+def main():
+ with open('sitemap-index-containers.xml', 'w') as output:
+ index_entity("containers", output)
+ with open('sitemap-index-releases.xml', 'w') as output:
+ index_entity("releases", output)
+
+if __name__=="__main__":
+ main()