Closed J666Z closed 2 months ago
用GPT写的代码,部分文件没问题,有些文件名称路径不对,编码也不对,放弃了,只用原来的元数据,STRM还是老老实实的用你的同步 import urllib.parse import os
def encode_strm_files_in_directory(directory_path): for root, dirs, files in os.walk(directory_path): for file_name in files: if file_name.endswith(".strm"): file_path = os.path.join(root, file_name) encode_strm_file(file_path)
def encode_strm_file(file_path): try: with open(file_path, 'r', encoding='utf-8') as file: content = file.read()
# Encode URI without encoding special symbols
encoded_content = urllib.parse.quote(content, safe='::/?#[]@!$&\'()*+,;=')
with open(file_path, 'w', encoding='utf-8') as file:
file.write(encoded_content)
print(f"Content in {file_path} has been URL encoded without encoding special symbols.")
except Exception as e:
print(f"An error occurred processing {file_path}: {e}")
root_directory = "/media/Lecoo/ZZZ" encode_strm_files_in_directory(root_directory)
要使用urlparse对路径进行编码。
我手动下载小雅的元数据,替换了IP地址,但是他这个地址编码和你你的不一样,有什么办法换成你那种%字符的吗