Skip to content

Instantly share code, notes, and snippets.

@hnq90
Last active April 7, 2017 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hnq90/38eaa792ad1f19df6f88345477c5badb to your computer and use it in GitHub Desktop.
Save hnq90/38eaa792ad1f19df6f88345477c5badb to your computer and use it in GitHub Desktop.
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