commit b46a6339de1a547093d2bdf271b2f8b7df8ed4de
parent 160cc7a6b6e1d0cb67753fea16c1731e1443a3b6
Author: glenda <glenda@kobeni>
Date: Thu, 18 Jan 2024 01:52:57 +0000
src/mangaupdates: turn tests into scripts
Diffstat:
3 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/src/mangaupdates/search b/src/mangaupdates/search
@@ -0,0 +1,12 @@
+#!/bin/rc
+# search for title on mangaupdates
+
+api_url='https://api.mangaupdates.com/v1'
+{
+cat <<EOF
+{
+ "search": "$*",
+ "stype": "title"
+}
+EOF
+} | hget -P -r 'Content-Type: application/json' $api_url/series/search | json/fmt
diff --git a/src/mangaupdates/series b/src/mangaupdates/series
@@ -0,0 +1,6 @@
+#!/bin/rc
+# get info on a specific series from mangaupdates
+
+api_url='https://api.mangaupdates.com/v1'
+series_id=$1
+hget $api_url/series/$series_id | json/fmt
diff --git a/src/mangaupdates/tests b/src/mangaupdates/tests
@@ -1,8 +1,28 @@
+# poking mangaupdates.com api
-hget https://api.mangaupdates.com/v1/releases/days | json/fmt
+## Search by title
+```
+api_url='https://api.mangaupdates.com/v1'
{
cat <<EOF
-{"search": "Yotsuba", "stype": "title"}
+{
+ "search": "Yotsuba",
+ "stype": "title"
+}
EOF
-} | hget -P -r 'Content-Type: application/json' https://api.mangaupdates.com/v1/series/search | json/fmt
+} | hget -P -r 'Content-Type: application/json' $api_url/series/search | json/fmt \
+ > /tmp/json
+```
+
+## Get series data
+
+Note: in the url of web interface, id is encoded in Base36, but api
+uses normal Base10 numbers.
+
+```
+api_url='https://api.mangaupdates.com/v1'
+series_id='23606352927'
+hget $api_url/series/$series_id | json/fmt \
+ > /tmp/json
+```