forked from maybe1229/jd-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport_sharecodes.sh
98 lines (89 loc) · 3.03 KB
/
export_sharecodes.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env bash
## Author: Evine Deng
## Source: https://github.com/EvineDeng/jd-base
## Modified: 2021-01-12
## Version: v3.4.0
## 文件路径、脚本网址、文件版本以及各种环境的判断
if [ -f /proc/1/cgroup ]
then
isDocker=$(cat /proc/1/cgroup | grep docker)
else
isDocker=""
fi
if [ -z "${isDocker}" ]
then
ShellDir=$(cd $(dirname $0); pwd)
else
ShellDir=${JD_DIR}
fi
LogDir=${ShellDir}/log
ScriptsDir=${ShellDir}/scripts
FileConf=${ShellDir}/config/config.sh
DateToday=$(date "+%Y-%m-%d")
isTermux=${ANDROID_RUNTIME_ROOT}${ANDROID_ROOT}
if [[ ${isTermux} ]]
then
Opt="P"
else
Opt="E"
fi
## 导出互助码子程序
function Cat_Scodes {
cd ${LogDir}/jd_$1
for log in $(ls -r)
do
codes=$(grep -${Opt} $2 ${log} | perl -pe "s| ||")
[ -n "${codes}" ] && break
done
echo ${codes}
}
## 导出口袋书店互助码
function Cat_ScodesBookShop {
cd ${LogDir}/jd_bookshop
for log in $(ls -r)
do
codes=$(perl -pe "s|信息获取成功\n||g" ${log} | grep -${Opt} "您的好友助力码为" | perl -pe "{s|您的好友助力码为||g; s|用户||g}")
[ -n "${codes}" ] && break
done
echo ${codes}
}
## 导出签到领现金互助码
function Cat_ScodesCash {
cd ${LogDir}/jd_cash
for log in $(ls -r)
do
codes=$(perl -0777 -pe "s|\*+\n+||g" ${log} | grep -${Opt} "您的助力码为" | perl -pe "{s|\*+开始||g; s|您的助力码为|:|g}")
[ -n "${codes}" ] && break
done
echo ${codes}
}
## 汇总
function Cat_All {
echo -e "本脚本从最后一个正常的日志中寻找互助码,某些账号缺失则代表在最后一个正常的日志中没有找到。"
echo -e "\n东东农场:"
Cat_Scodes fruit "的东东农场好友互助码" | perl -pe "s|的东东农场好友互助码||g"
echo -e "\n东东萌宠:"
Cat_Scodes pet "的东东萌宠好友互助码" | perl -pe "s|的东东萌宠好友互助码||g"
echo -e "\n种豆得豆:"
Cat_Scodes plantBean "的京东种豆得豆好友互助码" | perl -pe "s|的京东种豆得豆好友互助码||g"
echo -e "\n京喜工厂:"
Cat_Scodes dreamFactory "的京喜工厂好友互助码" | perl -pe "s|的京喜工厂好友互助码||g"
echo -e "\n东东工厂:"
Cat_Scodes jdfactory "的东东工厂好友互助码" | perl -pe "s|的东东工厂好友互助码||g"
echo -e "\n疯狂的JOY:"
Cat_Scodes crazy_joy "的crazyJoy任务好友互助码" | perl -pe "s|的crazyJoy任务好友互助码||g"
echo -e "\n京东赚赚:"
Cat_Scodes jdzz "的京东赚赚好友互助码" | perl -pe "s|的京东赚赚好友互助码||g"
echo -e "\n京喜农场:"
Cat_Scodes jxnc "的京喜农场好友互助码" | perl -pe "s|的京喜农场好友互助码||g"
echo -e "\n口袋书店:"
Cat_ScodesBookShop
echo -e "\n签到领现金:"
Cat_ScodesCash
}
## 执行并写入日志
LogTime=$(date "+%Y-%m-%d-%H-%M-%S")
LogFile="${LogDir}/export_sharecodes/${LogTime}.log"
[ ! -d "${LogDir}/export_sharecodes" ] && mkdir -p ${LogDir}/export_sharecodes
touch ${LogFile}
Cat_All | perl -pe "s| |\n|g" | tee ${LogFile}