[buoh] Add tool for checking comic links
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [buoh] Add tool for checking comic links
- Date: Sat, 2 Jan 2021 21:38:36 +0000 (UTC)
commit 2cc9a2d92cfa15dcf56653bfbf873552cba8cb58
Author: Jan Tojnar <jtojnar gmail com>
Date: Sat Jan 2 22:35:06 2021 +0100
Add tool for checking comic links
build-aux/check-comic-links.py | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
---
diff --git a/build-aux/check-comic-links.py b/build-aux/check-comic-links.py
new file mode 100644
index 0000000..da4bed5
--- /dev/null
+++ b/build-aux/check-comic-links.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+import datetime
+import sys
+import xml.etree.ElementTree as ET
+import requests
+
+if len(sys.argv) < 2:
+ sys.exit('usage: check-comic-links.py <comics.xml>')
+
+tree = ET.parse(sys.argv[1])
+comic_list = tree.getroot()
+
+errors = False
+
+for comic in comic_list:
+ comic_class = comic.attrib['class']
+ if comic_class == 'date':
+ first_uri = datetime.datetime.strptime(comic.attrib['first'],
'%Y-%m-%d').strftime(comic.attrib['generic_uri'])
+ response = requests.get(first_uri, allow_redirects=False)
+ if response.status_code != 200:
+ title = comic.attrib['title']
+ print(f'Comic “{title}” returned {response.status_code} for {first_uri}', file=sys.stderr)
+ errors = True
+
+if errors:
+ sys.exit(1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]