CoolFace
Apppublic

animetoon/toon-api

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
App README

๐ŸŽฅ Project Stream - FastAPI & Telegram Bot (Hugging Face Spaces)

This repository contains the optimized configuration and code to deploy the Movie Stream backend on Hugging Face Spaces using a Docker container.

๐Ÿ›  Features

  • โ€”FastAPI Backend: Handles video streaming, download requests, API endpoints, and health checks.
  • โ€”Telegram Bot: Pyrogram (Pyrofork) bot processing media indexing and file requests.
  • โ€”Dynamic Config Sync: Downloads configuration at runtime from a secure GitHub Gist URL.
  • โ€”24/7 Hosting: Runs seamlessly on Hugging Face's Free CPU tier.
  • โ€”Secure Sandbox: Executed under a non-root user (UID 1000) for enhanced container security.

๐Ÿš€ Setup & Deployment Instructions

1. Prepare your Configuration Gist

  1. 1.Go to gist.github.com and sign in.
  2. 2.Create a new secret Gist (or public if you prefer, but secret is highly recommended for security).
  3. 3.Name the file config.env and paste your environment variables inside. For example:
env
   # Repository details to fetch the backend code dynamically at runtime
   UPSTREAM_REPO = "https://github.com/filmrockers-cloud/Movie-Stream-Server" # Keep token out of Gist for security!
   UPSTREAM_BRANCH = "main"

   API_ID = "20239261"
   API_HASH = "af61dab399ed3220a3a81570b56bd29d"
   BOT_TOKEN = "your_bot_token"
   AUTH_CHANNEL = "-100..."
   MANUAL_CHANNEL = "-100..."
   REPORT_CHANNEL = "-100..."
   DATABASE = "mongodb+srv://..."
   TMDB_API = "..."
   IMDB_API = "https://..."
   PORT = "7860"
   USE_CAPTION = "True"
   USE_TMDB = "True"
   OWNER_ID = "1357978966"
  1. 1.Click Create secret gist.
  2. 2.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.

2. Deploy to Hugging Face Spaces

  1. 1.Create a new Space on Hugging Face:
  2. 2.Go to Hugging Face Spaces and click Create new Space.
  3. 3.Enter a name (e.g., movie-stream-backend).
  4. 4.Select Docker as the SDK.
  5. 5.Choose the Blank template.
  6. 6.Click Create Space.
  7. 7.Set up your Gist and Token Secrets:
  8. 8.Go to the Settings tab of your new Space.
  9. 9.Scroll down to the Variables and secrets section.
  10. 10.Click New secret to add `GIST_URL` (or CONFIG_FILE_URL) and set the value to your Gist URL.
  11. 11.Click New secret again to add `GITHUB_TOKEN` (or PAT_TOKEN) and set the value to your GitHub Personal Access Token (ghp_...).
  12. 12.Upload the Code:
  13. 13.Clone your Hugging Face Space repository locally, or use the Hugging Face Web UI to upload all files from this Movie-Stream-HF folder.
  14. 14.Alternatively, initialize a git repository in this folder and push to Hugging Face:
bash
     git init
     git remote add origin https://huggingface.co/spaces/your-username/your-space-name
     git add .
     git commit -m "initial commit"
     git push -f origin main

Once 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.


Developed with โค๏ธ for ThiruEmpire.