Instantly share code, notes, and snippets.

@hnq90 /zing320.sh
Last active Apr 7, 2017

Embed
What would you like to do?
Download 320Kbps song from mp3.zing.vn
#!/bin/sh
songId=$1
parseJson () {
python -c "import json,sys;sys.stdout.write(json.dumps(json.load(sys.stdin)$1))";
}
fetch () {
local output=`wget -q --method GET --progress=dot --output-document - http://api.mp3.zing.vn/api/mobile/song/getsonginfo?requestdata={\"id\":\"$songId\"}`
local link=$(echo $output | parseJson "['source']['320']")
local artist=$(echo $output | parseJson "['artist']")
local title=$(echo $output | parseJson "['title']")
link="${link%\"}"
link="${link#\"}"
title="${title%\"}"
title="${title#\"}"
artist="${artist%\"}"
artist="${artist#\"}"
local fileName=`echo "$(echo -e $title)_$(echo -e $artist)_320kbps"`
wget --method GET \
--header 'cache-control: no-cache' \
--output-document="$fileName.mp3" \
- $link
}
fetch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment