Spaces:
Paused
Paused
| import os | |
| import json | |
| def read_json_file(input_file_path): | |
| with open(input_file_path, 'r') as file: | |
| data = json.load(file) # Load the JSON data from the file | |
| return data | |
| # root folder path | |
| file_path = os.path.abspath(__file__) | |
| current_Folder_Path = os.path.dirname(file_path) | |
| root_folder = os.path.dirname(current_Folder_Path) | |
| # imp folder path | |
| content_folder = current_Folder_Path + "/content/" | |
| unique_code_file_Path=current_Folder_Path +"/Unique_code/unique_code.json" | |
| # drive imp folders id | |
| youtube_videos_for_upload_folder_id = "150E6lc1owcHdPnz5DKOFXgmSxjFm0i3f" | |
| content_folder_id = "1tcNOWyaTxPrnEfDkTlejSySNQE3Ib9BT" | |
| unicode_folder_id="1iOt0tn1xcbfOZGvUwkRsLSFQFusbJZL8" | |
| download_drive_folder_list = [youtube_videos_for_upload_folder_id, content_folder_id] | |
| # vedio editing paths | |
| PATHS = { | |
| # files path | |
| "logo": content_folder + "logo.png", | |
| "background": content_folder + "background_image.jpg", | |
| "banner": content_folder + "yt_banner.png", | |
| "subscribe": content_folder + "subscribe.png", | |
| "animation": content_folder + "like_share_subscribe_animation.mp4", | |
| # imp folder path | |
| "input_folder_path": current_Folder_Path + "/youtube_videos/", | |
| "output_folder_path": current_Folder_Path + "/output_videos/" | |
| # "input_videos": current_Folder_Path + "input_vedio/", | |
| # "audio": content_folder + "audio.mp3", | |
| # "output_video": current_Folder_Path + "/output_videos/output_video_with_audio.mp4", | |
| # "input_video_path": current_Folder_Path + "/downloaded_videos/vedio_0.webm", | |
| } | |
| # imp functions | |
| def create_output_videos_folder(): | |
| output_videos_folder = PATHS["output_folder_path"] | |
| if not os.path.exists(output_videos_folder): | |
| os.makedirs(output_videos_folder) | |
| return output_videos_folder | |
| def check_paths_exist(paths): | |
| ignore_keys = {"input_videos", "audio", "output_video", "input_video_path"} # Keys to ignore | |
| missing_paths = {} | |
| for key, path in paths.items(): | |
| if key not in ignore_keys and not os.path.exists(path): | |
| missing_paths[key] = path | |
| if missing_paths: | |
| print("\033[91mThe following paths do not exist:\033[0m") # Red color | |
| for key, path in missing_paths.items(): | |
| print(f"\033[91m{key}: {path}\033[0m") | |
| raise Exception("Some required paths are missing.") | |
| else: | |
| print("All paths exist.") | |
| return missing_paths | |
| def validate_name(name): | |
| json_data = read_json_file(unique_code_file_Path) | |
| unique_code = json_data["unique_code"] | |
| print(name) | |
| if name == unique_code: | |
| return True | |
| else: | |
| return False | |