From 7dd1590399fc1e30cff298c000d026019bbbf82b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Navr=C3=A1til?= Date: Thu, 1 Aug 2024 14:57:29 +0200 Subject: [PATCH 1/3] Remove duplicities again for future use. --- nostr-backup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nostr-backup.sh b/nostr-backup.sh index 60a7c4f..b1b715d 100644 --- a/nostr-backup.sh +++ b/nostr-backup.sh @@ -43,3 +43,5 @@ done echo "Publishing to ${TARGET_RELAY}..." sort -u ~/tmp/nostr-backup.json | nak event ${TARGET_RELAY} +#Remove duplicities again for future use. +sort -u -o ~/tmp/nostr-backup.json ~/tmp/nostr-backup.json From 3fdca19d85077d31573f17aeef7de1775daf8a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Navr=C3=A1til?= Date: Thu, 1 Aug 2024 15:01:48 +0200 Subject: [PATCH 2/3] Read JSONL line by line --- slow-post.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/slow-post.py b/slow-post.py index 52843b1..9b34399 100644 --- a/slow-post.py +++ b/slow-post.py @@ -9,7 +9,14 @@ if len(sys.argv) < 2: relay = sys.argv[1] -data = json.loads(sys.stdin.read()) +data = [] +for line in sys.stdin: + try: + item = json.loads(line) + data.append(item) + except json.JSONDecodeError as e: + print(f"Error decoding JSON: {e}", file=sys.stderr) + continue # Execute the binary for each element in the JSON array for item in data: From 130b34f43008cac599e14f0dacd961e18ae1b053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Navr=C3=A1til?= Date: Thu, 1 Aug 2024 15:05:38 +0200 Subject: [PATCH 3/3] Syntax fix I was not able to run the previous code, but I'm running bash in Cygwin so it is possible it was a local problem. --- slow-post-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slow-post-all.sh b/slow-post-all.sh index 3563837..13d3274 100644 --- a/slow-post-all.sh +++ b/slow-post-all.sh @@ -7,5 +7,5 @@ for RELAY in wss://relay.nostrplebs.com wss://relay.nostr.band do echo "Publishing to ${RELAY}" # We can post to different relays in parallel, they don't know about each other - do python3 slow-post.py "${RELAY}" < "${1}";done ) & + python3 slow-post.py "${RELAY}" < "${1}" & done