Spaces:
Paused
Paused
import os | |
import json | |
CACHE_DIR = os.getenv("CACHE_DIR") | |
INDEX_FILE = os.getenv("INDEX_FILE") | |
def find_tv_path(json_data, title): | |
"""Find the path of the TV show in the JSON data based on the title.""" | |
for directory in json_data: | |
if directory['type'] == 'directory' and directory['path'] == 'tv': | |
for sub_directory in directory['contents']: | |
if sub_directory['type'] == 'directory' and title.lower() in sub_directory['path'].lower(): | |
return sub_directory | |
return None | |
with open(INDEX_FILE, 'r') as f: | |
file_structure = json.load(f) | |
print(find_tv_path(file_structure,title="Aho Girl")) |