File size: 4,959 Bytes
7942766
4afe0d2
710f611
 
 
 
 
7942766
 
 
 
ac28d89
 
c9f8e3c
 
 
 
 
ac28d89
c9f8e3c
ac28d89
c9f8e3c
ac28d89
c9f8e3c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
---
title: Instance 1
emoji: πŸš€
colorFrom: yellow
colorTo: red
sdk: gradio
sdk_version: 4.36.1
app_file: app.py
pinned: false
---


## Scripts
```
app.py         ->  main script that run flask server
indexer.py     ->  script to index the repo structure
```
## Film and TV API

This API provides endpoints for accessing and managing film and TV show data, including downloading, caching, and retrieving metadata.

## Table of Contents


- [Base URL](#base-url)
- [Endpoints](#endpoints)
  - [Film Endpoints](#film-endpoints)
  - [TV Show Endpoints](#tv-show-endpoints)
  - [Cache Endpoints](#cache-endpoints)
  - [Miscellaneous Endpoints](#miscellaneous-endpoints)
- [Error Handling](#error-handling)
- [Running the Server](#running-the-server)


## Base URL

All endpoints are accessed through the base URL:

```markdown
http://<server-address>:7860
```

Replace `<server-address>` with your server's address.

## Endpoints

### Film Endpoints

#### `GET /api/film`

**Description:** Starts the download of a film if it's not already cached.

**Query Parameters:**
- `title` (string): The title of the film.

**Responses:**
- `200 OK`: Download started successfully.
  ```json
  {
    "status": "Download started",
    "film_id": "film_id_here"
  }
  ```
- `400 Bad Request`: Title parameter is required.
  ```json
  {
    "error": "Title parameter is required"
  }
  ```
- `404 Not Found`: Movie not found.

#### `GET /api/film/store`

**Description:** Retrieves the JSON data for the film store.

**Responses:**
- `200 OK`: Returns the film store JSON data.
  ```json
  {
    "film_title": "cache_path_here"
  }
  ```
- `404 Not Found`: Film store JSON not found.

### TV Show Endpoints

#### `GET /api/tv`

**Description:** Starts the download of a TV show episode if it's not already cached.

**Query Parameters:**
- `title` (string): The title of the TV show.
- `season` (string): The season number.
- `episode` (string): The episode number.

**Responses:**
- `200 OK`: Download started successfully.
  ```json
  {
    "status": "Download started",
    "episode_id": "episode_id_here"
  }
  ```
- `400 Bad Request`: Title, season, and episode parameters are required.
  ```json
  {
    "error": "Title, season, and episode parameters are required"
  }
  ```
- `404 Not Found`: TV show or episode not found.

#### `GET /api/tv/store`

**Description:** Retrieves the JSON data for the TV store.

**Responses:**
- `200 OK`: Returns the TV store JSON data.
  ```json
  {
    "show_title": {
      "season": {
        "episode": "cache_path_here"
      }
    }
  }
  ```
- `404 Not Found`: TV store JSON not found.

### Cache Endpoints

#### `GET /api/cache/size`

**Description:** Retrieves the total size of the cache.

**Responses:**
- `200 OK`: Returns the cache size in a human-readable format.
  ```json
  {
    "cache_size": "10.5 MB"
  }
  ```

#### `POST /api/cache/clear`

**Description:** Clears the entire cache.

**Responses:**
- `200 OK`: Cache cleared successfully.
  ```json
  {
    "status": "Cache cleared"
  }
  ```

### Metadata Endpoints

#### `GET /api/filmid`

**Description:** Retrieves the film ID by title.

**Query Parameters:**
- `title` (string): The title of the film.

**Responses:**
- `200 OK`: Returns the film ID.
  ```json
  {
    "film_id": "film_id_here"
  }
  ```
- `400 Bad Request`: Title parameter is required.
  ```json
  {
    "error": "Title parameter is required"
  }
  ```

#### `GET /api/episodeid`

**Description:** Retrieves the episode ID by title, season, and episode.

**Query Parameters:**
- `title` (string): The title of the TV show.
- `season` (string): The season number.
- `episode` (string): The episode number.

**Responses:**
- `200 OK`: Returns the episode ID.
  ```json
  {
    "episode_id": "episode_id_here"
  }
  ```
- `400 Bad Request`: Title, season, and episode parameters are required.
  ```json
  {
    "error": "Title, season, and episode parameters are required"
  }
  ```

### Miscellaneous Endpoints

#### `GET /api/film/all`

**Description:** Retrieves a list of all films.

**Responses:**
- `200 OK`: Returns a list of film paths.
  ```json
  [
    "film_path_1",
    "film_path_2"
  ]
  ```

#### `GET /api/tv/all`

**Description:** Retrieves a list of all TV shows.

**Responses:**
- `200 OK`: Returns a list of TV shows with their episodes.
  ```json
  {
    "show_title": [
      {
        "season": "season_number",
        "episode": "episode_title"
      }
    ]
  }
  ```

## Error Handling

All endpoints return standard HTTP status codes:
- `200 OK` for successful requests.
- `400 Bad Request` for invalid requests.
- `404 Not Found` for missing resources.

Errors are returned in the following format:
```json
{
  "error": "Error message here"
}
```

## Running the Server

To run the server, ensure you have all required dependencies installed and use the following command:

```bash
python app.py
```

The server will start on `http://0.0.0.0:7860` by default.

---