Refactoring
This commit is contained in:
parent
07836f5763
commit
981d4a1b5f
2 changed files with 23 additions and 20 deletions
|
|
@ -6,10 +6,10 @@ function upload_to_doodstream () {
|
||||||
|
|
||||||
filepath=$( readlink -f "$filepath" )
|
filepath=$( readlink -f "$filepath" )
|
||||||
# echo "filepath: $filepath" >&2
|
# echo "filepath: $filepath" >&2
|
||||||
|
|
||||||
filesize=$(stat -c%s "$filepath")
|
filesize=$(stat -c%s "$filepath")
|
||||||
# echo "filesize: $filesize" >&2
|
# echo "filesize: $filesize" >&2
|
||||||
|
|
||||||
# filesha256=$( sha256sum "$filepath")
|
# filesha256=$( sha256sum "$filepath")
|
||||||
# filesha256=${filesha256%% *}
|
# 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)
|
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_url=$(echo $hoster_url | jq ".result")
|
||||||
# hoster_filename=$(echo $hoster_url | jq ".name")
|
# hoster_filename=$(echo $hoster_url | jq ".name")
|
||||||
hoster_url=$(echo $hoster_url | jq ".[0]")
|
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//\"}
|
hoster_url=${hoster_url//\"}
|
||||||
|
|
||||||
if [ "$hoster_url" != "" ] && [ "$hoster_url" != "null" ]; then
|
if [ "$hoster_url" != "" ] && [ "$hoster_url" != "null" ]; then
|
||||||
|
|
@ -39,25 +39,27 @@ function upload_to_doodstream () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function doodstream_check_if_file_is_alive () {
|
function doodstream_check_if_file_is_alive () {
|
||||||
file_url=$1
|
file_url=$2
|
||||||
api_key=$2
|
api_key=$1
|
||||||
# api_SecretID=$3
|
# api_SecretID=$3
|
||||||
|
|
||||||
# file_id=${file_url%/*}
|
# file_id=${file_url%/*}
|
||||||
# >&2 echo "File ID: $file_id"
|
# >&2 echo "File ID: $file_id"
|
||||||
file_id=${file_url##*/}
|
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")
|
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"
|
>&2 echo "Response: $response"
|
||||||
|
|
||||||
is_alive=$(echo $response | jq ".result")
|
is_alive=$(echo $response | jq ".result")
|
||||||
is_alive=$(echo $is_alive | jq ".[0]")
|
is_alive=$(echo $is_alive | jq ".[0]")
|
||||||
# is_alive=$(echo $is_alive | jq "first(.[])")
|
# is_alive=$(echo $is_alive | jq "first(.[])")
|
||||||
is_alive=$(echo $is_alive | jq ".status")
|
is_alive=$(echo $is_alive | jq ".status")
|
||||||
|
|
||||||
# >&2 echo $is_alive
|
# >&2 echo $is_alive
|
||||||
|
|
||||||
if [ "$is_alive" == "\"Not found\"" ]; then
|
if [ "$is_alive" == "\"Not found\"" ]; then
|
||||||
echo "false"
|
echo "false"
|
||||||
# elif [ $is_alive = '500' ]; then
|
# elif [ $is_alive = '500' ]; then
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,15 @@ function upload_to_streamtape () {
|
||||||
|
|
||||||
filepath=$( readlink -f "$filepath" )
|
filepath=$( readlink -f "$filepath" )
|
||||||
# echo "filepath: $filepath" >&2
|
# echo "filepath: $filepath" >&2
|
||||||
|
|
||||||
filesize=$(stat -c%s "$filepath")
|
filesize=$(stat -c%s "$filepath")
|
||||||
# echo "filesize: $filesize" >&2
|
# echo "filesize: $filesize" >&2
|
||||||
|
|
||||||
filesha256=$( sha256sum "$filepath")
|
filesha256=$( sha256sum "$filepath")
|
||||||
filesha256=${filesha256%% *}
|
filesha256=${filesha256%% *}
|
||||||
|
|
||||||
echo "filesha256 $filesha256" >&2
|
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")
|
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
|
echo "Upload_URL $upload_server" >&2
|
||||||
|
|
@ -34,22 +35,22 @@ function upload_to_streamtape () {
|
||||||
|
|
||||||
function streamtape_check_if_file_is_alive () {
|
function streamtape_check_if_file_is_alive () {
|
||||||
file_url=$1
|
file_url=$1
|
||||||
|
|
||||||
file_id=${file_url%/*}
|
file_id=${file_url%/*}
|
||||||
# >&2 echo "File ID: $file_id"
|
# >&2 echo "File ID: $file_id"
|
||||||
file_id=${file_id##*/}
|
file_id=${file_id##*/}
|
||||||
# >&2 echo "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" )
|
response=$(curl -s -X GET "https://api.streamtape.com/file/info?file=$file_id" -H "Content-Type: application/json" )
|
||||||
# >&2 echo "Response: $response"
|
# >&2 echo "Response: $response"
|
||||||
|
|
||||||
is_alive=$(echo $response | jq ".result")
|
is_alive=$(echo $response | jq ".result")
|
||||||
is_alive=$(echo $is_alive | jq "first(.[])")
|
is_alive=$(echo $is_alive | jq "first(.[])")
|
||||||
is_alive=$(echo $is_alive | jq ".status")
|
is_alive=$(echo $is_alive | jq ".status")
|
||||||
|
|
||||||
# echo $is_alive
|
# echo $is_alive
|
||||||
|
|
||||||
if [ $is_alive = '404' ]; then
|
if [ $is_alive == '404' ]; then
|
||||||
echo "false"
|
echo "false"
|
||||||
# elif [ $is_alive = '500' ]; then
|
# elif [ $is_alive = '500' ]; then
|
||||||
# echo "false"
|
# echo "false"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue