mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-05-23 19:17:41 +08:00
feat: 针对海外用户进行的少量优化
This commit is contained in:
parent
1ef6675a5f
commit
33a7e8e8b6
@ -22,6 +22,7 @@ import time
|
||||
import pickle
|
||||
from . import config
|
||||
from . import utils
|
||||
from . import variable
|
||||
|
||||
def is_valid_utf8(text):
|
||||
# 判断是否为有效的utf-8字符串
|
||||
@ -90,6 +91,9 @@ def request(url, options = {}):
|
||||
except:
|
||||
options['headers'] = {}
|
||||
options['headers']['User-Agent'] = random.choice(ua_list)
|
||||
# 检查是否在国内
|
||||
if ((not variable.iscn) and (not options["headers"].get("X-Forwarded-For"))):
|
||||
options["headers"]["X-Forwarded-For"] = variable.fakeip
|
||||
# 获取请求主函数
|
||||
try:
|
||||
reqattr = getattr(requests, method.lower())
|
||||
@ -196,4 +200,13 @@ async def asyncrequest(url, options={}):
|
||||
# Return the response
|
||||
return req
|
||||
|
||||
"""
|
||||
"""
|
||||
|
||||
def checkcn():
|
||||
req = request("https://mips.kugou.com/check/iscn?&format=json")
|
||||
body = utils.jsobject(req.json())
|
||||
variable.iscn = bool(body.flag)
|
||||
if (not variable.iscn):
|
||||
variable.fakeip = "1.0.2.114"
|
||||
logger.info("您在非中国大陆服务器上启动了项目,已自动开启ip伪装")
|
||||
logger.warning("此方式无法解决咪咕音乐的链接获取问题,您可以配置代理,服务器地址可在下方链接中找到\nhttps://hidemy.io/cn/proxy-list/?country=CN#list")
|
||||
|
@ -133,4 +133,5 @@ class jsobject(dict):
|
||||
def __getattr__(self, UNUSED):
|
||||
return None
|
||||
|
||||
add_to_global_namespace('require', require)
|
||||
add_to_global_namespace('require', require)
|
||||
|
||||
|
@ -11,9 +11,11 @@
|
||||
import os
|
||||
|
||||
|
||||
debug_mode = True
|
||||
debug_mode = False
|
||||
log_length_limit = 400
|
||||
running = True
|
||||
config = {}
|
||||
workdir = os.getcwd()
|
||||
banList_suggest = 0
|
||||
banList_suggest = 0
|
||||
iscn = True
|
||||
fake_ip = None
|
Loading…
x
Reference in New Issue
Block a user