Spaces:
Build error
Build error
Merge branch 'main' of https://huggingface.co/spaces/Unicone-Studio/hanskingdom
Browse files
test.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import json
|
| 3 |
-
|
| 4 |
-
CACHE_DIR = os.getenv("CACHE_DIR")
|
| 5 |
-
INDEX_FILE = os.getenv("INDEX_FILE")
|
| 6 |
-
|
| 7 |
-
def get_all_tv_shows(indexed_cache):
|
| 8 |
-
"""Get all TV shows from the indexed cache structure JSON file."""
|
| 9 |
-
tv_shows = {}
|
| 10 |
-
for directory in indexed_cache:
|
| 11 |
-
if directory['type'] == 'directory' and directory['path'] == 'tv':
|
| 12 |
-
for sub_directory in directory['contents']:
|
| 13 |
-
if sub_directory['type'] == 'directory':
|
| 14 |
-
show_title = sub_directory['path'].split('/')[-1]
|
| 15 |
-
tv_shows[show_title] = []
|
| 16 |
-
for season_directory in sub_directory['contents']:
|
| 17 |
-
if season_directory['type'] == 'directory':
|
| 18 |
-
season = season_directory['path'].split('/')[-1]
|
| 19 |
-
for episode in season_directory['contents']:
|
| 20 |
-
if episode['type'] == 'file':
|
| 21 |
-
tv_shows[show_title].append({
|
| 22 |
-
"season": season,
|
| 23 |
-
"episode": episode['path'].split('/')[-1],
|
| 24 |
-
"path": episode['path']
|
| 25 |
-
})
|
| 26 |
-
return tv_shows
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
with open(INDEX_FILE, 'r') as f:
|
| 30 |
-
file_structure = json.load(f)
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
print(get_all_tv_shows(file_structure))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|