Spaces:
Build error
Build error
Commit
·
db2ea61
1
Parent(s):
f27e7ee
fix tv download api
Browse files
app.py
CHANGED
|
@@ -215,12 +215,16 @@ def get_tv_show_api():
|
|
| 215 |
return jsonify({"error": "TV show not found"}), 404
|
| 216 |
|
| 217 |
episode_path = None
|
| 218 |
-
for
|
| 219 |
-
if
|
| 220 |
-
for
|
| 221 |
-
if
|
| 222 |
-
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
if not episode_path:
|
| 226 |
return jsonify({"error": "Episode not found"}), 404
|
|
@@ -238,6 +242,7 @@ def get_tv_show_api():
|
|
| 238 |
|
| 239 |
return jsonify({"status": "Download started", "episode_id": episode_id})
|
| 240 |
|
|
|
|
| 241 |
@app.route('/api/progress/<id>', methods=['GET'])
|
| 242 |
def get_progress_api(id):
|
| 243 |
"""Endpoint to get the download progress of a movie or TV show episode."""
|
|
|
|
| 215 |
return jsonify({"error": "TV show not found"}), 404
|
| 216 |
|
| 217 |
episode_path = None
|
| 218 |
+
for directory in file_structure:
|
| 219 |
+
if directory['type'] == 'directory' and directory['path'] == 'tv':
|
| 220 |
+
for sub_directory in directory['contents']:
|
| 221 |
+
if sub_directory['type'] == 'directory' and title.lower() in sub_directory['path'].lower():
|
| 222 |
+
for season_dir in sub_directory['contents']:
|
| 223 |
+
if season_dir['type'] == 'directory' and season_dir['path'].endswith(f'Season {season}'):
|
| 224 |
+
for episode_file in season_dir['contents']:
|
| 225 |
+
if episode_file['type'] == 'file' and episode_file['path'].endswith(f'{episode}'):
|
| 226 |
+
episode_path = episode_file['path']
|
| 227 |
+
break
|
| 228 |
|
| 229 |
if not episode_path:
|
| 230 |
return jsonify({"error": "Episode not found"}), 404
|
|
|
|
| 242 |
|
| 243 |
return jsonify({"status": "Download started", "episode_id": episode_id})
|
| 244 |
|
| 245 |
+
|
| 246 |
@app.route('/api/progress/<id>', methods=['GET'])
|
| 247 |
def get_progress_api(id):
|
| 248 |
"""Endpoint to get the download progress of a movie or TV show episode."""
|