Spaces:
Paused
Paused
title: Instance 1 | |
emoji: π | |
colorFrom: yellow | |
colorTo: red | |
sdk: gradio | |
sdk_version: 4.36.1 | |
app_file: app.py | |
pinned: false | |
## Scripts | |
``` | |
app.py -> main script that run flask server | |
indexer.py -> script to index the repo structure | |
``` | |
## Film and TV API | |
This API provides endpoints for accessing and managing film and TV show data, including downloading, caching, and retrieving metadata. | |
## Table of Contents | |
- [Base URL](#base-url) | |
- [Endpoints](#endpoints) | |
- [Film Endpoints](#film-endpoints) | |
- [TV Show Endpoints](#tv-show-endpoints) | |
- [Cache Endpoints](#cache-endpoints) | |
- [Miscellaneous Endpoints](#miscellaneous-endpoints) | |
- [Error Handling](#error-handling) | |
- [Running the Server](#running-the-server) | |
## Base URL | |
All endpoints are accessed through the base URL: | |
```markdown | |
http://<server-address>:7860 | |
``` | |
Replace `<server-address>` with your server's address. | |
## Endpoints | |
### Film Endpoints | |
#### `GET /api/film` | |
**Description:** Starts the download of a film if it's not already cached. | |
**Query Parameters:** | |
- `title` (string): The title of the film. | |
**Responses:** | |
- `200 OK`: Download started successfully. | |
```json | |
{ | |
"status": "Download started", | |
"film_id": "film_id_here" | |
} | |
``` | |
- `400 Bad Request`: Title parameter is required. | |
```json | |
{ | |
"error": "Title parameter is required" | |
} | |
``` | |
- `404 Not Found`: Movie not found. | |
#### `GET /api/film/store` | |
**Description:** Retrieves the JSON data for the film store. | |
**Responses:** | |
- `200 OK`: Returns the film store JSON data. | |
```json | |
{ | |
"film_title": "cache_path_here" | |
} | |
``` | |
- `404 Not Found`: Film store JSON not found. | |
### TV Show Endpoints | |
#### `GET /api/tv` | |
**Description:** Starts the download of a TV show episode if it's not already cached. | |
**Query Parameters:** | |
- `title` (string): The title of the TV show. | |
- `season` (string): The season number. | |
- `episode` (string): The episode number. | |
**Responses:** | |
- `200 OK`: Download started successfully. | |
```json | |
{ | |
"status": "Download started", | |
"episode_id": "episode_id_here" | |
} | |
``` | |
- `400 Bad Request`: Title, season, and episode parameters are required. | |
```json | |
{ | |
"error": "Title, season, and episode parameters are required" | |
} | |
``` | |
- `404 Not Found`: TV show or episode not found. | |
#### `GET /api/tv/store` | |
**Description:** Retrieves the JSON data for the TV store. | |
**Responses:** | |
- `200 OK`: Returns the TV store JSON data. | |
```json | |
{ | |
"show_title": { | |
"season": { | |
"episode": "cache_path_here" | |
} | |
} | |
} | |
``` | |
- `404 Not Found`: TV store JSON not found. | |
### Cache Endpoints | |
#### `GET /api/cache/size` | |
**Description:** Retrieves the total size of the cache. | |
**Responses:** | |
- `200 OK`: Returns the cache size in a human-readable format. | |
```json | |
{ | |
"cache_size": "10.5 MB" | |
} | |
``` | |
#### `POST /api/cache/clear` | |
**Description:** Clears the entire cache. | |
**Responses:** | |
- `200 OK`: Cache cleared successfully. | |
```json | |
{ | |
"status": "Cache cleared" | |
} | |
``` | |
### Metadata Endpoints | |
#### `GET /api/filmid` | |
**Description:** Retrieves the film ID by title. | |
**Query Parameters:** | |
- `title` (string): The title of the film. | |
**Responses:** | |
- `200 OK`: Returns the film ID. | |
```json | |
{ | |
"film_id": "film_id_here" | |
} | |
``` | |
- `400 Bad Request`: Title parameter is required. | |
```json | |
{ | |
"error": "Title parameter is required" | |
} | |
``` | |
#### `GET /api/episodeid` | |
**Description:** Retrieves the episode ID by title, season, and episode. | |
**Query Parameters:** | |
- `title` (string): The title of the TV show. | |
- `season` (string): The season number. | |
- `episode` (string): The episode number. | |
**Responses:** | |
- `200 OK`: Returns the episode ID. | |
```json | |
{ | |
"episode_id": "episode_id_here" | |
} | |
``` | |
- `400 Bad Request`: Title, season, and episode parameters are required. | |
```json | |
{ | |
"error": "Title, season, and episode parameters are required" | |
} | |
``` | |
### Miscellaneous Endpoints | |
#### `GET /api/film/all` | |
**Description:** Retrieves a list of all films. | |
**Responses:** | |
- `200 OK`: Returns a list of film paths. | |
```json | |
[ | |
"film_path_1", | |
"film_path_2" | |
] | |
``` | |
#### `GET /api/tv/all` | |
**Description:** Retrieves a list of all TV shows. | |
**Responses:** | |
- `200 OK`: Returns a list of TV shows with their episodes. | |
```json | |
{ | |
"show_title": [ | |
{ | |
"season": "season_number", | |
"episode": "episode_title" | |
} | |
] | |
} | |
``` | |
## Error Handling | |
All endpoints return standard HTTP status codes: | |
- `200 OK` for successful requests. | |
- `400 Bad Request` for invalid requests. | |
- `404 Not Found` for missing resources. | |
Errors are returned in the following format: | |
```json | |
{ | |
"error": "Error message here" | |
} | |
``` | |
## Running the Server | |
To run the server, ensure you have all required dependencies installed and use the following command: | |
```bash | |
python app.py | |
``` | |
The server will start on `http://0.0.0.0:7860` by default. | |
--- |