diff --git a/all_in_one.sh b/all_in_one.sh index 37853b6a2..2091d76bb 100644 --- a/all_in_one.sh +++ b/all_in_one.sh @@ -400,15 +400,16 @@ function check_aliyunpan_opentoken() { } -function qrcode_aliyunpan_tvtoken() { +function qrcode_mode_choose() { + + function qrcode_web() { + + if ! check_port "34256"; then + ERROR "34256 端口被占用,请关闭占用此端口的程序!" + exit 1 + fi - 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 @@ -424,7 +425,45 @@ function qrcode_aliyunpan_tvtoken() { -e LANG=C.UTF-8 \ $(get_default_network "qrcode") \ ddsderek/xiaoya-glue:python \ - /aliyuntvtoken/alitoken2.py --qrcode_mode=web + "${2}" --qrcode_mode=web + + } + + if [ "${2}" == "/aliyuntoken/aliyuntoken_vercel.py" ]; then + WARN "当前模式只能浏览器扫码!" + qrcode_web "${1}" "${2}" + fi + + while true; do + INFO "请选择扫码模式 [ 1: 命令行扫码 | 2: 浏览器扫码 ](默认 2)" + read -erp "QRCODE_MODE:" QRCODE_MODE + [[ -z "${QRCODE_MODE}" ]] && QRCODE_MODE="2" + if [[ ${QRCODE_MODE} == [1] ]]; then + docker run -i --rm \ + -v "${1}:/data" \ + -e LANG=C.UTF-8 \ + ddsderek/xiaoya-glue:python \ + "${2}" --qrcode_mode=shell + return 0 + elif [[ ${QRCODE_MODE} == [2] ]]; then + qrcode_web "${1}" "${2}" + return 0 + else + ERROR "输入无效,请重新选择" + fi + done + +} + +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 配置" + pull_glue_python_ddsrem + qrcode_mode_choose "${1}" "/aliyuntvtoken/alitoken2.py" INFO "操作全部完成!" ;; *) @@ -441,7 +480,7 @@ function qrcode_aliyunpan_refreshtoken() { case $cpu_arch in "x86_64" | *"amd64"* | "aarch64" | *"arm64"* | *"armv8"* | *"arm/v8"*) INFO "阿里云盘 Refresh Token 配置" - local local_ip command_file + local 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" @@ -453,22 +492,7 @@ function qrcode_aliyunpan_refreshtoken() { 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扫描二维码!" - # shellcheck disable=SC2046 - docker run -i --rm \ - -v "${1}:/data" \ - -e LANG=C.UTF-8 \ - $(get_default_network "qrcode") \ - ddsderek/xiaoya-glue:python \ - "/aliyuntoken/${command_file}" --qrcode_mode=web + qrcode_mode_choose "${1}" "/aliyuntoken/${command_file}" INFO "操作全部完成!" ;; *) @@ -485,7 +509,7 @@ function qrcode_aliyunpan_opentoken() { case $cpu_arch in "x86_64" | *"amd64"* | "aarch64" | *"arm64"* | *"armv8"* | *"arm/v8"*) INFO "阿里云盘 Open Token 配置" - local local_ip command_file + local 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" @@ -494,22 +518,7 @@ function qrcode_aliyunpan_opentoken() { 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扫描二维码!" - # shellcheck disable=SC2046 - docker run -i --rm \ - -v "${1}:/data" \ - -e LANG=C.UTF-8 \ - $(get_default_network "qrcode") \ - ddsderek/xiaoya-glue:python \ - "/aliyunopentoken/${command_file}" --qrcode_mode=web + qrcode_mode_choose "${1}" "/aliyunopentoken/${command_file}" INFO "操作全部完成!" ;; *) @@ -526,24 +535,8 @@ function qrcode_115_cookie() { 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扫描二维码!" - # shellcheck disable=SC2046 - docker run -i --rm \ - -v "${1}:/data" \ - -e LANG=C.UTF-8 \ - $(get_default_network "qrcode") \ - ddsderek/xiaoya-glue:python \ - /115cookie/115cookie.py --qrcode_mode=web + qrcode_mode_choose "${1}" "/115cookie/115cookie.py" INFO "操作全部完成!" ;; *) @@ -560,24 +553,8 @@ function qrcode_quark_cookie() { 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扫描二维码!" - # shellcheck disable=SC2046 - docker run -i --rm \ - -v "${1}:/data" \ - -e LANG=C.UTF-8 \ - $(get_default_network "qrcode") \ - ddsderek/xiaoya-glue:python \ - /quark_cookie/quark_cookie.py --qrcode_mode=web + qrcode_mode_choose "${1}" "/quark_cookie/quark_cookie.py" INFO "操作全部完成!" ;; *) @@ -594,24 +571,8 @@ function qrcode_uc_cookie() { 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扫描二维码!" - # shellcheck disable=SC2046 - docker run -i --rm \ - -v "${1}:/data" \ - -e LANG=C.UTF-8 \ - $(get_default_network "qrcode") \ - ddsderek/xiaoya-glue:python \ - /uc_cookie/uc_cookie.py --qrcode_mode=web + qrcode_mode_choose "${1}" "/uc_cookie/uc_cookie.py" INFO "操作全部完成!" ;; *) diff --git a/glue_python/115cookie/115cookie.py b/glue_python/115cookie/115cookie.py index 613fa6bb0..4b1d86cb1 100644 --- a/glue_python/115cookie/115cookie.py +++ b/glue_python/115cookie/115cookie.py @@ -1,5 +1,8 @@ #!/usr/local/bin/python3 +__author__ = "ChenyangGao " +__license__ = "GPLv3 " + from flask import Flask, render_template, jsonify import threading import time @@ -208,6 +211,7 @@ def shutdown(): qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_H, box_size=5, border=4) qr.add_data(qrcode_token_url(qrcode_token["uid"])) qr.make(fit=True) + logging.info('请打开 115网盘 扫描此二维码!') qr.print_ascii(invert=True, tty=sys.stdout.isatty()) while last_status != 1 and last_status != 2: time.sleep(1) diff --git a/glue_python/aliyunopentoken/aliyunopentoken.py b/glue_python/aliyunopentoken/aliyunopentoken.py index 50d0b1900..bc6420c9c 100644 --- a/glue_python/aliyunopentoken/aliyunopentoken.py +++ b/glue_python/aliyunopentoken/aliyunopentoken.py @@ -150,6 +150,7 @@ def shutdown(): app.run(host='0.0.0.0', port=34256) elif args.qrcode_mode == 'shell': threading.Thread(target=poll_qrcode_status, args=(sid, False)).start() + logging.info('请打开阿里云盘扫描此二维码!') qr.print_ascii(invert=True, tty=sys.stdout.isatty()) while last_status != 1: time.sleep(1) diff --git a/glue_python/aliyunopentoken/aliyunopentoken_nn.ci.py b/glue_python/aliyunopentoken/aliyunopentoken_nn.ci.py index 4b60ca75b..62d1c109c 100644 --- a/glue_python/aliyunopentoken/aliyunopentoken_nn.ci.py +++ b/glue_python/aliyunopentoken/aliyunopentoken_nn.ci.py @@ -116,6 +116,7 @@ def shutdown(): app.run(host='0.0.0.0', port=34256) elif args.qrcode_mode == 'shell': threading.Thread(target=poll_qrcode_status, args=(sid, False)).start() + logging.info('请打开阿里云盘扫描此二维码!') qr.print_ascii(invert=True, tty=sys.stdout.isatty()) while last_status != 1: time.sleep(1) diff --git a/glue_python/aliyuntoken/aliyuntoken.py b/glue_python/aliyuntoken/aliyuntoken.py index 92cd250e3..673e0fa08 100644 --- a/glue_python/aliyuntoken/aliyuntoken.py +++ b/glue_python/aliyuntoken/aliyuntoken.py @@ -125,6 +125,7 @@ def shutdown(): app.run(host='0.0.0.0', port=34256) elif args.qrcode_mode == 'shell': threading.Thread(target=poll_qrcode_status, args=(data, False)).start() + logging.info('请打开阿里云盘扫描此二维码!') qr.print_ascii(invert=True, tty=sys.stdout.isatty()) while last_status != 1: time.sleep(1) diff --git a/glue_python/aliyuntoken/aliyuntoken_nn.ci.py b/glue_python/aliyuntoken/aliyuntoken_nn.ci.py index 69ad058e6..e3b82ded5 100644 --- a/glue_python/aliyuntoken/aliyuntoken_nn.ci.py +++ b/glue_python/aliyuntoken/aliyuntoken_nn.ci.py @@ -108,6 +108,7 @@ def shutdown(): app.run(host='0.0.0.0', port=34256) elif args.qrcode_mode == 'shell': threading.Thread(target=poll_qrcode_status, args=(data, False)).start() + logging.info('请打开阿里云盘扫描此二维码!') qr.print_ascii(invert=True, tty=sys.stdout.isatty()) while last_status != 1: time.sleep(1) diff --git a/glue_python/aliyuntvtoken/alitoken2.py b/glue_python/aliyuntvtoken/alitoken2.py index 508d437b5..5d8f98e18 100644 --- a/glue_python/aliyuntvtoken/alitoken2.py +++ b/glue_python/aliyuntvtoken/alitoken2.py @@ -156,6 +156,7 @@ def shutdown(): qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_H, box_size=5, border=4) qr.add_data(qr_link) qr.make(fit=True) + logging.info('请打开阿里云盘扫描此二维码!') qr.print_ascii(invert=True, tty=sys.stdout.isatty()) auth_code = check_qrcode_status(sid)['auth_code'] get_token(auth_code) diff --git a/glue_python/quark_cookie/quark_cookie.py b/glue_python/quark_cookie/quark_cookie.py index e8e1e2816..b59783bf3 100644 --- a/glue_python/quark_cookie/quark_cookie.py +++ b/glue_python/quark_cookie/quark_cookie.py @@ -111,6 +111,7 @@ def shutdown(): app.run(host='0.0.0.0', port=34256) elif args.qrcode_mode == 'shell': threading.Thread(target=poll_qrcode_status, args=(False,)).start() + logging.info('请打开 夸克 APP 扫描此二维码!') qr.print_ascii(invert=True, tty=sys.stdout.isatty()) while last_status != 1 and last_status != 2: time.sleep(1) diff --git a/glue_python/uc_cookie/uc_cookie.py b/glue_python/uc_cookie/uc_cookie.py index e803218c4..d51deb55e 100644 --- a/glue_python/uc_cookie/uc_cookie.py +++ b/glue_python/uc_cookie/uc_cookie.py @@ -124,6 +124,7 @@ def shutdown(): app.run(host='0.0.0.0', port=34256) elif args.qrcode_mode == 'shell': threading.Thread(target=poll_qrcode_status, args=(token,False,)).start() + logging.info('请打开 UC浏览器 APP 扫描此二维码!') qr.print_ascii(invert=True, tty=sys.stdout.isatty()) while last_status != 1 and last_status != 2: time.sleep(1)