From 959559298b4d1a34c69184a48fcf06c92d8cf3f4 Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 8 May 2022 02:23:20 +0000 Subject: [PATCH] Add API script --- api/search | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ spotify-dl-remote.sh | 5 +++++ 2 files changed, 67 insertions(+) create mode 100755 api/search create mode 100755 spotify-dl-remote.sh diff --git a/api/search b/api/search new file mode 100755 index 0000000..b6c4528 --- /dev/null +++ b/api/search @@ -0,0 +1,62 @@ +#!/bin/bash + +echo "content-type: text/html" +echo +echo "" + +args=$(echo "$SP_TRACK" | awk -F? '{print $2}' | sed 's/%20/ /g') + +#session_id=$(echo $RANDOM | md5sum | head -c 20; echo) +log_file="/tmp/spotify-dl.log" + +result=$(../spotify-dl.sh "$args" | tee $log_file 2>&1 | grep "/var/www/spotify-dl/" | grep -v "Format String:" | awk -F/ '{print $NF}' | rev | cut -c6- | rev | head -n1) +track=$(echo "$result" | awk -F '.mp3' '{print $1}') + +if [[ $track ]];then + echo "
" + echo "
" + echo "

$track

" + echo "





" + echo "
" + echo " + +" + echo "

" + echo "

DOWNLOAD

" + echo "

" + echo "
" + echo "
" +else + echo "
No result found
" +# echo "" +fi + +## redirection: echo "" + +echo " + +" diff --git a/spotify-dl-remote.sh b/spotify-dl-remote.sh new file mode 100755 index 0000000..9b4ad72 --- /dev/null +++ b/spotify-dl-remote.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +args="$@" + +wget "$(curl -s \"https://spotify-dl.p2p.legal/search?$args\" | grep 'https://spotify-dl.p2p.legal/dl' | awk -F '\"' '{print $2}')"