feat: better scripts & less fingerprinting info
This commit is contained in:
parent
dbeb324937
commit
cf2486f549
@ -13,7 +13,7 @@ export BEARER_TOKEN
|
||||
GUEST_TOKEN_RES=$(
|
||||
curl -sX POST https://clienttoken.spotify.com/v1/clienttoken \
|
||||
-H "Accept: application/json" -H "content-type: application/json" \
|
||||
--data '{"client_data":{"client_version":"1.2.27.147.g503c721c","client_id":"d8a5ed958d274c2e8ee717e6a4b0971d","js_sdk_data":{"device_brand":"unknown","device_model":"unknown","os":"linux","os_version":"unknown","device_id":"nuhuh","device_type":"computer"}}}'
|
||||
--data '{"client_data":{"client_version":"1.2","client_id":"d8a5ed958d274c2e8ee717e6a4b0971d","js_sdk_data":{"device_brand":"unknown","device_model":"unknown","os":"unknown","os_version":"unknown","device_id":"unknown","device_type":"unknown"}}}'
|
||||
)
|
||||
|
||||
if ! [[ "$(echo "$GUEST_TOKEN_RES" | jq -r .response_type)" == "RESPONSE_GRANTED_TOKEN_RESPONSE" ]]; then
|
||||
|
@ -6,8 +6,17 @@ MYDIR=$(dirname "$MYSELF")
|
||||
. "$MYDIR"/get-tokens.sh
|
||||
|
||||
PLAYLIST_ID=${PLAYLIST_ID:-"2BoXyJeV0fhEHOy4uiByxr"}
|
||||
TARGET=${TARGET:-}
|
||||
if [ -z "$TARGET" ]; then
|
||||
printf '\x1b[1;33m%s\x1b[0m\n' "W: No \$TARGET specified, using CWD"
|
||||
TARGET=.
|
||||
fi
|
||||
|
||||
i=0
|
||||
PLAYLIST_JSON="$TARGET/playlist.json"
|
||||
PLAYLIST_TXT="$TARGET/playlist.txt"
|
||||
SUM_PLAYLIST_JSON="$TARGET/summary-playlist.json"
|
||||
|
||||
# i=0
|
||||
iter_url=https://api.spotify.com/v1/playlists/$PLAYLIST_ID/tracks
|
||||
while :; do
|
||||
RES=$(curl --request GET \
|
||||
@ -18,20 +27,23 @@ while :; do
|
||||
iter_url=$(jq -r .next <<< "$RES")
|
||||
echo "$RES"
|
||||
|
||||
i=$((i+1))
|
||||
# _=$((i++))
|
||||
[[ "$iter_url" == "null" ]] && break
|
||||
done \
|
||||
| pv \
|
||||
| jq .items \
|
||||
| jq -s 'reduce .[] as $x ([]; . + $x)' \
|
||||
| jq 'del(.. | .available_markets?, .added_by?, .popularity?)' > playlist.json
|
||||
| jq 'del(.. | .available_markets?, .added_by?, .popularity?)' > "$PLAYLIST_JSON"
|
||||
|
||||
printf "downloaded %s songs metadata\n" "$(jq length playlist.json)"
|
||||
ARR=" "$'\x1b'"[32m=>"$'\x1b'"[0m"
|
||||
|
||||
jq -r '.[].track | ( .name + " - " + (.album.artists | map(.name) | join(", ")) )' playlist.json \
|
||||
> playlist.txt
|
||||
printf "and dumped it as text on %s\n" playlist.txt
|
||||
printf "$ARR downloaded \x1b[33m%s\x1b[0m songs metadata at \x1b[35m%s\x1b[0m\n" \
|
||||
"$(jq length "$PLAYLIST_JSON")" "$PLAYLIST_JSON"
|
||||
|
||||
jq -c '.[].track | ( [.id, .name, .album.name, (.album.artists | map(.name))] )' playlist.json \
|
||||
> summary-playlist.json
|
||||
printf "AND dumped summary metadata on %s\n" summary-playlist.txt
|
||||
jq -r '.[].track | ( .name + " - " + (.album.artists | map(.name) | join(", ")) )' "$PLAYLIST_JSON" \
|
||||
> "$PLAYLIST_TXT"
|
||||
printf "$ARR dumped it as text on \x1b[35m%s\x1b[0m\n" "$PLAYLIST_TXT"
|
||||
|
||||
jq -c '.[].track | ( [.id, .name, .album.name, (.album.artists | map(.name))] )' "$PLAYLIST_JSON" \
|
||||
> "$SUM_PLAYLIST_JSON"
|
||||
printf "$ARR dumped summary metadata on \x1b[35m%s\x1b[0m\n" "$SUM_PLAYLIST_JSON"
|
||||
|
Loading…
x
Reference in New Issue
Block a user