|
|
@ -163,7 +163,7 @@ today=`date "+%Y-%m-%d"` |
|
|
|
_today=`date "+%Y%m%d"` |
|
|
|
_today=`date "+%Y%m%d"` |
|
|
|
rank_json=$today.json |
|
|
|
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` |
|
|
|
sleepText=`cat $config_file | jq .sleep.text` |
|
|
|
sleepImage=`cat $config_file | jq .sleep.image` |
|
|
|
sleepImage=`cat $config_file | jq .sleep.image` |
|
|
@ -175,7 +175,7 @@ then |
|
|
|
curl -v $rank_url >$rank_json |
|
|
|
curl -v $rank_url >$rank_json |
|
|
|
fi |
|
|
|
fi |
|
|
|
length=`jq '.contents|length' $rank_json` |
|
|
|
length=`jq '.contents|length' $rank_json` |
|
|
|
fileCountSize=0 |
|
|
|
|
|
|
|
fileList='' |
|
|
|
fileList='' |
|
|
|
media='' |
|
|
|
media='' |
|
|
|
fileCount=0 |
|
|
|
fileCount=0 |
|
|
@ -279,8 +279,8 @@ do |
|
|
|
original_file_size=`du -b $original_file_name|awk '{print $1}'` |
|
|
|
original_file_size=`du -b $original_file_name|awk '{print $1}'` |
|
|
|
if [ $original_file_size -gt $maxFileSize ] |
|
|
|
if [ $original_file_size -gt $maxFileSize ] |
|
|
|
then |
|
|
|
then |
|
|
|
echo "${original_file_name}文件体积超过${maxFileSize}字节,需要在线压缩" |
|
|
|
echo "${original_file_name}文件体积:${original_file_size}字节超过${maxFileSize}字节限制,需要在线压缩" |
|
|
|
result=`curl -v -X POST -d "{\"apikey\": \"$convertio_apikey\", \"input\":\"upload\", \"outputformat\":\"jpeg\"}" http://api.convertio.co/convert` |
|
|
|
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 ] |
|
|
|
if [ `echo $result|jq -r .status` = ok ] |
|
|
|
then |
|
|
|
then |
|
|
@ -292,10 +292,11 @@ do |
|
|
|
do |
|
|
|
do |
|
|
|
sleep 10 |
|
|
|
sleep 10 |
|
|
|
result=`curl -v -X GET http://api.convertio.co/convert/$id/status` |
|
|
|
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 ]] |
|
|
|
if [[ `echo $result|jq -r .status` = ok && `echo $result|jq -r .data.step` = finish ]] |
|
|
|
then |
|
|
|
then |
|
|
|
echo $result|jq .data.output.url|xargs curl -v -o $original_file_name |
|
|
|
echo $result|jq .data.output.url|xargs curl -v -o $webp_file_name |
|
|
|
PutObject $original_file_name |
|
|
|
PutObject $webp_file_name |
|
|
|
break |
|
|
|
break |
|
|
|
elif [ `echo $result|jq -r .status` = error ] |
|
|
|
elif [ `echo $result|jq -r .status` = error ] |
|
|
|
then |
|
|
|
then |
|
|
@ -342,20 +343,23 @@ do |
|
|
|
fileList="$fileList -F $webp_file_name=@$webp_file_name" |
|
|
|
fileList="$fileList -F $webp_file_name=@$webp_file_name" |
|
|
|
fileCount=$((fileCount + 1)) |
|
|
|
fileCount=$((fileCount + 1)) |
|
|
|
fileSize=`du $webp_file_name | awk '{print $1}'` |
|
|
|
fileSize=`du $webp_file_name | awk '{print $1}'` |
|
|
|
fileCountSize=$((fileCountSize + fileSize)) |
|
|
|
echo "fileCount=$fileCount" |
|
|
|
echo "fileCountSize=$fileCountSize,fileCount=$fileCount" |
|
|
|
|
|
|
|
fi |
|
|
|
fi |
|
|
|
if [[ $fileCount -eq $maxFileCount ]] |
|
|
|
if [[ $fileCount -eq $maxFileCount ]] |
|
|
|
then |
|
|
|
then |
|
|
|
command="curl -v -F chat_id=$chat_id $fileList -F media='[`echo $media | cut -c 2-`]' $baseApi/sendMediaGroup" |
|
|
|
command="curl -v -F chat_id=$chat_id $fileList -F media='[`echo $media | cut -c 2-`]' $baseApi/sendMediaGroup" |
|
|
|
echo "上传图片命令:$command" |
|
|
|
echo "上传图片命令:$command" |
|
|
|
result=`bash -c "$command"` |
|
|
|
result=`bash -c "$command"` |
|
|
|
message_id=`echo $result|jq .result.message_id` |
|
|
|
|
|
|
|
echo "message_id:$message_id" |
|
|
|
if [ `echo $result|jq .ok` == "true" ] |
|
|
|
sleep $sleepImage |
|
|
|
then |
|
|
|
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 |
|
|
|
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 |
|
|
|
sleep $sleepText |
|
|
|
fileCountSize=0 |
|
|
|
|
|
|
|
fileList='' |
|
|
|
fileList='' |
|
|
|
media='' |
|
|
|
media='' |
|
|
|
fileCount=0 |
|
|
|
fileCount=0 |
|
|
@ -367,7 +371,8 @@ done |
|
|
|
next_expected_at=`curl -v https://cronitor.io/api/monitors/$CronitorJobName -u $CronitorKey:''|jq .next_expected_at` |
|
|
|
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 |
|
|
|
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 html|xargs rm -f |
|
|
|
find -type f -mtime +7|grep json |
|
|
|
find -type f -mtime +7|grep json|xargs rm -f |
|
|
|
find -type f -mtime +7|grep webp |
|
|
|
find -type f -mtime +7|grep webp|xargs rm -f |
|
|
|
|
|
|
|
find -type f -mtime +7|grep info|xargs rm -f |
|
|
|
DeleteMultipleObjects |
|
|
|
DeleteMultipleObjects |