From ea5ff744a13967b0016469a25e2f62cddbe9de96 Mon Sep 17 00:00:00 2001 From: alf Date: Thu, 23 Apr 2026 20:26:19 +0000 Subject: [PATCH] paste_senden.sh aktualisiert --- paste_senden.sh | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/paste_senden.sh b/paste_senden.sh index eb364d8..4b0c12e 100644 --- a/paste_senden.sh +++ b/paste_senden.sh @@ -1,12 +1,38 @@ #!/bin/bash -FILE="$1" # Pfad als erstes Argument beim Aufruf: ./script.sh datei.txt +FILE="$1" +HOST="${2:-http://localhost:8000}" -curl -X POST \ - -d 'api_dev_key=RdWPnCdyvMdV1YNr_Un-aw0zfbWnspff' \ - -d 'api_paste_name=tmp.txt' \ - --data-urlencode "api_paste_code@$FILE" \ - -d 'api_option=paste' \ - "https://pastebin.com/api/api_post.php" +if [ -z "$FILE" ]; then + echo "Verwendung: $0 [host]" + exit 1 +fi -echo +if [ ! -f "$FILE" ]; then + echo "Datei nicht gefunden: $FILE" + exit 1 +fi + +CONTENT=$(cat "$FILE") +FILENAME=$(basename "$FILE") + +RESPONSE=$(curl -s -X POST "$HOST/api/v1/paste" \ + -H "Content-Type: application/json" \ + -d "{ + \"expiry\": \"1day\", + \"files\": [{ + \"name\": \"$FILENAME\", + \"lexer\": \"text\", + \"content\": $(echo "$CONTENT" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))') + }] + }") + +LINK=$(echo "$RESPONSE" | python3 -c 'import json,sys; print(json.loads(sys.stdin.read())["link"])' 2>/dev/null) + +if [ -z "$LINK" ]; then + echo "Fehler: $RESPONSE" + exit 1 +fi + +echo "Paste URL: $LINK" +echo "Paste-ID: $(basename $LINK)" \ No newline at end of file