File size: 2,271 Bytes
0479731 d0df973 0479731 d0df973 | 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 | ---
title: CraftMovies API
emoji: π¬
colorFrom: red
colorTo: gray
sdk: docker
pinned: false
---
# CraftMovies API β Hugging Face Space
FastAPI backend for CraftMovies, ready for Hugging Face Spaces Docker hosting.
## What this API does
Returns JSON for:
- Search
- Search All: search + TV seasons + episode metadata
- Browse movies
- Browse TV
- Movie detail
- TV show detail
- Episode detail
- Visible iframe `embed_url`
## Important
This API returns metadata and visible iframe embed URLs only. It does **not** bypass DRM, decode protected players, break tokens, or extract hidden third-party footage URLs.
Use returned `embed_url` in an iframe:
```html
<iframe
src="EMBED_URL_HERE"
allow="autoplay; fullscreen; picture-in-picture; encrypted-media"
referrerpolicy="no-referrer"
allowfullscreen
></iframe>
```
## Hugging Face Space setup
Create a new Space:
1. Go to Hugging Face β Spaces
2. Create new Space
3. Choose **Docker**
4. Upload all files from this ZIP
5. Wait for build to finish
The API will run on port `7860`.
## Local test
```bash
pip install -r requirements.txt
python -m uvicorn main:app --host 0.0.0.0 --port 7860 --reload
```
Open:
```text
http://127.0.0.1:7860/docs
```
## Endpoints
```text
GET /
GET /health
GET /api/home
GET /api/search?q=lucifer
GET /api/search-all?q=lucifer&limit_tv=1&limit_episodes=5
GET /api/fetch-movies
GET /api/fetch-tv
GET /api/browse/movie
GET /api/browse/tv
GET /api/movie?url=/movie/5nspt-the-avengers-2012
GET /api/tv-show?url=/tv/56tj4-lucifer&limit_episodes=5
GET /api/episode?url=/tv/56tj4-lucifer/season/1/episode/3
```
## Main endpoint for app frontend
```text
GET /api/search-all?q=lucifer&limit_tv=1&limit_episodes=5
```
This does:
```text
search
β detect movie/TV
β expand TV show
β extract seasons
β fetch episode pages
β return episode embed_url
```
## Environment variables
Optional variables in Space settings:
```env
CRAFTMOVIES_BASE_URL=https://streamimdb.ru
CRAFTMOVIES_TIMEOUT=15
CRAFTMOVIES_DEBUG=false
CRAFTMOVIES_CACHE_TTL_SECONDS=300
CRAFTMOVIES_CORS_ORIGINS=*
```
## CORS
Default allows all origins:
```env
CRAFTMOVIES_CORS_ORIGINS=*
```
For production, set your frontend domain:
```env
CRAFTMOVIES_CORS_ORIGINS=https://yourfrontend.com
```
|