File size: 4,112 Bytes
cf54400 8725d0d 6d1a377 e47fc7c 8725d0d cf54400 8725d0d 6e5685b 8725d0d 6e5685b 8725d0d 6e5685b 8725d0d 6e5685b 8725d0d 6e5685b 8725d0d 6e5685b 8725d0d 6e5685b 8725d0d 6e5685b 8725d0d 6e5685b 8725d0d 6e5685b 8725d0d 6e5685b 8725d0d 6e5685b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
---
title: Load Balancer
emoji: π
colorFrom: yellow
colorTo: red
sdk: gradio
sdk_version: 4.36.1
app_file: app.py
pinned: false
---
# API Documentation
This is a Flask-based API application that serves various endpoints to manage and retrieve information about films and TV shows, including caching, metadata, and download progress. The application functions as a load balancer to manage media content.
## Prerequisites
- Python 3.10
- Flask
- Flask-CORS
- requests
- python-dotenv
- tqdm
## Installation
1. Clone the repository.
2. Install the required packages using pip:
```bash
pip install -r requirements.txt
```
3. Set up the necessary environment variables:
- `CACHE_DIR`: Directory where cached files are stored.
- `INDEX_FILE`: Path to the index file.
- `TOKEN`: API token for Huggingface.
- `REPO`: Huggingface Repository URL.
- `THETVDB_API_KEY` : TheTVDB API key.
- `THETVDB_API_URL` : TheTVDB API url
## Usage
To start the Flask server, run:
```bash
python app.py
```
The server will run on `http://0.0.0.0:7860`.
## API Endpoints
### Get Movie by Title
- **URL:** `/api/film/<title>`
- **Method:** `GET`
- **Description:** Retrieves the URL of the movie by its title. If not cached, it starts the download process.
- **Parameters:**
- `title` (string): The title of the movie.
### Get TV Show Episode by Title, Season, and Episode
- **URL:** `/api/tv/<title>/<season>/<episode>`
- **Method:** `GET`
- **Description:** Retrieves the URL of the TV show episode by its title, season, and episode. If not cached, it starts the download process.
- **Parameters:**
- `title` (string): The title of the TV show.
- `season` (string): The season number.
- `episode` (string): The episode number.
### Get Film ID by Title
- **URL:** `/api/filmid/<title>`
- **Method:** `GET`
- **Description:** Retrieves the film ID by providing the movie title.
- **Parameters:**
- `title` (string): The title of the movie.
### Get Episode ID by Title, Season, and Episode
- **URL:** `/api/episodeid/<title>/<season>/<episode>`
- **Method:** `GET`
- **Description:** Retrieves the episode ID by providing the TV show title, season, and episode.
- **Parameters:**
- `title` (string): The title of the TV show.
- `season` (string): The season number.
- `episode` (string): The episode number.
### Get Cache Size
- **URL:** `/api/cache/size`
- **Method:** `GET`
- **Description:** Retrieves the total size of the cache in a human-readable format.
### Clear Cache
- **URL:** `/api/cache/clear`
- **Method:** `POST`
- **Description:** Clears the entire cache.
### Get TV Store JSON
- **URL:** `/api/tv/store`
- **Method:** `GET`
- **Description:** Retrieves the TV store JSON.
### Get Film Store JSON
- **URL:** `/api/film/store`
- **Method:** `GET`
- **Description:** Retrieves the film store JSON.
### Get Film Metadata by Title
- **URL:** `/api/film/metadata/<title>`
- **Method:** `GET`
- **Description:** Retrieves the metadata of a film by its title.
- **Parameters:**
- `title` (string): The title of the movie.
### Get TV Show Metadata by Title
- **URL:** `/api/tv/metadata/<title>`
- **Method:** `GET`
- **Description:** Retrieves the metadata of a TV show by its title.
- **Parameters:**
- `title` (string): The title of the TV show.
### Get All Films
- **URL:** `/api/film/all`
- **Method:** `GET`
- **Description:** Retrieves a list of all films.
### Get All TV Shows
- **URL:** `/api/tv/all`
- **Method:** `GET`
- **Description:** Retrieves a list of all TV shows.
### Get Instances
- **URL:** `/api/instances`
- **Method:** `GET`
- **Description:** Retrieves a list of all registered instances.
### Get Instances Health
- **URL:** `/api/instances/health`
- **Method:** `GET`
- **Description:** Retrieves the health status of all registered instances.
### Register Instance (Only for Instance)
- **URL:** `/api/register`
- **Method:** `POST`
- **Description:** Registers a new instance.
- **Request Body:**
- `url` (string): The URL of the instance.
## License
This project is licensed under the `MIT License` |