Skip to content

Commit

Permalink
<feat/fix>添加使用代理配置和自动获取系统代理配置/fix #45
Browse files Browse the repository at this point in the history
  • Loading branch information
Abcuders committed Jul 6, 2024
1 parent 4211359 commit 3996514
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
28 changes: 17 additions & 11 deletions AutoAnimeMv.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from zhconv import convert # 繁化简
from urllib.parse import quote,unquote # url encode
from requests import get,post,exceptions # 网络部分
from urllib.request import getproxies # 获取系统代理
#from random import randint # 随机数生成
#from threading import Thread # 多线程
from importlib import import_module # 动态加载模块
Expand All @@ -19,7 +20,7 @@ def Start_PATH():
'''初始化'''
# 版本 数据库缓存 Api数据缓存 Log数据集 分隔符
global Versions,AimeListCache,BgmAPIDataCache,TMDBAPIDataCache,LogData,Separator,Proxy,TgBotMsgData,PyPath
Versions = '3.2.4'
Versions = '3.3.5'
AimeListCache = None
BgmAPIDataCache = {}
TMDBAPIDataCache = {}
Expand All @@ -28,8 +29,10 @@ def Start_PATH():
TgBotMsgData = ''
PyPath = __file__.replace('AutoAnimeMv.py','').strip(' ')

global USEMODULE,HTTPPROXY,HTTPSPROXY,ALLPROXY,USEBGMAPI,USETMDBAPI,USELINK,LINKFAILSUSEMOVEFLAGS,USETITLTOEP,PRINTLOGFLAG,RMLOGSFLAG,USEBOTFLAG,TIMELAPSE,SEEPSINGLECHARACTER,JELLYFINFORMAT,NOTLOADEXTLIST,MANDATORYCOVER,NETERRRECTRYTIMS
global USEMODULE,USEPROXY,USESYSPROXY,HTTPPROXY,HTTPSPROXY,ALLPROXY,USEBGMAPI,USETMDBAPI,USELINK,LINKFAILSUSEMOVEFLAGS,USETITLTOEP,PRINTLOGFLAG,RMLOGSFLAG,USEBOTFLAG,TIMELAPSE,SEEPSINGLECHARACTER,JELLYFINFORMAT,NOTLOADEXTLIST,MANDATORYCOVER,NETERRRECTRYTIMS
USEMODULE = None
USEPROXY = False # 使用代理
USESYSPROXY = False # 使用系统代理
HTTPPROXY = '' # Http代理
HTTPSPROXY = '' # Https代理
ALLPROXY = '' # 全部代理
Expand Down Expand Up @@ -325,7 +328,7 @@ def Auxiliary_UniformOTSTR(File):

NewFile = convert(File,'zh-hans')# 繁化简
NewUSTRFile = sub(r',|,| ','-',NewFile,flags=I)
NewUSTRFile = sub(r'[^a-z0-9\s&/::.\-\(\)()《》\u4e00-\u9fa5\u3040-\u309F\u30A0-\u30FF\u31F0-\u31FF]','=',NewUSTRFile,flags=I)
NewUSTRFile = sub(r'[^a-z0-9\s&/::.\-\(\)()《》\u4e00-\u9fa5\u3040-\u309F\u30A0-\u30FF\u31F0-\u31FF°]','=',NewUSTRFile,flags=I)
#异种剧集统一
OtEpisodesMatchData = [r'第(\d{1,4})集',r'(\d{1,4})集',r'第(\d{1,4})话',r'(\d{1,4})END',r'(\d{1,4}) END',r'(\d{1,4})E']
for i in OtEpisodesMatchData:
Expand Down Expand Up @@ -465,7 +468,7 @@ def Scan(File):
Auxiliary_Log((f'发现{len(AssFileList)}个字幕文件 ==> {AssFileList}',f'发现{len(VDFileList)}个视频文件 ==> {VDFileList}'),'INFO')
return VDFileList,AssFileList
else:
Auxiliary_Log(f'发现{len(VDFileList)}个视频文件,没有发现字幕文件, ==> {VDFileList}','INFO')
Auxiliary_Log(f'发现{len(VDFileList)}个视频文件,没有发现字幕文件 ==> {VDFileList}','INFO')
return VDFileList
elif AssFileList != []:
Auxiliary_Log((f'没有发现任何番剧视频文件,但发现{len(AssFileList)}个字幕文件 ==> {AssFileList}','只有字幕文件需要处理'),'INFO')
Expand Down Expand Up @@ -499,16 +502,19 @@ def Auxiliary_ASSFileCA(ASSFileName):

def Auxiliary_PROXY():
'''代理'''

if 'HTTPPROXY' in globals():
if USEPROXY == True:
global HTTPPROXY
environ['http_proxy'] = HTTPPROXY
if 'HTTPSPROXY' in globals():
global HTTPSPROXY
environ['https_proxy'] = HTTPSPROXY
if 'ALLPROXY' in globals():
global ALLPROXY
environ['all_proxy'] = ALLPROXY
Auxiliary_Log('代理功能开启')
if USESYSPROXY == True:
Auxiliary_Log('使用系统代理')
HTTPPROXY,HTTPSPROXY,a = tuple(getproxies().values())
environ['http_proxy'] = HTTPPROXY
environ['https_proxy'] = HTTPSPROXY
environ['all_proxy'] = ALLPROXY



def Auxiliary_Http(Url,flag='GET',json=None):
'''网络'''
Expand Down
2 changes: 2 additions & 0 deletions config.ini.Template
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ USEMODULE = False # 使用模块
NOTLOADEXTLIST = 'exmaple1', # 模块排除列表,格式 'exmaple1','exmaple2' + ... ,

# NetConfig
USEPROXY = True # 使用代理
USESYSPROXY = True # 使用系统代理
HTTPPROXY = '' # Http代理
HTTPSPROXY = 'http://10.0.0.1:7890' # Https代理
ALLPROXY = '' # 全部代理
Expand Down

0 comments on commit 3996514

Please sign in to comment.