|
|
|
@ -163,7 +163,7 @@ today=`date "+%Y-%m-%d"` |
|
|
|
|
_today=`date "+%Y%m%d"` |
|
|
|
|
rank_json=$today.json |
|
|
|
|
|
|
|
|
|
rule=`cat $config_file | jq .rule|jq to_entries|jq 'map("sed -e \"s/\\\\"+.key+"/\\\\"+.value+"/g\"")'|jq -r '.[]'|sed ':a;N;s/\n/|/;t a;'` |
|
|
|
|
rule='sed -e "s/\\&/\\&/g"|sed -e "s/\\</\\</g"|sed -e "s/\\>/\\>/g"' |
|
|
|
|
|
|
|
|
|
sleepText=`cat $config_file | jq .sleep.text` |
|
|
|
|
sleepImage=`cat $config_file | jq .sleep.image` |
|
|
|
@ -175,7 +175,7 @@ then |
|
|
|
|
curl -v $rank_url >$rank_json |
|
|
|
|
fi |
|
|
|
|
length=`jq '.contents|length' $rank_json` |
|
|
|
|
fileCountSize=0 |
|
|
|
|
|
|
|
|
|
fileList='' |
|
|
|
|
media='' |
|
|
|
|
fileCount=0 |
|
|
|
@ -279,8 +279,8 @@ do |
|
|
|
|
original_file_size=`du -b $original_file_name|awk '{print $1}'` |
|
|
|
|
if [ $original_file_size -gt $maxFileSize ] |
|
|
|
|
then |
|
|
|
|
echo "${original_file_name}文件体积超过${maxFileSize}字节,需要在线压缩" |
|
|
|
|
result=`curl -v -X POST -d "{\"apikey\": \"$convertio_apikey\", \"input\":\"upload\", \"outputformat\":\"jpeg\"}" http://api.convertio.co/convert` |
|
|
|
|
echo "${original_file_name}文件体积:${original_file_size}字节超过${maxFileSize}字节限制,需要在线压缩" |
|
|
|
|
result=`curl -v -X POST -d "{\"apikey\": \"$convertio_apikey\", \"input\":\"upload\", \"outputformat\":\"webp\"}" http://api.convertio.co/convert` |
|
|
|
|
|
|
|
|
|
if [ `echo $result|jq -r .status` = ok ] |
|
|
|
|
then |
|
|
|
@ -292,10 +292,11 @@ do |
|
|
|
|
do |
|
|
|
|
sleep 10 |
|
|
|
|
result=`curl -v -X GET http://api.convertio.co/convert/$id/status` |
|
|
|
|
echo "转换响应:$result" |
|
|
|
|
if [[ `echo $result|jq -r .status` = ok && `echo $result|jq -r .data.step` = finish ]] |
|
|
|
|
then |
|
|
|
|
echo $result|jq .data.output.url|xargs curl -v -o $original_file_name |
|
|
|
|
PutObject $original_file_name |
|
|
|
|
echo $result|jq .data.output.url|xargs curl -v -o $webp_file_name |
|
|
|
|
PutObject $webp_file_name |
|
|
|
|
break |
|
|
|
|
elif [ `echo $result|jq -r .status` = error ] |
|
|
|
|
then |
|
|
|
@ -342,20 +343,23 @@ do |
|
|
|
|
fileList="$fileList -F $webp_file_name=@$webp_file_name" |
|
|
|
|
fileCount=$((fileCount + 1)) |
|
|
|
|
fileSize=`du $webp_file_name | awk '{print $1}'` |
|
|
|
|
fileCountSize=$((fileCountSize + fileSize)) |
|
|
|
|
echo "fileCountSize=$fileCountSize,fileCount=$fileCount" |
|
|
|
|
echo "fileCount=$fileCount" |
|
|
|
|
fi |
|
|
|
|
if [[ $fileCount -eq $maxFileCount ]] |
|
|
|
|
then |
|
|
|
|
command="curl -v -F chat_id=$chat_id $fileList -F media='[`echo $media | cut -c 2-`]' $baseApi/sendMediaGroup" |
|
|
|
|
echo "上传图片命令:$command" |
|
|
|
|
result=`bash -c "$command"` |
|
|
|
|
message_id=`echo $result|jq .result.message_id` |
|
|
|
|
echo "message_id:$message_id" |
|
|
|
|
sleep $sleepImage |
|
|
|
|
curl -v -d chat_id=$chat_id -d reply_to_message_id=$message_id -d text="以上作品日榜排名分别是 #排名${start_rank}_${end_rank} #rank${start_rank}_${end_rank} ,点击作品可以查看pid/标题/画师/tag信息." $baseApi/sendMessage |
|
|
|
|
|
|
|
|
|
if [ `echo $result|jq .ok` == "true" ] |
|
|
|
|
then |
|
|
|
|
sleep $sleepImage |
|
|
|
|
text="以上作品日榜排名分别是 #排名${start_rank}_${end_rank} #rank${start_rank}_${end_rank} ,点击作品可以查看pid/标题/画师/tag信息." |
|
|
|
|
else |
|
|
|
|
text="#排名${start_rank}_${end_rank} #rank${start_rank}_${end_rank}作品上传失败,请联系管理员" |
|
|
|
|
fi |
|
|
|
|
curl -v -d chat_id=$chat_id -d text=$text $baseApi/sendMessage |
|
|
|
|
sleep $sleepText |
|
|
|
|
fileCountSize=0 |
|
|
|
|
fileList='' |
|
|
|
|
media='' |
|
|
|
|
fileCount=0 |
|
|
|
@ -367,7 +371,8 @@ done |
|
|
|
|
next_expected_at=`curl -v https://cronitor.io/api/monitors/$CronitorJobName -u $CronitorKey:''|jq .next_expected_at` |
|
|
|
|
curl -v -d chat_id=$chat_id -d text="以上就是$today日榜前${length}名作品,本次推送完毕,下次推送时间预计是`date -d @$next_expected_at '+%Y-%m-%d %H:%M:%S'`,如有问题请联系管理员。 #date$_today #日期$_today " $baseApi/sendMessage |
|
|
|
|
|
|
|
|
|
find -type f -mtime +7|grep html |
|
|
|
|
find -type f -mtime +7|grep json |
|
|
|
|
find -type f -mtime +7|grep webp |
|
|
|
|
find -type f -mtime +7|grep html|xargs rm -f |
|
|
|
|
find -type f -mtime +7|grep json|xargs rm -f |
|
|
|
|
find -type f -mtime +7|grep webp|xargs rm -f |
|
|
|
|
find -type f -mtime +7|grep info|xargs rm -f |
|
|
|
|
DeleteMultipleObjects |