forked from DDS-Derek/xiaoya-alist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
all_in_one.sh
4882 lines (4357 loc) · 178 KB
/
all_in_one.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# shellcheck shell=bash
# shellcheck disable=SC2086
# shellcheck source=/dev/null
PATH=${PATH}:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
export PATH
#
# ——————————————————————————————————————————————————————————————————————————————————
# __ ___ _ _ _
# \ \ / (_) /\ | (_) | |
# \ V / _ __ _ ___ _ _ __ _ / \ | |_ ___| |_
# > < | |/ _` |/ _ \| | | |/ _` | / /\ \ | | / __| __|
# / . \| | (_| | (_) | |_| | (_| | / ____ \| | \__ \ |_
# /_/ \_\_|\__,_|\___/ \__, |\__,_| /_/ \_\_|_|___/\__|
# __/ |
# |___/
#
# Copyright (c) 2024 DDSRem <https://blog.ddsrem.com>
#
# This is free software, licensed under the GNU General Public License v3.0.
#
# ——————————————————————————————————————————————————————————————————————————————————
#
DATE_VERSION="v1.7.4-2024_10_05_10_37"
#
# ——————————————————————————————————————————————————————————————————————————————————
amilys_embyserver_latest_version=4.8.10.0
emby_embyserver_latest_version=4.8.10.0
# ——————————————————————————————————————————————————————————————————————————————————
Sky_Blue="\e[36m"
Blue="\033[34m"
Green="\033[32m"
Red="\033[31m"
Yellow='\033[33m'
Font="\033[0m"
INFO="[${Green}INFO${Font}]"
ERROR="[${Red}ERROR${Font}]"
WARN="[${Yellow}WARN${Font}]"
function INFO() {
echo -e "${INFO} ${1}"
}
function ERROR() {
echo -e "${ERROR} ${1}"
}
function WARN() {
echo -e "${WARN} ${1}"
}
# shellcheck disable=SC2034
mirrors=(
"docker.io"
"registry-docker-hub-latest-9vqc.onrender.com"
"docker.fxxk.dedyn.io"
"docker.chenby.cn"
"dockerproxy.com"
"hub.uuuadc.top"
"docker.jsdelivr.fyi"
"docker.registry.cyou"
"dockerhub.anzu.vip"
"docker.luyao.dynv6.net"
"freeno.xyz"
"docker.1panel.live"
"dockerpull.com"
)
function root_need() {
if [[ $EUID -ne 0 ]]; then
ERROR '此脚本必须以 root 身份运行!'
exit 1
fi
}
function wait_emby_start() {
start_time=$(date +%s)
CONTAINER_NAME="$(cat "${DDSREM_CONFIG_DIR}"/container_name/xiaoya_emby_name.txt)"
TARGET_LOG_LINE_SUCCESS="All entry points have started"
while true; do
line=$(docker logs "$CONTAINER_NAME" 2>&1 | tail -n 10)
echo -e "$line"
if [[ "$line" == *"$TARGET_LOG_LINE_SUCCESS"* ]]; then
break
fi
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if [ "$elapsed_time" -gt 600 ]; then
WARN "Emby 未正常启动超时 10 分钟!"
break
fi
sleep 8
done
}
function wait_xiaoya_start() {
start_time=$(date +%s)
TARGET_LOG_LINE_SUCCESS="success load storage: [/©️"
while true; do
line=$(docker logs "$(cat ${DDSREM_CONFIG_DIR}/container_name/xiaoya_alist_name.txt)" 2>&1 | tail -n 10)
echo -e "$line"
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if [[ "$line" == *"$TARGET_LOG_LINE_SUCCESS"* ]]; then
if [ "$elapsed_time" -gt 20 ]; then
break
fi
fi
if [ "$elapsed_time" -gt 600 ]; then
WARN "小雅alist 未正常启动超时 10 分钟!"
break
fi
sleep 8
done
}
function check_quark_cookie() {
if [[ ! -f "${1}/quark_cookie.txt" ]] && [[ ! -s "${1}/quark_cookie.txt" ]]; then
return 1
fi
local cookie user_agent url headers response status state_url sign_daily_reward sign_daily_reward_mb url2 response2 member member_type vip_88
cookie=$(head -n1 "${1}/quark_cookie.txt")
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch"
url="https://drive-pc.quark.cn/1/clouddrive/config?pr=ucpro&fr=pc&uc_param_str="
headers="Cookie: $cookie; User-Agent: $user_agent; Referer: https://pan.quark.cn"
response=$(curl -s -D - -H "$headers" "$url")
status=$(echo "$response" | grep -i status | cut -f2 -d: | cut -f1 -d,)
if [ "$status" == "401" ]; then
ERROR "无效夸克 Cookie"
return 1
elif [ "$status" == "200" ]; then
url2="https://drive-pc.quark.cn/1/clouddrive/member?pr=ucpro&fr=pc&uc_param_str=&fetch_subscribe=true&_ch=home&fetch_identity=true"
response2=$(curl -s -H "$headers" "$url2")
member=$(echo $response2 | grep -o '"member_type":"[^"]*"' | sed 's/"member_type":"\(.*\)"/\1/')
if [ $member == 'EXP_SVIP' ] || [ $member == 'SVIP' ]; then
vip_88=$(echo $response2 | grep -o '"vip88_new":[t|f]' | cut -f2 -d:)
if [ $vip_88 == 't' ]; then
member_type="88VIP会员"
else
member_type="SVIP会员"
fi
elif [ $member == 'NORMAL' ]; then
member_type="普通用户"
else
member_type="${member//\"/}会员"
fi
INFO "有效 夸克 Cookie,${member_type}"
state_url="https://drive-m.quark.cn/1/clouddrive/capacity/growth/info?pr=ucpro&fr=pc&uc_param_str="
response=$(curl -s -H "$headers" "$state_url")
sign_daily_reward=$(echo "$response" | cut -f6 -d\{ | cut -f4 -d: | cut -f1 -d,)
if [ -n "${sign_daily_reward}" ]; then
sign_daily_reward_mb=$(echo "$sign_daily_reward 1024 1024" | awk '{printf "%.2f\n", $1 / ($2 * $3)}')
INFO "夸克签到获取 $sign_daily_reward_mb MB"
fi
return 0
else
ERROR "请求失败,请检查 Cookie 或网络连接是否正确。"
return 1
fi
}
function check_uc_cookie() {
if [[ ! -f "${1}/uc_cookie.txt" ]] && [[ ! -s "${1}/uc_cookie.txt" ]]; then
return 1
fi
local cookie user_agent url headers response status referer set_cookie
cookie=$(head -n1 "${1}/uc_cookie.txt")
referer="https://drive.uc.cn"
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch"
url="https://pc-api.uc.cn/1/clouddrive/file/sort?pr=UCBrowser&fr=pc&pdir_fid=0&_page=1&_size=50&_fetch_total=1&_fetch_sub_dirs=0&_sort=file_type:asc,updated_at:desc"
headers="Cookie: $cookie; User-Agent: $user_agent; Referer: $referer"
response=$(curl -s -D - -H "$headers" "$url")
set_cookie=$(echo "$response" | grep -i "^Set-Cookie:" | sed 's/Set-Cookie: //')
status=$(echo "$response" | grep -i status | cut -f2 -d: | cut -f1 -d,)
if [ "$status" == "401" ]; then
ERROR "无效 UC Cookie"
return 1
elif [ -n "${set_cookie}" ]; then
local new_puus new_cookie
new_puus=$(echo "$set_cookie" | cut -f2 -d: | cut -f1 -d\;)
new_cookie=${cookie//__puus=[^;]*/$new_puus}
echo "$new_cookie" > ${1}/uc_cookie.txt
INFO "有效 UC Cookie 并更新"
return 0
elif [ -z "${set_cookie}" ] && [ "${status}" == "200" ]; then
INFO "有效 UC Cookie"
return 0
else
ERROR "请求失败,请检查 Cookie 或网络连接是否正确。"
return 1
fi
}
function check_115_cookie() {
if [[ ! -f "${1}/115_cookie.txt" ]] && [[ ! -s "${1}/115_cookie.txt" ]]; then
return 1
fi
local cookie user_agent url headers response vip
cookie=$(head -n1 "${1}/115_cookie.txt")
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"
url="https://my.115.com/?ct=ajax&ac=nav"
headers="Cookie: $cookie; User-Agent: $user_agent; Referer: https://115.com/"
response=$(curl -s -D - -H "$headers" "$url")
vip=$(echo -e "$response" | grep -o '"vip":[^,]*' | sed 's/"vip"://')
if echo -e "${response}" | grep -q "user_id"; then
if [ $vip == "0" ]; then
INFO "有效 115 Cookie,普通用户"
else
INFO "有效 115 Cookie,VIP用户"
fi
return 0
else
ERROR "请求失败,请检查 Cookie 或网络连接是否正确。"
return 1
fi
}
function qrcode_aliyunpan_tvtoken() {
clear_qrcode_container
cpu_arch=$(uname -m)
case $cpu_arch in
"x86_64" | *"amd64"* | "aarch64" | *"arm64"* | *"armv8"* | *"arm/v8"*)
INFO "阿里云盘 TV Token 配置"
local local_ip
pull_glue_python_ddsrem
if [[ "${OSNAME}" = "macos" ]]; then
local_ip=$(ifconfig "$(route -n get default | grep interface | awk -F ':' '{print$2}' | awk '{$1=$1};1')" | grep 'inet ' | awk '{print$2}')
else
local_ip=$(ip address | grep inet | grep -v 172.17 | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | sed 's/addr://' | head -n1 | cut -f1 -d"/")
fi
if [ -z "${local_ip}" ]; then
local_ip="小雅服务器IP"
fi
INFO "请浏览器访问 http://${local_ip}:34256 并使用阿里云盘APP扫描二维码!"
docker run -i --rm \
-v "${1}:/data" \
-e LANG=C.UTF-8 \
--net=host \
ddsderek/xiaoya-glue:python \
/aliyuntvtoken/alitoken2.py
INFO "操作全部完成!"
;;
*)
WARN "目前阿里云盘 TV Token 扫码获取只支持amd64和arm64架构,你的架构是:$cpu_arch"
;;
esac
}
function qrcode_aliyunpan_refreshtoken() {
clear_qrcode_container
cpu_arch=$(uname -m)
case $cpu_arch in
"x86_64" | *"amd64"* | "aarch64" | *"arm64"* | *"armv8"* | *"arm/v8"*)
INFO "阿里云盘 Refresh Token 配置"
local local_ip command_file
pull_glue_python_ddsrem
if curl -Is https://api.xhofe.top/alist/ali/qr | head -n 1 | grep -q '200'; then
command_file="aliyuntoken.py"
INFO "使用 api.xhofe.top 地址"
elif curl -Is https://api-cf.nn.ci/alist/ali/qr | head -n 1 | grep -q '200'; then
command_file="aliyuntoken_nn.ci.py"
INFO "使用 api-cf.nn.ci 地址"
else
command_file="aliyuntoken_vercel.py"
INFO "使用 aliyuntoken.vercel.app 地址"
fi
if [[ "${OSNAME}" = "macos" ]]; then
local_ip=$(ifconfig "$(route -n get default | grep interface | awk -F ':' '{print$2}' | awk '{$1=$1};1')" | grep 'inet ' | awk '{print$2}')
else
local_ip=$(ip address | grep inet | grep -v 172.17 | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | sed 's/addr://' | head -n1 | cut -f1 -d"/")
fi
if [ -z "${local_ip}" ]; then
local_ip="小雅服务器IP"
fi
INFO "请浏览器访问 http://${local_ip}:34256 并使用阿里云盘APP扫描二维码!"
docker run -i --rm \
-v "${1}:/data" \
-e LANG=C.UTF-8 \
--net=host \
ddsderek/xiaoya-glue:python \
"/aliyuntoken/${command_file}"
INFO "操作全部完成!"
;;
*)
WARN "目前阿里云盘 Refresh Token 扫码获取只支持amd64和arm64架构,你的架构是:$cpu_arch"
;;
esac
}
function qrcode_aliyunpan_opentoken() {
clear_qrcode_container
cpu_arch=$(uname -m)
case $cpu_arch in
"x86_64" | *"amd64"* | "aarch64" | *"arm64"* | *"armv8"* | *"arm/v8"*)
INFO "阿里云盘 Open Token 配置"
local local_ip command_file
pull_glue_python_ddsrem
if curl -Is https://api.xhofe.top/alist/ali_open/qr | head -n 1 | grep -q '200'; then
command_file="aliyunopentoken.py"
INFO "使用 api.xhofe.top 地址"
else
command_file="aliyunopentoken_nn.ci.py"
INFO "使用 api-cf.nn.ci 地址"
fi
if [[ "${OSNAME}" = "macos" ]]; then
local_ip=$(ifconfig "$(route -n get default | grep interface | awk -F ':' '{print$2}' | awk '{$1=$1};1')" | grep 'inet ' | awk '{print$2}')
else
local_ip=$(ip address | grep inet | grep -v 172.17 | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | sed 's/addr://' | head -n1 | cut -f1 -d"/")
fi
if [ -z "${local_ip}" ]; then
local_ip="小雅服务器IP"
fi
INFO "请浏览器访问 http://${local_ip}:34256 并使用阿里云盘APP扫描二维码!"
docker run -i --rm \
-v "${1}:/data" \
-e LANG=C.UTF-8 \
--net=host \
ddsderek/xiaoya-glue:python \
"/aliyunopentoken/${command_file}"
INFO "操作全部完成!"
;;
*)
WARN "目前阿里云盘 Open Token 扫码获取只支持amd64和arm64架构,你的架构是:$cpu_arch"
;;
esac
}
function qrcode_115_cookie() {
clear_qrcode_container
cpu_arch=$(uname -m)
case $cpu_arch in
"x86_64" | *"amd64"* | "aarch64" | *"arm64"* | *"armv8"* | *"arm/v8"*)
INFO "115 Cookie 扫码获取"
local local_ip
pull_glue_python_ddsrem
if [[ "${OSNAME}" = "macos" ]]; then
local_ip=$(ifconfig "$(route -n get default | grep interface | awk -F ':' '{print$2}' | awk '{$1=$1};1')" | grep 'inet ' | awk '{print$2}')
else
local_ip=$(ip address | grep inet | grep -v 172.17 | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | sed 's/addr://' | head -n1 | cut -f1 -d"/")
fi
if [ -z "${local_ip}" ]; then
local_ip="小雅服务器IP"
fi
INFO "请浏览器访问 http://${local_ip}:34256 并使用阿里云盘APP扫描二维码!"
docker run -i --rm \
-v "${1}:/data" \
-e LANG=C.UTF-8 \
--net=host \
ddsderek/xiaoya-glue:python \
/115cookie/115cookie.py
INFO "操作全部完成!"
;;
*)
WARN "目前 115 Cookie 扫码获取只支持amd64和arm64架构,你的架构是:$cpu_arch"
;;
esac
}
function qrcode_quark_cookie() {
clear_qrcode_container
cpu_arch=$(uname -m)
case $cpu_arch in
"x86_64" | *"amd64"* | "aarch64" | *"arm64"* | *"armv8"* | *"arm/v8"*)
INFO "夸克 Cookie 扫码获取"
local local_ip
pull_glue_python_ddsrem
if [[ "${OSNAME}" = "macos" ]]; then
local_ip=$(ifconfig "$(route -n get default | grep interface | awk -F ':' '{print$2}' | awk '{$1=$1};1')" | grep 'inet ' | awk '{print$2}')
else
local_ip=$(ip address | grep inet | grep -v 172.17 | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | sed 's/addr://' | head -n1 | cut -f1 -d"/")
fi
if [ -z "${local_ip}" ]; then
local_ip="小雅服务器IP"
fi
INFO "请稍等片刻直到 Flask 启动后浏览器访问 http://${local_ip}:34256 并使用夸克APP扫描二维码!"
docker run -i --rm \
-v "${1}:/data" \
-e LANG=C.UTF-8 \
--net=host \
ddsderek/xiaoya-glue:python \
/quark_cookie/quark_cookie.py
INFO "操作全部完成!"
;;
*)
WARN "目前夸克 Cookie 扫码获取只支持amd64和arm64架构,你的架构是:$cpu_arch"
;;
esac
}
function qrcode_uc_cookie() {
clear_qrcode_container
cpu_arch=$(uname -m)
case $cpu_arch in
"x86_64" | *"amd64"* | "aarch64" | *"arm64"* | *"armv8"* | *"arm/v8"*)
INFO "UC Cookie 扫码获取"
local local_ip
pull_glue_python_ddsrem
if [[ "${OSNAME}" = "macos" ]]; then
local_ip=$(ifconfig "$(route -n get default | grep interface | awk -F ':' '{print$2}' | awk '{$1=$1};1')" | grep 'inet ' | awk '{print$2}')
else
local_ip=$(ip address | grep inet | grep -v 172.17 | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | sed 's/addr://' | head -n1 | cut -f1 -d"/")
fi
if [ -z "${local_ip}" ]; then
local_ip="小雅服务器IP"
fi
INFO "请稍等片刻直到 Flask 启动后浏览器访问 http://${local_ip}:34256 并使用UC浏览器APP扫描二维码!"
docker run -i --rm \
-v "${1}:/data" \
-e LANG=C.UTF-8 \
--net=host \
ddsderek/xiaoya-glue:python \
/uc_cookie/uc_cookie.py
INFO "操作全部完成!"
;;
*)
WARN "目前 UC Cookie 扫码获取只支持amd64和arm64架构,你的架构是:$cpu_arch"
;;
esac
}
function enter_aliyunpan_refreshtoken() {
while true; do
INFO "是否使用扫码自动 Token [Y/n](默认 Y)"
read -erp "Token:" choose_qrcode_aliyunpan_refreshtoken
[[ -z "${choose_qrcode_aliyunpan_refreshtoken}" ]] && choose_qrcode_aliyunpan_refreshtoken="y"
if [[ ${choose_qrcode_aliyunpan_refreshtoken} == [YyNn] ]]; then
break
else
ERROR "非法输入,请输入 [Y/n]"
fi
done
if [[ ${choose_qrcode_aliyunpan_refreshtoken} == [Yy] ]]; then
qrcode_aliyunpan_refreshtoken "${1}"
fi
while true; do
mytokenfilesize=$(cat "${1}"/mytoken.txt)
mytokenstringsize=${#mytokenfilesize}
if [ "$mytokenstringsize" -le 31 ]; then
INFO "输入你的阿里云盘 Token(32位长)"
read -erp "TOKEN:" token
token_len=${#token}
if [ "$token_len" -ne 32 ]; then
ERROR "长度不对,阿里云盘 Token是32位长"
ERROR "安装停止,请参考指南配置文件: https://xiaoyaliu.notion.site/xiaoya-docker-69404af849504fa5bcf9f2dd5ecaa75f"
else
echo "$token" > "${1}"/mytoken.txt
break
fi
else
break
fi
done
}
function settings_aliyunpan_refreshtoken() {
if [ "${2}" == "force" ]; then
enter_aliyunpan_refreshtoken "${1}"
else
mytokenfilesize=$(cat "${1}"/mytoken.txt)
mytokenstringsize=${#mytokenfilesize}
if [ "$mytokenstringsize" -le 31 ]; then
enter_aliyunpan_refreshtoken "${1}"
fi
fi
}
function enter_aliyunpan_opentoken() {
while true; do
INFO "是否使用扫码自动 Token [Y/n](默认 Y)"
read -erp "Token:" choose_qrcode_aliyunpan_opentoken
[[ -z "${choose_qrcode_aliyunpan_opentoken}" ]] && choose_qrcode_aliyunpan_opentoken="y"
if [[ ${choose_qrcode_aliyunpan_opentoken} == [YyNn] ]]; then
break
else
ERROR "非法输入,请输入 [Y/n]"
fi
done
if [[ ${choose_qrcode_aliyunpan_opentoken} == [Yy] ]]; then
qrcode_aliyunpan_opentoken "${1}"
fi
while true; do
myopentokenfilesize=$(cat "${1}"/myopentoken.txt)
myopentokenstringsize=${#myopentokenfilesize}
if [ "$myopentokenstringsize" -le 279 ]; then
INFO "输入你的阿里云盘 Open Token(280位长或者335位长)"
read -erp "OPENTOKEN:" opentoken
opentoken_len=${#opentoken}
if [[ "$opentoken_len" -ne 280 ]] && [[ "$opentoken_len" -ne 335 ]]; then
ERROR "长度不对,阿里云盘 Open Token是280位长或者335位"
ERROR "安装停止,请参考指南配置文件: https://xiaoyaliu.notion.site/xiaoya-docker-69404af849504fa5bcf9f2dd5ecaa75f"
else
echo "$opentoken" > "${1}"/myopentoken.txt
break
fi
else
break
fi
done
}
function settings_aliyunpan_opentoken() {
if [ -f "${1}/open_tv_token_url.txt" ]; then
mv "${1}/open_tv_token_url.txt" "${1}/open_tv_token_url.txt.bak"
fi
if [ "${2}" == "force" ]; then
enter_aliyunpan_opentoken "${1}"
else
myopentokenfilesize=$(cat "${1}"/myopentoken.txt)
myopentokenstringsize=${#myopentokenfilesize}
if [ "$myopentokenstringsize" -le 279 ]; then
enter_aliyunpan_opentoken "${1}"
fi
fi
}
function enter_115_cookie() {
touch ${1}/115_cookie.txt
while true; do
INFO "是否使用扫码自动 Cookie [Y/n](默认 Y)"
read -erp "Cookie:" choose_qrcode_115_cookie
[[ -z "${choose_qrcode_115_cookie}" ]] && choose_qrcode_115_cookie="y"
if [[ ${choose_qrcode_115_cookie} == [YyNn] ]]; then
break
else
ERROR "非法输入,请输入 [Y/n]"
fi
done
if [[ ${choose_qrcode_115_cookie} == [Yy] ]]; then
qrcode_115_cookie "${1}"
fi
if ! check_115_cookie "${1}"; then
WARN "扫码获取115 Cookie 失败,请手动获取!"
while true; do
INFO "输入你的 115 Cookie"
read -erp "Cookie:" set_115_cookie
echo -e "${set_115_cookie}" > ${1}/115_cookie.txt
if check_115_cookie "${1}"; then
break
fi
done
fi
}
function settings_115_cookie() {
if [ "${2}" == "force" ]; then
enter_115_cookie "${1}"
else
if [ ! -f "${1}/115_cookie.txt" ] || ! check_115_cookie "${1}"; then
while true; do
INFO "是否配置 115 Cookie [Y/n](默认 n 不配置)"
read -erp "Cookie:" choose_115_cookie
[[ -z "${choose_115_cookie}" ]] && choose_115_cookie="n"
if [[ ${choose_115_cookie} == [YyNn] ]]; then
break
else
ERROR "非法输入,请输入 [Y/n]"
fi
done
if [[ ${choose_115_cookie} == [Yy] ]]; then
enter_115_cookie "${1}"
fi
fi
fi
}
function enter_quark_cookie() {
touch ${1}/quark_cookie.txt
while true; do
INFO "是否使用扫码自动 Cookie [Y/n](默认 Y)"
read -erp "Cookie:" choose_qrcode_quark_cookie
[[ -z "${choose_qrcode_quark_cookie}" ]] && choose_qrcode_quark_cookie="y"
if [[ ${choose_qrcode_quark_cookie} == [YyNn] ]]; then
break
else
ERROR "非法输入,请输入 [Y/n]"
fi
done
if [[ ${choose_qrcode_quark_cookie} == [Yy] ]]; then
qrcode_quark_cookie "${1}"
fi
if ! check_quark_cookie "${1}"; then
while true; do
INFO "输入你的 夸克 Cookie"
read -erp "Cookie:" quark_cookie
echo -e "${quark_cookie}" > ${1}/quark_cookie.txt
if check_quark_cookie "${1}"; then
break
fi
done
fi
}
function settings_quark_cookie() {
if [ "${2}" == "force" ]; then
enter_quark_cookie "${1}"
else
if [ ! -f "${1}/quark_cookie.txt" ] || ! check_quark_cookie "${1}"; then
while true; do
INFO "是否配置 夸克 Cookie [Y/n](默认 n 不配置)"
read -erp "Cookie:" choose_quark_cookie
[[ -z "${choose_quark_cookie}" ]] && choose_quark_cookie="n"
if [[ ${choose_quark_cookie} == [YyNn] ]]; then
break
else
ERROR "非法输入,请输入 [Y/n]"
fi
done
if [[ ${choose_quark_cookie} == [Yy] ]]; then
enter_quark_cookie "${1}"
fi
fi
fi
}
function enter_uc_cookie() {
touch ${1}/uc_cookie.txt
while true; do
INFO "是否使用扫码自动 Cookie [Y/n](默认 Y)"
read -erp "Cookie:" choose_qrcode_uc_cookie
[[ -z "${choose_qrcode_uc_cookie}" ]] && choose_qrcode_uc_cookie="y"
if [[ ${choose_qrcode_uc_cookie} == [YyNn] ]]; then
break
else
ERROR "非法输入,请输入 [Y/n]"
fi
done
if [[ ${choose_qrcode_uc_cookie} == [Yy] ]]; then
qrcode_uc_cookie "${1}"
fi
if ! check_uc_cookie "${1}"; then
while true; do
INFO "输入你的 UC Cookie"
read -erp "Cookie:" uc_cookie
echo -e "${uc_cookie}" > ${1}/uc_cookie.txt
if check_uc_cookie "${1}"; then
break
fi
done
fi
}
function settings_uc_cookie() {
if [ "${2}" == "force" ]; then
enter_uc_cookie "${1}"
else
if [ ! -f "${1}/uc_cookie.txt" ] || ! check_uc_cookie "${1}"; then
while true; do
INFO "是否配置 UC Cookie [Y/n](默认 n 不配置)"
read -erp "Cookie:" choose_uc_cookie
[[ -z "${choose_uc_cookie}" ]] && choose_uc_cookie="n"
if [[ ${choose_uc_cookie} == [YyNn] ]]; then
break
else
ERROR "非法输入,请输入 [Y/n]"
fi
done
if [[ ${choose_uc_cookie} == [Yy] ]]; then
enter_uc_cookie "${1}"
fi
fi
fi
}
function enter_pikpak_account() {
touch ${1}/pikpak.txt
INFO "输入你的 PikPak 账号(手机号或邮箱)"
INFO "如果手机号,要\"+区号\",比如你的手机号\"12345678900\"那么就填\"+8612345678900\""
read -erp "PikPak_Username:" PikPak_Username
INFO "输入你的 PikPak 账号密码"
read -erp "PikPak_Password:" PikPak_Password
INFO "输入你的 PikPak X-Device-Id"
read -erp "PikPak_Device_Id:" PikPak_Device_Id
echo -e "\"${PikPak_Username}\" \"${PikPak_Password}\" \"web\" \"${PikPak_Device_Id}\"" > ${1}/pikpak.txt
}
function settings_pikpak_account() {
if [ "${2}" == "force" ]; then
enter_pikpak_account "${1}"
else
if [ ! -f "${1}/pikpak.txt" ]; then
while true; do
INFO "是否继续配置 PikPak 账号密码 [Y/n](默认 n 不配置)"
read -erp "PikPak_Set:" PikPak_Set
[[ -z "${PikPak_Set}" ]] && PikPak_Set="n"
if [[ ${PikPak_Set} == [YyNn] ]]; then
break
else
ERROR "非法输入,请输入 [Y/n]"
fi
done
if [[ ${PikPak_Set} == [Yy] ]]; then
enter_pikpak_account "${1}"
fi
fi
fi
}
function enter_ali2115() {
touch ${1}/ali2115.txt
if [ -f "${1}/115_cookie.txt" ] && check_115_cookie "${1}"; then
INFO "自动获取 115 Cookie!"
set_115_cookie="$(cat ${1}/115_cookie.txt | head -n1)"
else
while true; do
INFO "输入你的 115 Cookie"
read -erp "Cookie:" set_115_cookie
if [ -n "${set_115_cookie}" ]; then
break
fi
done
fi
while true; do
INFO "是否自动删除115转存文件 [Y/n](默认 Y)"
read -erp "purge_pan115_temp:" purge_pan115_temp
[[ -z "${purge_pan115_temp}" ]] && purge_pan115_temp="y"
if [[ ${purge_pan115_temp} == [YyNn] ]]; then
break
else
ERROR "非法输入,请输入 [Y/n]"
fi
done
while true; do
INFO "是否自动删除阿里云盘转存文件 [Y/n](默认 Y)"
read -erp "purge_ali_temp:" purge_ali_temp
[[ -z "${purge_ali_temp}" ]] && purge_ali_temp="y"
if [[ ${purge_ali_temp} == [YyNn] ]]; then
break
else
ERROR "非法输入,请输入 [Y/n]"
fi
done
INFO "输入你的 115 转存文件夹 id(默认 0)"
read -erp "dir_id:" dir_id
[[ -z "${dir_id}" ]] && dir_id=0
if [[ ${purge_pan115_temp} == [Yy] ]]; then
purge_pan115_temp=true
else
purge_pan115_temp=false
fi
if [[ ${purge_ali_temp} == [Yy] ]]; then
purge_ali_temp=true
else
purge_ali_temp=false
fi
echo -e "purge_ali_temp=${purge_ali_temp}\ncookie=\"${set_115_cookie}\"\npurge_pan115_temp=${purge_pan115_temp}\ndir_id=${dir_id}" > ${1}/ali2115.txt
}
function settings_ali2115() {
if [ "${2}" == "force" ]; then
enter_ali2115 "${1}"
else
if [ ! -f "${1}/ali2115.txt" ]; then
while true; do
INFO "是否配置 阿里转存115播放(ali2115.txt) [Y/n](默认 n 不配置)"
read -erp "ali2115:" ali2115_set
[[ -z "${ali2115_set}" ]] && ali2115_set="n"
if [[ ${ali2115_set} == [YyNn] ]]; then
break
else
ERROR "非法输入,请输入 [Y/n]"
fi
done
if [[ ${ali2115_set} == [Yy] ]]; then
enter_ali2115 "${1}"
fi
fi
fi
}
function get_config_dir() {
if docker container inspect "$(cat ${DDSREM_CONFIG_DIR}/container_name/xiaoya_alist_name.txt)" > /dev/null 2>&1; then
xiaoya_config_dir="$(docker inspect --format='{{range $v,$conf := .Mounts}}{{$conf.Source}}:{{$conf.Destination}}{{$conf.Type}}~{{end}}' "$(cat ${DDSREM_CONFIG_DIR}/container_name/xiaoya_alist_name.txt)" | tr '~' '\n' | grep bind | sed 's/bind//g' | grep ":/data$" | awk -F: '{print $1}')"
fi
if [ -n "${xiaoya_config_dir}" ]; then
xiaoya_config_dir=$(cat ${DDSREM_CONFIG_DIR}/xiaoya_alist_config_dir.txt)
INFO "小雅配置目录通过小雅容器获取"
INFO "已读取小雅Alist配置文件路径:${xiaoya_config_dir} (默认不更改回车继续,如果需要更改请输入新路径)"
read -erp "CONFIG_DIR:" CONFIG_DIR
[[ -z "${CONFIG_DIR}" ]] && CONFIG_DIR=${xiaoya_config_dir}
echo "${CONFIG_DIR}" > ${DDSREM_CONFIG_DIR}/xiaoya_alist_config_dir.txt
elif [ -f ${DDSREM_CONFIG_DIR}/xiaoya_alist_config_dir.txt ]; then
OLD_CONFIG_DIR=$(cat ${DDSREM_CONFIG_DIR}/xiaoya_alist_config_dir.txt)
INFO "已读取小雅Alist配置文件路径:${OLD_CONFIG_DIR} (默认不更改回车继续,如果需要更改请输入新路径)"
read -erp "CONFIG_DIR:" CONFIG_DIR
[[ -z "${CONFIG_DIR}" ]] && CONFIG_DIR=${OLD_CONFIG_DIR}
echo "${CONFIG_DIR}" > ${DDSREM_CONFIG_DIR}/xiaoya_alist_config_dir.txt
else
INFO "请输入配置文件目录(默认 /etc/xiaoya )"
read -erp "CONFIG_DIR:" CONFIG_DIR
[[ -z "${CONFIG_DIR}" ]] && CONFIG_DIR="/etc/xiaoya"
touch ${DDSREM_CONFIG_DIR}/xiaoya_alist_config_dir.txt
echo "${CONFIG_DIR}" > ${DDSREM_CONFIG_DIR}/xiaoya_alist_config_dir.txt
fi
if [ -d "${CONFIG_DIR}" ]; then
INFO "读取配置目录中..."
# 将所有小雅配置文件修正成 linux 格式
if [[ "${OSNAME}" = "macos" ]]; then
find ${CONFIG_DIR} -maxdepth 1 -type f -name "*.txt" -exec sed -i '' "s/\r$//g" {} \;
else
find ${CONFIG_DIR} -maxdepth 1 -type f -name "*.txt" -exec sed -i "s/\r$//g" {} \;
fi
# 设置权限
find ${CONFIG_DIR} -maxdepth 1 -type f -exec chmod 777 {} \;
fi
}
function get_media_dir() {
if [ -f ${DDSREM_CONFIG_DIR}/xiaoya_alist_config_dir.txt ]; then
XIAOYA_CONFIG_DIR=$(cat ${DDSREM_CONFIG_DIR}/xiaoya_alist_config_dir.txt)
if [ -s "${XIAOYA_CONFIG_DIR}/emby_config.txt" ]; then
# shellcheck disable=SC1091
source "${XIAOYA_CONFIG_DIR}/emby_config.txt"
# shellcheck disable=SC2154
echo "${media_dir}" > ${DDSREM_CONFIG_DIR}/xiaoya_alist_media_dir.txt
INFO "媒体库目录通过 emby_config.txt 获取"
fi
fi
if [ -f ${DDSREM_CONFIG_DIR}/xiaoya_alist_media_dir.txt ]; then
OLD_MEDIA_DIR=$(cat ${DDSREM_CONFIG_DIR}/xiaoya_alist_media_dir.txt)
INFO "已读取媒体库目录:${OLD_MEDIA_DIR} (默认不更改回车继续,如果需要更改请输入新路径)"
read -erp "MEDIA_DIR:" MEDIA_DIR
[[ -z "${MEDIA_DIR}" ]] && MEDIA_DIR=${OLD_MEDIA_DIR}
echo "${MEDIA_DIR}" > ${DDSREM_CONFIG_DIR}/xiaoya_alist_media_dir.txt
else
INFO "请输入媒体库目录(默认 /opt/media )"
read -erp "MEDIA_DIR:" MEDIA_DIR
[[ -z "${MEDIA_DIR}" ]] && MEDIA_DIR="/opt/media"
touch ${DDSREM_CONFIG_DIR}/xiaoya_alist_media_dir.txt
echo "${MEDIA_DIR}" > ${DDSREM_CONFIG_DIR}/xiaoya_alist_media_dir.txt
fi
}
function main_account_management() {
clear
local config_dir
if docker container inspect "$(cat ${DDSREM_CONFIG_DIR}/container_name/xiaoya_alist_name.txt)" > /dev/null 2>&1; then
config_dir="$(docker inspect --format='{{range $v,$conf := .Mounts}}{{$conf.Source}}:{{$conf.Destination}}{{$conf.Type}}~{{end}}' "$(cat ${DDSREM_CONFIG_DIR}/container_name/xiaoya_alist_name.txt)" | tr '~' '\n' | grep bind | sed 's/bind//g' | grep ":/data$" | awk -F: '{print $1}')"
fi
if [ -z "${config_dir}" ]; then
get_config_dir
config_dir=${CONFIG_DIR}
fi
echo -e "——————————————————————————————————————————————————————————————————————————————————"
echo -e "${Blue}账号管理${Font}\n"
echo -e "${Sky_Blue}小雅留言,会员购买指南:
基础版:阿里非会员+115会员+夸克88vip
升级版:阿里svip+115会员+夸克88vip(用TV token破解阿里svip的高速流量限制)
豪华版:阿里svip+第三方权益包+115会员+夸克svip
乞丐版:满足看emby画报但不要播放,播放用tvbox各种免费源${Font}\n"
echo -ne "${INFO} 界面加载中...${Font}\r"
echo -e "1、115 Cookie (当前:$(if CHECK_OUT=$(check_115_cookie "${config_dir}"); then echo -e "${Green}$(echo -e ${CHECK_OUT} | sed 's/\[.*\] //')${Font}"; else echo -e "${Red}错误${Font}"; fi))
2、夸克 Cookie (当前:$(if CHECK_OUT=$(check_quark_cookie "${config_dir}"); then echo -e "${Green}$(echo -e ${CHECK_OUT} | sed 's/\[.*\] //')${Font}"; else echo -e "${Red}错误${Font}"; fi))
3、阿里云盘 Refresh Token(mytoken) (当前:$(if [ -f "${config_dir}/mytoken.txt" ]; then echo -e "${Green}已配置${Font}"; else echo -e "${Red}未配置${Font}"; fi))
4、阿里云盘 Open Token(myopentoken)(当前:$(if [ -f "${config_dir}/myopentoken.txt" ]; then if [ -f "${config_dir}/open_tv_token_url.txt" ]; then echo -e "${Green}已配置 TV Token${Font}"; else echo -e "${Green}已配置${Font}"; fi; else echo -e "${Red}未配置${Font}"; fi))
5、UC Cookie (当前:$(if CHECK_OUT=$(check_uc_cookie "${config_dir}"); then echo -e "${Green}$(echo -e ${CHECK_OUT} | sed 's/\[.*\] //')${Font}"; else echo -e "${Red}错误${Font}"; fi))
6、PikPak (当前:$(if [ -f "${config_dir}/pikpak.txt" ]; then echo -e "${Green}已配置${Font}"; else echo -e "${Red}未配置${Font}"; fi))
7、阿里转存115播放(ali2115.txt) (当前:$(if [ -f "${config_dir}/ali2115.txt" ]; then echo -e "${Green}已配置${Font}"; else echo -e "${Red}未配置${Font}"; fi))"
echo -e "8、应用配置(自动重启小雅,并返回上级菜单)"
echo -e "0、返回上级(从此处退出不会重启小雅,如果更改了上述配置请手动重启)"
echo -e "——————————————————————————————————————————————————————————————————————————————————"
read -erp "请输入数字 [0-8]:" num
case "$num" in
1)
clear
settings_115_cookie "${config_dir}" force
main_account_management
;;
2)
clear
settings_quark_cookie "${config_dir}" force
main_account_management
;;
3)
clear
settings_aliyunpan_refreshtoken "${config_dir}" force
main_account_management
;;
4)
clear
settings_aliyunpan_opentoken "${config_dir}" force
main_account_management
;;
5)
clear
settings_uc_cookie "${config_dir}" force
main_account_management
;;
6)
clear
settings_pikpak_account "${config_dir}" force
main_account_management
;;
7)
clear
settings_ali2115 "${config_dir}" force
main_account_management
;;
8)
clear
if docker container inspect "$(cat ${DDSREM_CONFIG_DIR}/container_name/xiaoya_alist_name.txt)" > /dev/null 2>&1; then
INFO "重启小雅容器中..."
docker restart "$(cat ${DDSREM_CONFIG_DIR}/container_name/xiaoya_alist_name.txt)"
wait_xiaoya_start
else
WARN "您未安装小雅,请先安装小雅容器!"
fi
if docker container inspect xiaoya-115cleaner > /dev/null 2>&1; then
docker restart xiaoya-115cleaner
fi
INFO "配置保存完成,按任意键返回菜单!"
read -rs -n 1 -p ""
clear
main_xiaoya_alist
;;
0)
clear
main_xiaoya_alist
;;
*)
clear
ERROR '请输入正确数字 [0-8]'
main_account_management
;;
esac
}
function install_xiaoya_alist() {
if [ ! -d "${CONFIG_DIR}" ]; then
mkdir -p "${CONFIG_DIR}"
else
if [ -d "${CONFIG_DIR}"/mytoken.txt ]; then
rm -rf "${CONFIG_DIR}"/mytoken.txt
fi
fi
if [ ! -d "${CONFIG_DIR}/data" ]; then
mkdir -p "${CONFIG_DIR}/data"
fi
files=("mytoken.txt" "myopentoken.txt" "temp_transfer_folder_id.txt")