Skip to content

kboxjson

kboxjson #4427

Workflow file for this run

name: kboxjson
on:
schedule:
- cron: '8 */8 * * *'
workflow_dispatch:
jobs:
my-job:
name: My Job
runs-on: ubuntu-latest
environment:
name: github-pages
steps:
- uses: actions/checkout@v2
- name: Fetch JSON
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
URLMK: ${{ secrets.URLMK }}
WWW: ${{ secrets.WWW }}
GATEWAY: ${{ secrets.GATEWAY }}
FMSERVICERETRY: ${{ secrets.FMSERVICERETRY }}
run: |
function waitForJobs() {
runningJobs=$(jobs -pr | wc -l)
while [ "$runningJobs" -gt "$1" ]; do
echo "Waiting for ${runningJobs} -> $1 Jobs"
#jobs -r | wc -l | tr -d " "
runningJobs=$(jobs -pr | wc -l)
sleep 1
done
}
[ -d fmlist ] || mkdir fmlist
pagesize=1
pageindex=1
urllist="$URLMK/fmList.php?pagesize=$pagesize&pageindex=$pageindex";
jsonlist=$(curl -s "$urllist")
[[ $jsonlist == \"* ]] && jsonlist=$(eval echo "$jsonlist")
main="def main():
import sys, json
print(json.load(sys.stdin)['recordcount'])"
py=$(echo -e "$main\nmain()")
#echo $py
pagesize=$(echo "$jsonlist" | python3 -c "$py")
echo $pagesize
urllist="$URLMK/fmList.php?pagesize=$pagesize&pageindex=$pageindex"
jsonlist=$(curl -s "$urllist")
[[ $jsonlist == \"* ]] && jsonlist=$(eval echo "$jsonlist")
echo $jsonlist > "fmlist/$pageindex.json"
urllist="$WWW/fmweb/html/index.html"
jsonlist=$(curl -s -4 "$urllist"|grep 'var radioData = '|sed 's/^var radioData = /{"data":/;s/;$/}/')
echo "$jsonlist" > "fmlist.json"
#echo "$jsonlist"
main="def main():
import sys, json
fmlist=json.load(sys.stdin)
for fm in fmlist['data']:
print(fm['fmid'])"
py=$(echo -e "$main\nmain()")
#echo "$jsonlist"
#echo "$py"
loop="YES"
count=0
for fmid in $(echo "$jsonlist" | python3 -c "$py")
do
[ -z $loop ] && break
waitForJobs 22
count=$((count+1))
echo "fmid=$fmid $count/$pagesize"
offset="0"
for offset in {0..600..20}
do
[ -z $loop ] && break
function fmserviceretrySongs(){
#$FMSERVICERETRY/v1/app_song_list_offset?dfid=4WWbsd4ayqvC0diIQl2sB5Fx
#{"uid":"0","appid":"1005","clientver":"10259","mid":"283772038997640891902313795880766264264","clienttime":"1649117508","key":"24d3bf3d4c6fdd1834691aa355ddcf0d","ishq":0,"area_code":"1","data":[{"fmid":"5","singername":"中文经典","fmtype":"2","offset":"1","size":19}],"get_tracker":1}
#{"uid":"0","appid":"1005","clientver":"10259","mid":"283772038997640891902313795880766264264","clienttime":"1649143065","key":"291945d5873cd1cfd9e1c37c7e63b03b","ishq":0,"area_code":"1","data":[{"fmid":"11","singername":"轻音乐","fmtype":"2","offset":"","size":19}],"get_tracker":1}
urlsongs="$FMSERVICERETRY/v1/app_song_list_offset"
clienttime=$(date +%s)
postdata='{"appid":"1005","clientver":"10259","mid":"283772038997640891902313795880766264264","clienttime":"1649117508","key":"24d3bf3d4c6fdd1834691aa355ddcf0d","data":[{"fmid":"'$fmid'","fmtype":"2","offset":"'$offset'","size":20}]}'
#echo "$postdata"
jsonsongs=$(curl -v -X POST "$urlsongs" -H 'Content-Type: application/json' -d "$postdata")
[[ $jsonsongs == \"* ]] && jsonsongs=$(eval echo "$jsonsongs")
if echo "$jsonsongs" | grep -q '"songs":\[{'; then
[ -d "fmserviceretry/$fmid" ] || mkdir -p "fmserviceretry/$fmid"
echo "$jsonsongs" > "fmserviceretry/$fmid/$offset.json"
fi
}
#fmserviceretrySongs &
function gatewaySongs(){
#$URLMK/fmSongs.php?size=20&fmid=$fmid&offset=$offset
#offset=$(grep -o 'offset[^,]*\",' "$fsongs" |grep -o '%7B.*%7D')n
urlsongs="$GATEWAY/openapicdn/broadcast/v2/get_songlist?radio_id=$fmid&offset=$offset&pagesize=20"
jsonsongs=$(curl -s "$urlsongs")
[[ $jsonsongs == \"* ]] && jsonsongs=$(eval echo "$jsonsongs")
main="def main():
import sys, json
fmsongs=json.load(sys.stdin)
if fmsongs['data']['songlist'] is None:
print("0")
else:
print(len(fmsongs['data']['songlist']))"
py=$(echo -e "$main\nmain()")
lensongs=$(echo "$jsonsongs" | python3 -c "$py")
#echo "offset=$offset len=$lensongs"
if [ "$lensongs" -gt "0" ]; then
[ -d "gateway/$fmid" ] || mkdir -p "gateway/$fmid"
echo $jsonsongs > "gateway/$fmid/$offset.json"
#if echo "$jsonhash" | grep -q '"error":"您操作太频繁了,请稍后再试"'; then
# loop=""
# echo "QUIT"
#fi
#sleep 10
fi
}
gatewaySongs &
done
done
waitForJobs 0
curl -k -o bing.json "https://bing.com/HPImageArchive.aspx?format=js&idx=0&n=8"
curl -k -o pixabay.json "${{ secrets.PIXABAY }}"
if [ $? -eq 0 ]; then
sed -i 's|\"largeImageURL"|\"_largeImageURL"|g' pixabay.json
sed -i 's|\"previewURL"|\"largeImageURL"|g' pixabay.json
sed -i 's|\_150.jpg|\_960_720.jpg|g' pixabay.json
fi
curl -k -o vladstudio.json "https://vlad.studio/api/v3/art/?client=${{ secrets.VLADSTUDIO }}&format=json&has_wall=1&limit=600"
if [ $? -eq 0 ]; then
sed -i 's|api\\\/v3\\\/download?client=.\{24\}&filename=|wallpaper-image\\\/|g' vladstudio.json
sed -i 's|\&size|?size|g' vladstudio.json
fi
curl -k -o unsplash.json "${{ secrets.UNSPLASH }}1"
if [ $? -eq 0 ]; then
for p in 2 3 4 5 6 ; do
curl -k -o unsplash_tmp.json "${{ secrets.UNSPLASH }}$p"
if [ $? -eq 0 ]; then
json=$(cat unsplash.json)
json=${json%*\]}
tmp=$(cat unsplash_tmp.json)
tmp=${tmp#*\[}
echo "$json,$tmp" > unsplash.json
fi
done
fi
- name: Cleanup
run: |
rm -f upload.txt
rm -f unsplash_tmp.json
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Action Auto"