Commit 7c6a5a6e04

7c6a5a6e0452f327988de30ec0245750e5a2fb9b

parent: 13f5cbef1e

Unsigned

Wraient <wraient.911@gmail.com> · 2024-10-08 04:41 UTC

update script automatically

Layout: unified · split

curd.py +19
@@ -904,6 +904,20 @@ def load_config() -> dict:
904 904
905 return config_dict 905 return config_dict
906 906
907def update_script():
908 script_dir = os.path.dirname(os.path.realpath(__file__))
909 script_file = os.path.join(script_dir, "curd.py")
910
911 response = requests.get("https://raw.githubusercontent.com/Wraient/curd/refs/heads/main/curd.py")
912 if response.status_code == 200:
913 # Write the content to a file
914 with open(script_file, 'wb') as file:
915 file.write(response.content)
916 print(f"Script update successfully at {script_file}")
917 else:
918 print(f"Failed to download the script. Status code: {response.status_code}")
919 exit(1)
920
907# ----------------------------------------------- Create Bash Script ---------------------------------------- 921# ----------------------------------------------- Create Bash Script ----------------------------------------
908 922
909def create_anime_list(): 923def create_anime_list():
@@ -1104,8 +1118,13 @@ parser.add_argument("-new", action='store_true', help="Add new anime to watching
1104parser.add_argument("-sub", action='store_true', help="Anime audio type (optional)") 1118parser.add_argument("-sub", action='store_true', help="Anime audio type (optional)")
1105parser.add_argument("-dub", action='store_true', help="Anime audio type (optional)") 1119parser.add_argument("-dub", action='store_true', help="Anime audio type (optional)")
1106parser.add_argument("-c", action='store_true', help="Continue last watching anime (optional)") 1120parser.add_argument("-c", action='store_true', help="Continue last watching anime (optional)")
1121parser.add_argument("-u", action='store_true', help="Update script (optional)")
1107args = parser.parse_args() 1122args = parser.parse_args()
1108 1123
1124if args.u:
1125 update_script()
1126 exit(0)
1127
1109user_config = load_config() # python dictionary containing all the configs as key value pairs 1128user_config = load_config() # python dictionary containing all the configs as key value pairs
1110history_file_path_ = os.path.expandvars(get_userconfig_value(user_config, "history_file")) 1129history_file_path_ = os.path.expandvars(get_userconfig_value(user_config, "history_file"))
1111history_file_path_ = os.path.dirname(history_file_path_) 1130history_file_path_ = os.path.dirname(history_file_path_)