Emano209 commited on
Commit
eaeb903
·
verified ·
1 Parent(s): 4a9c15e

Delete index.js

Browse files
Files changed (1) hide show
  1. index.js +0 -178
index.js DELETED
@@ -1,178 +0,0 @@
1
- const express = require('express');
2
- const cors = require('cors');
3
- const { getShowboxStreams } = require('./showbox');
4
-
5
- const app = express();
6
- app.use(cors());
7
-
8
- const PORT = process.env.PORT || 7860;
9
-
10
- const FEBBOX_UI_COOKIE = process.env.FEBBOX_UI_COOKIE || '';
11
- const TMDB_API_KEY = process.env.TMDB_API_KEY || '';
12
-
13
- const manifest = {
14
- id: 'community.showbox-febbox-streams',
15
- version: '3.0.0',
16
- name: 'ShowBox Streams',
17
- description: 'Direct HTTP streams via ShowBox + FebBox.',
18
- logo: 'https://www.febbox.com/favicon.ico',
19
- resources: ['stream'],
20
- types: ['movie', 'series'],
21
- idPrefixes: ['tt'],
22
- catalogs: [],
23
- behaviorHints: { adult: false, p2p: false },
24
- };
25
-
26
- app.get('/', (req, res) => {
27
- const hasCookie = !!FEBBOX_UI_COOKIE;
28
- const hasKey = !!TMDB_API_KEY;
29
- const host = process.env.SPACE_HOST
30
- ? `https://${process.env.SPACE_HOST}`
31
- : `http://localhost:${PORT}`;
32
-
33
- res.send(`<!DOCTYPE html><html>
34
- <head><title>ShowBox Streams</title>
35
- <style>
36
- *{box-sizing:border-box}body{font-family:-apple-system,sans-serif;max-width:640px;
37
- margin:60px auto;color:#e0e0e0;background:#0f0f0f;padding:24px}h1{color:#fff}
38
- .badge{display:inline-block;padding:3px 12px;border-radius:20px;font-size:12px;margin:2px}
39
- .ok{background:#1e4d1e}.no{background:#4d1e1e}
40
- .btn{display:inline-block;padding:12px 26px;background:#7b5ea7;color:#fff;
41
- text-decoration:none;border-radius:8px;font-size:15px;margin-top:8px}
42
- code{background:#1e1e1e;padding:2px 7px;border-radius:4px;font-size:13px}
43
- .box{background:#1a1a1a;border:1px solid #2a2a2a;border-radius:10px;padding:16px;margin:18px 0}
44
- .box h3{margin-top:0;color:#888;font-size:12px;text-transform:uppercase;letter-spacing:1px}
45
- ol{margin:0;padding-left:18px;line-height:2;font-size:14px}a{color:#9b79d4}
46
- </style></head>
47
- <body>
48
- <h1>🎬 ShowBox Streams</h1>
49
- <span class="badge ${hasCookie?'ok':'no'}">${hasCookie?'✅ FebBox cookie set':'⚠️ No FebBox cookie'}</span>
50
- <span class="badge ${hasKey?'ok':'no'}">${hasKey?'✅ TMDB key set':'⚠️ No TMDB key'}</span>
51
-
52
- <p>Stremio addon for direct HTTP streams via ShowBox + FebBox.</p>
53
- <a class="btn" href="stremio://${host.replace(/^https?:\/\//,'')}/manifest.json">➕ Install in Stremio</a>
54
- <p style="font-size:13px;color:#666;margin-top:8px">Or add manually:<br>
55
- <code>${host}/manifest.json</code></p>
56
-
57
- <div class="box">
58
- <h3>Required: FebBox ui cookie</h3>
59
- <ol>
60
- <li>Go to <a href="https://www.febbox.com" target="_blank">febbox.com</a> → log in with Google</li>
61
- <li>Press F12 → Application → Cookies → <code>febbox.com</code></li>
62
- <li>Copy the value of the <strong>ui</strong> cookie</li>
63
- <li>Add as secret <code>FEBBOX_UI_COOKIE</code> in HuggingFace Space settings</li>
64
- </ol>
65
- </div>
66
-
67
- <div class="box">
68
- <h3>Required: TMDB API key</h3>
69
- <ol>
70
- <li>Go to <a href="https://www.themoviedb.org/signup" target="_blank">themoviedb.org</a> → sign up free</li>
71
- <li>Go to Settings → API → Request a v3 API Key (takes ~1 min)</li>
72
- <li>Add as secret <code>TMDB_API_KEY</code> in HuggingFace Space settings</li>
73
- </ol>
74
- </div>
75
- </body></html>`);
76
- });
77
-
78
- app.get('/manifest.json', (_req, res) => res.json(manifest));
79
-
80
- app.get('/deploy', (_req, res) => res.sendFile(__dirname + '/deploy.html'));
81
-
82
- // Proxy the Cloudflare Worker deploy API call (avoids browser CORS)
83
- app.post('/deploy-worker', express.json(), async (req, res) => {
84
- const { accountId, apiToken } = req.body;
85
- if (!accountId || !apiToken) return res.json({ success: false, error: 'Missing fields' });
86
-
87
- const workerCode = `export default {
88
- async fetch(request) {
89
- const url = new URL(request.url);
90
- const destination = url.searchParams.get("destination");
91
- if (!destination) return new Response("Missing destination", { status: 400 });
92
- const res = await fetch(decodeURIComponent(destination), {
93
- headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" },
94
- });
95
- return new Response(res.body, {
96
- status: res.status,
97
- headers: {
98
- "Content-Type": res.headers.get("Content-Type") || "application/json",
99
- "Access-Control-Allow-Origin": "*",
100
- },
101
- });
102
- },
103
- };`;
104
-
105
- try {
106
- const axios = require('axios');
107
- const FormData = require('form-data');
108
- const form = new FormData();
109
- form.append('metadata', Buffer.from(JSON.stringify({
110
- main_module: 'worker.js',
111
- compatibility_date: '2024-01-01',
112
- })), { filename: 'metadata', contentType: 'application/json' });
113
- form.append('worker.js', Buffer.from(workerCode), { filename: 'worker.js', contentType: 'application/javascript+module' });
114
-
115
- const cfRes = await axios.put(
116
- `https://api.cloudflare.com/client/v4/accounts/${accountId}/workers/scripts/showbox-proxy`,
117
- form,
118
- { headers: { Authorization: `Bearer ${apiToken}`, ...form.getHeaders() } }
119
- );
120
-
121
- if (!cfRes.data.success) return res.json({ success: false, error: cfRes.data.errors?.[0]?.message });
122
-
123
- // Get subdomain
124
- const subRes = await axios.get(
125
- `https://api.cloudflare.com/client/v4/accounts/${accountId}/workers/subdomain`,
126
- { headers: { Authorization: `Bearer ${apiToken}` } }
127
- );
128
- const subdomain = subRes.data.result?.subdomain || 'YOUR_SUBDOMAIN';
129
- const proxyUrl = `https://showbox-proxy.${subdomain}.workers.dev`;
130
- res.json({ success: true, proxyUrl });
131
- } catch (err) {
132
- res.json({ success: false, error: err.response?.data?.errors?.[0]?.message || err.message });
133
- }
134
- });
135
-
136
- app.get('/stream/:type/:id.json', async (req, res) => {
137
- const { type, id } = req.params;
138
- let imdbId, season, episode;
139
-
140
- if (type === 'series') {
141
- const p = id.split(':');
142
- imdbId = p[0]; season = +p[1]; episode = +p[2];
143
- } else {
144
- imdbId = id;
145
- }
146
-
147
- console.log(`\n[req] ${type} ${imdbId}${season != null ? ` S${season}E${episode}` : ''}`);
148
-
149
- if (!TMDB_API_KEY) {
150
- console.error('[err] TMDB_API_KEY not set!');
151
- return res.json({ streams: [] });
152
- }
153
- if (!FEBBOX_UI_COOKIE) {
154
- console.warn('[warn] FEBBOX_UI_COOKIE not set — streams may fail');
155
- }
156
-
157
- try {
158
- const streams = await getShowboxStreams({
159
- imdbId,
160
- type,
161
- season: season ?? null,
162
- episode: episode ?? null,
163
- uiCookie: FEBBOX_UI_COOKIE,
164
- tmdbApiKey: TMDB_API_KEY,
165
- });
166
- res.json({ streams });
167
- } catch (err) {
168
- console.error('[err]', err.message);
169
- res.json({ streams: [] });
170
- }
171
- });
172
-
173
- app.listen(PORT, () => {
174
- console.log(`\n🎬 ShowBox Stremio Addon — port ${PORT}`);
175
- if (!TMDB_API_KEY) console.log('⚠ TMDB_API_KEY not set — addon will not work');
176
- if (!FEBBOX_UI_COOKIE) console.log('⚠ FEBBOX_UI_COOKIE not set — streams may fail');
177
- if (TMDB_API_KEY && FEBBOX_UI_COOKIE) console.log('✅ All secrets loaded');
178
- });