import json import os import download_manga import make_pdf_from_images import save_file_to_hugging_face import vedio_upload_to_gofile def save_to_json(folder_name, public_url,json_file): """Save the folder name and public URL to a JSON file.""" data = load_json(json_file) data[folder_name] = public_url # Store using folder name as key with open(json_file, "w") as file: json.dump(data, file, indent=4) print(f"Saved: {folder_name} -> {public_url}") return json_file def load_json(file_path): """Load existing JSON data or return an empty dictionary.""" if os.path.exists(file_path): try: with open(file_path, "r") as file: return json.load(file) except json.JSONDecodeError: return {} # Handle corrupted JSON return {} # Return empty dict if file doesn’t exist def main(url): json_file = "manga_downloads.json" main_folder=download_manga.main(url) output_folder=make_pdf_from_images.main(main_folder) public_url=vedio_upload_to_gofile.main(output_folder) folder_name = os.path.basename(main_folder) json_file_path =save_to_json(folder_name, public_url,json_file) save_file_to_hugging_face.upload_file(json_file) return public_url if __name__ == "__main__": url = "https://mangadistrict.com/read-scan/boarding-diary-uncensored-fan-edition/v1-high-quality-optimized-for-moderate-data-usage/chapter-1" main(url)