1.删除config。json rule配置项

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

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

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