Spaces:
Build error
Build error
A newer version of the Gradio SDK is available:
6.5.1
metadata
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
Clone the repository.
Install the required packages using pip:
pip install -r requirements.txtSet 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:
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