Open lgtice opened 1 year ago
You can do it by adding just 3 lines of code.
fetch_track_by_ids()
and then pass the count to fetch_track_by_id()
fetch_track_by_id()
, use $2 to get the count parameter and then apply the count to the saved filename.# param track_id track_id
fetch_track_by_ids() {
local count=0
for id in $@; do
count=$((count + 1))
fetch_track_by_id $id $count
done
}
# param track_id
fetch_track_by_id() {
count=$2
result=`curl -s "http://mobile.ximalaya.com/v1/track/baseInfo?device=iPhone&trackId=$1"|grep title`
if [ -n "$result" ];then
uid=`echo $result|decode_json uid|sed 's/\"//g'`
title=`echo $result|decode_json title|sed 's/\"//g'`
url64=`echo $result|decode_json playUrl64|sed 's/\"//g'|sed 's/\\\//g'`
if [ -n "$url64" ];then
title=`echo $title|sed 's/\.//g'|sed 's/\///g'`
echo "fetching $title ..."
echo "$url64"
# wget "$url64" -O "$dst_dir/$count-$title.mp3"
curl -s "$url64" -o "$dst_dir/$count-$title.mp3"
else
error "Failed to fetch the track, may be a paid resource."
fi
else
error "The trackId $1 does not exist."
fi
}
You can still use wget, however, I don't have wget on my Mac, so I changed the download tool to curl.
不添加序号的话,下载下来的顺序是乱的。按时间排序有时候都不是顺序的。