|
|
import os |
|
|
|
|
|
def replace_url_in_file(file_path, old_url, new_url): |
|
|
try: |
|
|
with open(file_path, 'r', encoding='utf-8') as file: |
|
|
filedata = file.read() |
|
|
|
|
|
filedata = filedata.replace(old_url, new_url) |
|
|
|
|
|
with open(file_path, 'w', encoding='utf-8') as file: |
|
|
file.write(filedata) |
|
|
except Exception as e: |
|
|
pass |
|
|
|
|
|
def replace_url_in_folder(folder_path, old_url, new_url): |
|
|
for root, dirs, files in os.walk(folder_path): |
|
|
for file in files: |
|
|
file_path = os.path.join(root, file) |
|
|
replace_url_in_file(file_path, old_url, new_url) |
|
|
|
|
|
folder_path = 'stable-diffusion-webui-forge/' |
|
|
old_hugging = 'huggingface.co' |
|
|
new_hugging = 'hf-mirror.com' |
|
|
old_git = "https://github.com" |
|
|
new_git = "https://gh.con.sh/https://github.com" |
|
|
replace_url_in_folder(folder_path, old_hugging, new_hugging) |
|
|
replace_url_in_folder(folder_path, old_git, new_git) |
|
|
print("ALL DONE!") |
|
|
|
|
|
|
|
|
|