1.删除config。json rule配置项

2.修复自动清理文件逻辑
3.上传图片失败增加错误提示
4.在线压缩格式修改为webp
master
panqihua 2 years ago
parent e8116a3560
commit e5fd30b24d
  1. 1
      pixiv/config.json.example
  2. 37
      pixiv/pixiv.sh

@ -4,7 +4,6 @@
"chatId": "推送目标聊天的唯一标识符或目标频道的用户名",
"mode": "Pixiv排行榜类型,有效值:daily/weekly/monthly/rookie/daily_r18/weekly_r18/male_r18/female_r18/r18g,分别是日榜/周榜/月榜/新人榜/日榜r18/周榜r18/受男性欢迎r18/受女性欢迎r18/r18g",
"content": "Pixiv排行榜类型,有效值:illust/ugoira/manga/,分别是插画/动图/漫画",
"rule":{"匹配需要转义的内容":"转换后的值","&amp;":"&","&lt;":"<"},
"sleep":{
"text":10,
"image":60

@ -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/\\&amp;/\\&/g"|sed -e "s/\\&lt;/\\</g"|sed -e "s/\\&gt;/\\>/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
Loading…
Cancel
Save