Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
jsdfhasuh authored Jan 28, 2023
1 parent 61fd6d5 commit fce643a
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions cookie_renow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

####

vertex_host="http://192.168.1.128:3000" ###填入vertex的地址
cookie_cloud_host="http://192.168.1.125:8088/cookie" ###填入cookie_cloud的地址
cookie_password="csASVX41KUHa49pguigyvM" ###填入cookie_cloud的密码
password="95f0f96bc5836c39387a66c1ba766367" ###填入vertex的密码,通过f12获取 或者自己原来的密码 md5加密32位 小写
username="admin" ###填入vertex的用户名
####


DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DIR_past="$(echo "$DIR" | grep -oP "/.*/"|sed -r "s#(/$)##g")"
echo $DIR
echo $DIR_past
log=$DIR/cookie_renow.log
cookie=$DIR/cookie.json
site=$DIR/site.json
subscribe=$DIR/subscribe.json
set -x
echo "$(curl -X POST -d "password=$cookie_password" "$cookie_cloud_host/get"|jq '.cookie_data')" > $cookie
vertex_cookie="$(curl -i --header 'Referer: '$vertex_host'' --data 'username='$username'&password='$password'' "$vertex_host/api/user/login" | grep -Eo "Set.Cookie.*"|sed -r "s#Set.Cookie: ##g"|sed -r "s#\r##g")"
echo $vertex_cookie
exec >$log 2>&1

get_cookie()
{
final_cookie=""
domain=$1
echo $domain
element="$(cat cookie.json | jq '."'$domain'"')"
time="$(echo $element | awk -v RS='domain' 'END {print --NR}' )"
final_cookie=""
for i in $(seq 1 $time)
do
element_name="$(echo $element | jq '.['$(($i-1))'].name'| sed -r "s#\"##g"|sed -r "s#[\]##g")"
element_value="$(echo $element | jq '.['$(($i-1))'].value'| sed -r "s#\"##g"|sed -r "s#[\]##g")"
echo "$element_name""=""$element_value"
final_cookie="$final_cookie""$element_name""=""$element_value"";"
done
final_cookie="$(echo $final_cookie|sed -r "s#;\$##g"|sed -r "s#\r##g")"
echo $final_cookie
}

renow_site()
{
echo "$(curl --cookie "$vertex_cookie" -H "Content-Type: application/json" "$vertex_host/api/site/list"|jq '.data.siteList')" > $site
time="$(cat $site | grep -c "cookie")"
mkdir -p $DIR/allsite
for i in $(seq 1 $time)
do

vertex_name="$(cat $site | jq '.['$(($i-1))'].name'| sed -r "s#\"##g"|sed -r "s#[\]##g")"
echo "$(cat $site|jq '.['$(($i-1))']')" > $DIR/allsite/"$vertex_name".json
vertex_site="$(cat $site | jq '.['$(($i-1))'].index'| sed -r "s#\"##g"|sed -r "s#[\]##g"|awk 'BEGIN {FS="/"} {print $3}')"
get_cookie "$vertex_site"
echo "$(cat $DIR/allsite/"$vertex_name".json | jq --arg v $final_cookie '.cookie=$v')" > $DIR/allsite/"$vertex_name".json
curl -X POST --cookie "$vertex_cookie" -H "Content-Type: application/json" --data @"$DIR/allsite/"$vertex_name".json" "$vertex_host/api/site/modify"
sleep 5
done
}

renow_douban()
{
echo "$(curl --cookie "$vertex_cookie" -H "Content-Type: application/json" "$vertex_host/api/subscribe/list"|jq '.data')" > $subscribe
time="$(cat $subscribe | grep -c "categories")"
mkdir -p $DIR/allsubscribe
for i in $(seq 1 $time)
do
vertex_name="$(cat $subscribe | jq '.['$(($i-1))'].alias'| sed -r "s#\"##g"|sed -r "s#[\]##g")"
echo "$(cat $subscribe|jq '.['$(($i-1))']')" > $DIR/allsubscribe/"$vertex_name".json
get_cookie ".douban.com"
echo "$(cat $DIR/allsubscribe/"$vertex_name".json | jq --arg v $final_cookie '.cookie=$v')" > $DIR/allsubscribe/"$vertex_name".json
curl -X POST --cookie "$vertex_cookie" -H "Content-Type: application/json" --data @"$DIR/allsubscribe/"$vertex_name".json" "$vertex_host/api/subscribe/modify"
sleep 5
done
}

renow_douban
renow_site
set +x

0 comments on commit fce643a

Please sign in to comment.