import os import json import requests import ImportantVariables def upload_file_to_gofile(file_path): url = "https://store1.gofile.io/uploadFile" with open(file_path, "rb") as f: response = requests.post(url, files={"file": f}) if response.status_code == 200: result = response.json() if result["status"] == "ok": return result["data"]["downloadPage"] else: print("❌ Upload failed:", result) else: print(f"❌ Error: HTTP {response.status_code}") return None def upload_folder_to_gofile(folder_path, json_name="files.json"): file_urls = {} # Upload each file in the folder for root, _, files in os.walk(folder_path): for file in files: file_path = os.path.join(root, file) print(f"Uploading {file}...") file_url = upload_file_to_gofile(file_path) if file_url: file_urls[file] = file_url # Save file URLs in a JSON file json_path = os.path.join(folder_path, json_name) with open(json_path, "w") as json_file: json.dump(file_urls, json_file, indent=4) # Upload the JSON file print("Uploading JSON file...") json_file_url = upload_file_to_gofile(json_path) return json_file_url # Example usage # folder_url = upload_folder_to_gofile("your_folder_path_here") # print("JSON file URL:", folder_url) def main(): # Example usage folder_path = ImportantVariables.PATHS["output_folder_path"] public_url=upload_folder_to_gofile(folder_path) print("JSON file URL:", public_url) return public_url if __name__ == "__main__": main()