From 981d4a1b5f4230db3b6d91b174c1ff7b7a1b0b12 Mon Sep 17 00:00:00 2001 From: Tidoni Date: Wed, 22 Dec 2021 21:33:15 +0100 Subject: [PATCH] Refactoring --- doodstreamFunctions.fn | 26 ++++++++++++++------------ streamtapeFunctions.fn | 17 +++++++++-------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/doodstreamFunctions.fn b/doodstreamFunctions.fn index caf20cd..ad21169 100644 --- a/doodstreamFunctions.fn +++ b/doodstreamFunctions.fn @@ -6,10 +6,10 @@ function upload_to_doodstream () { filepath=$( readlink -f "$filepath" ) # echo "filepath: $filepath" >&2 - + filesize=$(stat -c%s "$filepath") # echo "filesize: $filesize" >&2 - + # filesha256=$( sha256sum "$filepath") # filesha256=${filesha256%% *} @@ -23,12 +23,12 @@ function upload_to_doodstream () { hoster_url=$(curl -X POST -F api_key=$api_key -F "file=@\"$filepath\"" $upload_server?$api_key) - # echo "hoster_url: $hoster_url" >&2 + echo "hoster_url: $hoster_url" >&2 hoster_url=$(echo $hoster_url | jq ".result") # hoster_filename=$(echo $hoster_url | jq ".name") hoster_url=$(echo $hoster_url | jq ".[0]") - hoster_url=$(echo $hoster_url | jq ".protected_dl") + hoster_url=$(echo $hoster_url | jq ".download_url") hoster_url=${hoster_url//\"} if [ "$hoster_url" != "" ] && [ "$hoster_url" != "null" ]; then @@ -39,25 +39,27 @@ function upload_to_doodstream () { } function doodstream_check_if_file_is_alive () { - file_url=$1 - api_key=$2 + file_url=$2 + api_key=$1 # api_SecretID=$3 - + # file_id=${file_url%/*} # >&2 echo "File ID: $file_id" file_id=${file_url##*/} - # >&2 echo "File ID: $file_id" - + >&2 echo "File ID: $file_id" + + >&2 echo "URL to call: https://doodapi.com/api/file/check?key=$api_key&file_code=$file_id" + response=$(curl -s -X GET "https://doodapi.com/api/file/check?key=$api_key&file_code=$file_id" -H "Content-Type: multipart/form-data") >&2 echo "Response: $response" - + is_alive=$(echo $response | jq ".result") is_alive=$(echo $is_alive | jq ".[0]") # is_alive=$(echo $is_alive | jq "first(.[])") is_alive=$(echo $is_alive | jq ".status") - + # >&2 echo $is_alive - + if [ "$is_alive" == "\"Not found\"" ]; then echo "false" # elif [ $is_alive = '500' ]; then diff --git a/streamtapeFunctions.fn b/streamtapeFunctions.fn index 4bc5a81..59c2bdd 100755 --- a/streamtapeFunctions.fn +++ b/streamtapeFunctions.fn @@ -7,14 +7,15 @@ function upload_to_streamtape () { filepath=$( readlink -f "$filepath" ) # echo "filepath: $filepath" >&2 - + filesize=$(stat -c%s "$filepath") # echo "filesize: $filesize" >&2 - + filesha256=$( sha256sum "$filepath") filesha256=${filesha256%% *} echo "filesha256 $filesha256" >&2 + echo "https://api.streamtape.com/file/ul?login=$api_user&key=$api_key&sha256=$filesha256" >&2 upload_server=$(curl -s -X GET "https://api.streamtape.com/file/ul?login=$api_user&key=$api_key&sha256=$filesha256" -H "Content-Type: application/json") echo "Upload_URL $upload_server" >&2 @@ -34,22 +35,22 @@ function upload_to_streamtape () { function streamtape_check_if_file_is_alive () { file_url=$1 - + file_id=${file_url%/*} # >&2 echo "File ID: $file_id" file_id=${file_id##*/} # >&2 echo "File ID: $file_id" - + response=$(curl -s -X GET "https://api.streamtape.com/file/info?file=$file_id" -H "Content-Type: application/json" ) # >&2 echo "Response: $response" - + is_alive=$(echo $response | jq ".result") is_alive=$(echo $is_alive | jq "first(.[])") is_alive=$(echo $is_alive | jq ".status") - + # echo $is_alive - - if [ $is_alive = '404' ]; then + + if [ $is_alive == '404' ]; then echo "false" # elif [ $is_alive = '500' ]; then # echo "false"