import uvicorn import os import requests import json import base64 import os os.system("pip install yt-dlp") import yt_dlp import os def download_video_with_cookies(video_url, cookies_path): # Define options for yt-dlp ydl_opts = { 'cookies': cookies_path, # Path to the cookies file 'outtmpl': 'downloads/%(title)s.%(ext)s', # Define the output file template } # Using yt-dlp to download the video with yt_dlp.YoutubeDL(ydl_opts) as ydl: ydl.download([video_url]) # Downloads the video # Path to the cookies.txt file in your Hugging Face Space cookies_file = '/mnt/data/cookies.txt' # You will need to upload the cookies.txt file here # Example video URL video_url = 'https://www.youtube.com/watch?v=kffacxfA7G4' # Replace with the desired YouTube video URL # Call the download function download_video_with_cookies(video_url, cookies_file) import re import logging from typing import Union from base64 import b64decode from fastapi import FastAPI from fastapi.staticfiles import StaticFiles from fastapi.responses import FileResponse from pydantic import BaseModel from loguru import logger import nest_asyncio LibsicXInstall = os.getenv("LibsicXInstall") os.system(f"pip3 install -q {LibsicXInstall}") logging.basicConfig(level=logging.ERROR) app = FastAPI( title="HellBot", version="1.0.2", contact={ "name": "🌀ʊʄ⊕ք🌀", "url": "https://t.me/UFoPinfo", }, docs_url=None, redoc_url="/" ) class UserRequestIn(BaseModel): text: str @app.post("/test") def index(request: UserRequestIn): logger.debug(request) return {"ok": True} @app.get("/") def HellBot(): return {"message": "running"} if __name__ == "__main__": nest_asyncio.apply() uvicorn.run(app, host="0.0.0.0", port=7860)