Spaces:
Build error
Build error
Commit
·
3b0491c
1
Parent(s):
40d796b
metadata route update
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ from flask import Flask, jsonify, request, send_from_directory
|
|
| 2 |
import os
|
| 3 |
import json
|
| 4 |
import threading
|
|
|
|
| 5 |
from hf_scrapper import download_file, get_system_proxies, get_download_progress
|
| 6 |
from indexer import indexer
|
| 7 |
from tvdb import fetch_and_cache_json
|
|
@@ -153,12 +154,26 @@ def get_film_store():
|
|
| 153 |
return jsonify(film_store_data)
|
| 154 |
return jsonify({}), 404
|
| 155 |
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
# Routes
|
| 159 |
@app.route('/')
|
| 160 |
def index():
|
| 161 |
-
return "Server
|
| 162 |
|
| 163 |
# Main entry point
|
| 164 |
if __name__ == "__main__":
|
|
|
|
| 2 |
import os
|
| 3 |
import json
|
| 4 |
import threading
|
| 5 |
+
import urllib.parse
|
| 6 |
from hf_scrapper import download_file, get_system_proxies, get_download_progress
|
| 7 |
from indexer import indexer
|
| 8 |
from tvdb import fetch_and_cache_json
|
|
|
|
| 154 |
return jsonify(film_store_data)
|
| 155 |
return jsonify({}), 404
|
| 156 |
|
| 157 |
+
@app.route('/api/metadata', methods=['GET'])
|
| 158 |
+
def get_metadata():
|
| 159 |
+
"""Endpoint to get the metadata by title."""
|
| 160 |
+
title = request.args.get('title')
|
| 161 |
+
if not title:
|
| 162 |
+
return jsonify({'error': 'No title provided'}), 400
|
| 163 |
+
|
| 164 |
+
json_cache_path = os.path.join(CACHE_DIR, f"{urllib.parse.quote(title)}.json")
|
| 165 |
+
|
| 166 |
+
if os.path.exists(json_cache_path):
|
| 167 |
+
with open(json_cache_path, 'r') as f:
|
| 168 |
+
data = json.load(f)
|
| 169 |
+
return jsonify(data)
|
| 170 |
+
|
| 171 |
+
return jsonify({'error': 'Metadata not found'}), 404
|
| 172 |
|
| 173 |
# Routes
|
| 174 |
@app.route('/')
|
| 175 |
def index():
|
| 176 |
+
return "Server Running"
|
| 177 |
|
| 178 |
# Main entry point
|
| 179 |
if __name__ == "__main__":
|