Emano209 commited on
Commit
0f32f4e
·
verified ·
1 Parent(s): d3bb77b

Delete showbox.js

Browse files
Files changed (1) hide show
  1. showbox.js +0 -137
showbox.js DELETED
@@ -1,137 +0,0 @@
1
- // showbox.js — ShowBox + FebBox API client
2
- const crypto = require('crypto');
3
- const axios = require('axios');
4
-
5
- const SHOWBOX_CONFIG = {
6
- BASE_URL: 'https://mbpapi.shegu.net/api/api_client/index/',
7
- APP_KEY: 'moviebox',
8
- APP_ID: 'com.tdo.showbox',
9
- IV: 'wEiphTn!',
10
- KEY: '123d6cedf626dy54233aa1w6',
11
- };
12
-
13
- const FEBBOX_BASE = 'https://www.febbox.com';
14
-
15
- function encrypt(data) {
16
- const key = Buffer.from(SHOWBOX_CONFIG.KEY, 'utf8').slice(0, 16);
17
- const iv = Buffer.from(SHOWBOX_CONFIG.IV.padEnd(16, '\0'), 'utf8').slice(0, 16);
18
- const cipher = crypto.createCipheriv('aes-128-cbc', key, iv);
19
- let enc = cipher.update(JSON.stringify(data), 'utf8', 'base64');
20
- enc += cipher.final('base64');
21
- return enc;
22
- }
23
-
24
- function buildRequest(params) {
25
- const timestamp = Math.floor(Date.now() / 1000);
26
- const payload = { ...params, app_key: SHOWBOX_CONFIG.APP_KEY, app_id: SHOWBOX_CONFIG.APP_ID, timestamp };
27
- return { ...payload, sign: encrypt(payload) };
28
- }
29
-
30
- async function sbGet(targetUrl, proxyUrl) {
31
- const url = proxyUrl ? `${proxyUrl}${encodeURIComponent(targetUrl)}` : targetUrl;
32
- const res = await axios.get(url, {
33
- timeout: 15000,
34
- headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36' },
35
- });
36
- return res.data;
37
- }
38
-
39
- async function fbGet(targetUrl, uiCookie, proxyUrl) {
40
- const url = proxyUrl ? `${proxyUrl}${encodeURIComponent(targetUrl)}` : targetUrl;
41
- const res = await axios.get(url, {
42
- timeout: 15000,
43
- headers: {
44
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
45
- Cookie: `ui=${uiCookie}`,
46
- Referer: 'https://www.febbox.com/',
47
- },
48
- });
49
- return res.data;
50
- }
51
-
52
- async function getShowboxId(imdbId, proxy) {
53
- const params = buildRequest({ imdb_id: imdbId, module: 'Search_v2' });
54
- const url = `${SHOWBOX_CONFIG.BASE_URL}?${new URLSearchParams(params)}`;
55
- const data = await sbGet(url, proxy);
56
- const item = data?.data?.list?.[0];
57
- if (!item) return null;
58
- return { id: item.id, boxType: item.box_type, title: item.title };
59
- }
60
-
61
- async function getShareKey(showboxId, boxType, season, episode, proxy) {
62
- const params = buildRequest({
63
- id: showboxId,
64
- box_type: boxType,
65
- module: boxType === 2 ? 'TV_downloadurl_v3' : 'Movie_downloadurl_v3',
66
- ...(season != null ? { season, episode } : {}),
67
- });
68
- const url = `${SHOWBOX_CONFIG.BASE_URL}?${new URLSearchParams(params)}`;
69
- const data = await sbGet(url, proxy);
70
- const link = data?.data?.link;
71
- if (!link) return null;
72
- const match = link.match(/sw_key=([^&]+)/);
73
- return match ? match[1] : null;
74
- }
75
-
76
- async function getFiles(shareKey, uiCookie, proxy) {
77
- const url = `${FEBBOX_BASE}/file/file_share_list?share_key=${shareKey}&parent_id=0&is_html=0`;
78
- const data = await fbGet(url, uiCookie, proxy);
79
- return data?.data?.file_list || [];
80
- }
81
-
82
- async function getLinks(shareKey, fid, uiCookie, proxy) {
83
- const url = `${FEBBOX_BASE}/file/player?share_key=${shareKey}&fid=${fid}`;
84
- const data = await fbGet(url, uiCookie, proxy);
85
- return data?.data?.sources || [];
86
- }
87
-
88
- function quality(filename) {
89
- const f = (filename || '').toUpperCase();
90
- if (f.includes('2160') || f.includes('4K') || f.includes('UHD')) return '4K';
91
- if (f.includes('1080')) return '1080p';
92
- if (f.includes('720')) return '720p';
93
- if (f.includes('480')) return '480p';
94
- return 'HD';
95
- }
96
-
97
- async function getShowboxStreams(imdbId, type, season, episode, uiCookie, sbProxy, fbProxy) {
98
- const info = await getShowboxId(imdbId, sbProxy);
99
- if (!info) return [];
100
-
101
- console.log(`[ShowBox] "${info.title}" id=${info.id}`);
102
-
103
- const shareKey = await getShareKey(
104
- info.id, info.boxType,
105
- type === 'series' ? season : null,
106
- type === 'series' ? episode : null,
107
- sbProxy
108
- );
109
- if (!shareKey) return [];
110
-
111
- const files = await getFiles(shareKey, uiCookie, fbProxy);
112
- if (!files.length) return [];
113
-
114
- const streams = [];
115
- for (const file of files.slice(0, 5)) {
116
- try {
117
- const q = quality(file.file_name);
118
- const sources = await getLinks(shareKey, file.fid, uiCookie, fbProxy);
119
- for (const src of sources) {
120
- const url = src.file || src.url || src.src;
121
- if (!url) continue;
122
- const label = src.label || q;
123
- streams.push({
124
- url,
125
- name: `ShowBox\n${label}`,
126
- description: `${info.title} · ${label}`,
127
- behaviorHints: { notWebReady: false, filename: file.file_name || `${imdbId}.mkv` },
128
- });
129
- }
130
- } catch (e) {
131
- console.warn(`[ShowBox] fid=${file.fid} failed:`, e.message);
132
- }
133
- }
134
- return streams;
135
- }
136
-
137
- module.exports = { getShowboxStreams };