animetoon/toon-api
0
1---2title: Project Stream3emoji: ๐4colorFrom: blue5colorTo: purple6sdk: docker7app_port: 78608pinned: false9---10 11# ๐ฅ Project Stream - FastAPI & Telegram Bot (Hugging Face Spaces)12 13This repository contains the optimized configuration and code to deploy the **Movie Stream** backend on Hugging Face Spaces using a Docker container.14 15## ๐ Features16- **FastAPI Backend**: Handles video streaming, download requests, API endpoints, and health checks.17- **Telegram Bot**: Pyrogram (Pyrofork) bot processing media indexing and file requests.18- **Dynamic Config Sync**: Downloads configuration at runtime from a secure GitHub Gist URL.19- **24/7 Hosting**: Runs seamlessly on Hugging Face's Free CPU tier.20- **Secure Sandbox**: Executed under a non-root user (UID 1000) for enhanced container security.21 22## ๐ Setup & Deployment Instructions23 24### 1. Prepare your Configuration Gist251. Go to [gist.github.com](https://gist.github.com) and sign in.262. Create a new secret Gist (or public if you prefer, but **secret** is highly recommended for security).273. Name the file `config.env` and paste your environment variables inside. For example:28 ```env29 # Repository details to fetch the backend code dynamically at runtime30 UPSTREAM_REPO = "https://github.com/filmrockers-cloud/Movie-Stream-Server" # Keep token out of Gist for security!31 UPSTREAM_BRANCH = "main"32 33 API_ID = "20239261"34 API_HASH = "af61dab399ed3220a3a81570b56bd29d"35 BOT_TOKEN = "your_bot_token"36 AUTH_CHANNEL = "-100..."37 MANUAL_CHANNEL = "-100..."38 REPORT_CHANNEL = "-100..."39 DATABASE = "mongodb+srv://..."40 TMDB_API = "..."41 IMDB_API = "https://..."42 PORT = "7860"43 USE_CAPTION = "True"44 USE_TMDB = "True"45 OWNER_ID = "1357978966"46 ```474. Click **Create secret gist**.485. Copy the URL of the Gist from your browser address bar (e.g., `https://gist.github.com/username/gist_id`). Our startup script will automatically handle converting it to a raw URL format.49 50---51 52### 2. Deploy to Hugging Face Spaces531. Create a new Space on Hugging Face:54 - Go to [Hugging Face Spaces](https://huggingface.co/spaces) and click **Create new Space**.55 - Enter a name (e.g., `movie-stream-backend`).56 - Select **Docker** as the SDK.57 - Choose the Blank template.58 - Click **Create Space**.592. Set up your Gist and Token Secrets:60 - Go to the **Settings** tab of your new Space.61 - Scroll down to the **Variables and secrets** section.62 - Click **New secret** to add **`GIST_URL`** (or `CONFIG_FILE_URL`) and set the value to your Gist URL.63 - Click **New secret** again to add **`GITHUB_TOKEN`** (or `PAT_TOKEN`) and set the value to your GitHub Personal Access Token (`ghp_...`).643. Upload the Code:65 - Clone your Hugging Face Space repository locally, or use the Hugging Face Web UI to upload all files from this `Movie-Stream-HF` folder.66 - Alternatively, initialize a git repository in this folder and push to Hugging Face:67 ```bash68 git init69 git remote add origin https://huggingface.co/spaces/your-username/your-space-name70 git add .71 git commit -m "initial commit"72 git push -f origin main73 ```74 75Once pushed, Hugging Face will automatically build the Docker image and start the container. The startup process will fetch your configuration from the Gist, write it to `config.env`, initialize the bot services, and bind to port `7860`.76 77---78*Developed with โค๏ธ for ThiruEmpire.*79 