diff --git a/ADC_function.py b/ADC_function.py index 30a3249..df10283 100755 --- a/ADC_function.py +++ b/ADC_function.py @@ -59,8 +59,6 @@ def get_html(url, cookies: dict = None, ua: str = None, return_type: str = None) if return_type == "object": return result - elif return_type == "json": - return result.json() else: return result.text diff --git a/AV_Data_Capture.py b/AV_Data_Capture.py index 1102495..74b2848 100755 --- a/AV_Data_Capture.py +++ b/AV_Data_Capture.py @@ -3,14 +3,15 @@ from core import * import os from number_parser import get_number -__version__ = '3.7.1' -def check_update(): - latest = get_html("https://api.github.com/repos/yoshiko2/AV_Data_Capture/releases/latest", - return_type="json")["tag_name"] +def check_update(local_version): + data = json.loads(get_html("https://api.github.com/repos/yoshiko2/AV_Data_Capture/releases/latest")) - if __version__ != latest: - line1 = "* New update " + str(latest) + " *" + remote = data["tag_name"] + local = local_version + + if not local == remote: + line1 = "* New update " + str(remote) + " *" print("[*]" + line1.center(54)) print("[*]" + "↓ Download ↓".center(54)) print("[*] https://github.com/yoshiko2/AV_Data_Capture/releases") @@ -110,6 +111,7 @@ def create_data_and_move_with_custom_number(file_path: str, c: config.Config, cu if __name__ == '__main__': + version = '3.7.2' # Parse command line args single_file_path, config_file, auto_exit, custom_number = argparse_function() @@ -117,13 +119,13 @@ if __name__ == '__main__': # Read config.ini conf = config.Config(path=config_file) - version_print = 'Version ' + __version__ + version_print = 'Version ' + version print('[*]================== AV Data Capture ===================') print('[*]' + version_print.center(54)) print('[*]======================================================') if conf.update_check(): - check_update() + check_update(version) create_failed_folder(conf.failed_folder()) os.chdir(os.getcwd()) diff --git a/core.py b/core.py index 55b8cb7..c85b988 100755 --- a/core.py +++ b/core.py @@ -83,9 +83,12 @@ def get_data_from_json(file_number, filepath, conf: config.Config): # 从JSON json_data = {} for source in sources: - json_data = json.loads(func_mapping[source](file_number)) - # if any service return a valid return, break - if get_data_state(json_data): + try: + json_data = json.loads(func_mapping[source](file_number)) + # if any service return a valid return, break + if get_data_state(json_data): + break + except: break # Return if data not found in all sources diff --git a/linux_make.py b/linux_make.py new file mode 100644 index 0000000..7d062e3 --- /dev/null +++ b/linux_make.py @@ -0,0 +1,6 @@ +import os +os.system("pyinstaller --onefile AV_Data_Capture.py --hidden-import ADC_function.py --hidden-import core.py") +os.system("rm -rf ./build") +os.system("rm -rf ./__pycache__") +os.system("rm -rf AV_Data_Capture.spec") +os.system("echo '[Make]Finish'") diff --git a/number_parser.py b/number_parser.py index d9e35f8..16063ea 100644 --- a/number_parser.py +++ b/number_parser.py @@ -28,19 +28,25 @@ def get_number(filepath: str) -> str: """ filepath = os.path.basename(filepath) - if '-' in filepath or '_' in filepath: # 普通提取番号 主要处理包含减号-和_的番号 - filepath = filepath.replace("_", "-") - filepath.strip('22-sht.me').strip('-HD').strip('-hd') - filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath)) # 去除文件名中时间 - if 'FC2' or 'fc2' in filename: - filename = filename.replace('PPV','').replace('ppv','').replace('--','-').replace('_','-') - file_number = re.search(r'\w+-\w+', filename, re.A).group() - return file_number - else: # 提取不含减号-的番号,FANZA CID - try: - return str(re.findall(r'(.+?)\.', str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip("['']").replace('_', '-') - except: - return re.search(r'(.+?)\.', filepath)[0] + try: + if '-' in filepath or '_' in filepath: # 普通提取番号 主要处理包含减号-和_的番号 + filepath = filepath.replace("_", "-") + filepath.strip('22-sht.me').strip('-HD').strip('-hd') + filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath)) # 去除文件名中时间 + if 'FC2' or 'fc2' in filename: + filename = filename.replace('PPV', '').replace('ppv', '').replace('--', '-').replace('_', '-') + file_number = re.search(r'\w+-\w+', filename, re.A).group() + return file_number + else: # 提取不含减号-的番号,FANZA CID + try: + return str( + re.findall(r'(.+?)\.', str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip( + "['']").replace('_', '-') + except: + return re.search(r'(.+?)\.', filepath)[0] + except Exception as e: + print('[-]' + str(e)) + return if __name__ == "__main__":