From 0988039a34a470b8c532da4b2d27c3982da52e24 Mon Sep 17 00:00:00 2001 From: Yoshiko2 Date: Thu, 4 Nov 2021 23:47:46 +0800 Subject: [PATCH 1/3] Create mapping_actor.xml --- MappingTable/mapping_actor.xml | 2714 ++++++++++++++++++++++++++++++++ 1 file changed, 2714 insertions(+) create mode 100644 MappingTable/mapping_actor.xml diff --git a/MappingTable/mapping_actor.xml b/MappingTable/mapping_actor.xml new file mode 100644 index 0000000..c2f6236 --- /dev/null +++ b/MappingTable/mapping_actor.xml @@ -0,0 +1,2714 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a5e8687639c0a389f16668a85caca3377c058628 Mon Sep 17 00:00:00 2001 From: Yoshiko2 Date: Thu, 4 Nov 2021 23:48:10 +0800 Subject: [PATCH 2/3] Create mapping_info.xml --- MappingTable/mapping_info.xml | 411 ++++++++++++++++++++++++++++++++++ 1 file changed, 411 insertions(+) create mode 100644 MappingTable/mapping_info.xml diff --git a/MappingTable/mapping_info.xml b/MappingTable/mapping_info.xml new file mode 100644 index 0000000..89a1a65 --- /dev/null +++ b/MappingTable/mapping_info.xml @@ -0,0 +1,411 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 50c3975b7565f8e5d7b59829e38c321f9bb88ebd Mon Sep 17 00:00:00 2001 From: yoshiko2 Date: Fri, 5 Nov 2021 00:49:19 +0800 Subject: [PATCH 3/3] Add Donwload Mapping Table function --- ADC_function.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++ AV_Data_Capture.py | 14 +++++++++++ 2 files changed, 72 insertions(+) diff --git a/ADC_function.py b/ADC_function.py index 2198939..2ea0fbe 100755 --- a/ADC_function.py +++ b/ADC_function.py @@ -770,3 +770,61 @@ if __name__ == "__main__": if len(sys.argv)>1: url = sys.argv[1] benchmark(t, url) + +def download_file_with_filename(url, filename, path): + conf = config.getInstance() + configProxy = conf.proxy() + + for i in range(configProxy.retry): + try: + if configProxy.enable: + if not os.path.exists(path): + try: + os.makedirs(path) + except: + print(f"[-]Fatal error! Can not make folder '{path}'") + sys.exit(0) + proxies = configProxy.proxies() + headers = { + 'User-Agent': G_USER_AGENT} + r = requests.get(url, headers=headers, timeout=configProxy.timeout, proxies=proxies) + if r == '': + print('[-]Movie Download Data not found!') + return + with open(os.path.join(path, filename), "wb") as code: + code.write(r.content) + return + else: + if not os.path.exists(path): + try: + os.makedirs(path) + except: + print(f"[-]Fatal error! Can not make folder '{path}'") + sys.exit(0) + headers = { + 'User-Agent': G_USER_AGENT} + r = requests.get(url, timeout=configProxy.timeout, headers=headers) + if r == '': + print('[-]Movie Download Data not found!') + return + with open(os.path.join(path, filename), "wb") as code: + code.write(r.content) + return + except requests.exceptions.RequestException: + i += 1 + print('[-]Download : Connect retry ' + str(i) + '/' + str(configProxy.retry)) + except requests.exceptions.ConnectionError: + i += 1 + print('[-]Download : Connect retry ' + str(i) + '/' + str(configProxy.retry)) + except requests.exceptions.ProxyError: + i += 1 + print('[-]Download : Connect retry ' + str(i) + '/' + str(configProxy.retry)) + except requests.exceptions.ConnectTimeout: + i += 1 + print('[-]Download : Connect retry ' + str(i) + '/' + str(configProxy.retry)) + except IOError: + raise ValueError(f"[-]Create Directory '{path}' failed!") + return + print('[-]Connect Failed! Please check your Proxy or Network!') + raise ValueError('[-]Connect Failed! Please check your Proxy or Network!') + return \ No newline at end of file diff --git a/AV_Data_Capture.py b/AV_Data_Capture.py index afc56ea..24fb80e 100755 --- a/AV_Data_Capture.py +++ b/AV_Data_Capture.py @@ -9,6 +9,7 @@ import urllib3 import signal from opencc import OpenCC +import ADC_function import config from datetime import datetime, timedelta import time @@ -472,6 +473,19 @@ def main(): if conf.update_check(): check_update(version) + # Download Mapping Table + if not os.path.exists(str(Path.home() / logdir / 'mapping_actor.xml')): + ADC_function.download_file_with_filename( + "https://raw.githubusercontent.com/yoshiko2/AV_Data_Capture/master/MappingTable/mapping_actor.xml", + "mapping_actor.xml", str(Path.home() / logdir)) + print("[+] [1/2] Mapping Table Downloaded") + + if not os.path.exists(str(Path.home() / logdir / 'mapping_info.xml')): + ADC_function.download_file_with_filename( + "https://raw.githubusercontent.com/yoshiko2/AV_Data_Capture/master/MappingTable/mapping_info.xml", + "mapping_info.xml", str(Path.home() / logdir)) + print("[+] [2/2] Mapping Table Downloaded") + print(f"[+]Load Config file '{conf.ini_path}'.") if conf.debug(): print('[+]Enable debug')