JOHN SILLVESTOR commited on
Commit
1042c8a
·
verified ·
1 Parent(s): 04ba9b5

Update Node HTTP service

Browse files
Files changed (1) hide show
  1. server.js +0 -19
server.js CHANGED
@@ -18,8 +18,6 @@ const CHUNK = 64 * 1024;
18
  const MIN_ALIGN = 4096;
19
  const BOT_MAX = 12;
20
  const FAST_CHUNK = 512 * 1024;
21
- const MOOV_TAIL = 1024 * 1024;
22
- const PREVIEW_PCT = { anonymous: 30, registered: 60, subscribed: 100 };
23
  const FB_PROJECT = process.env.FIREBASE_PROJECT_ID || "";
24
  const FB_DB = String(process.env.FIREBASE_DB_URL || "").replace(/\/?$/, "/");
25
  const FB_SECRET = process.env.FIREBASE_DB_SECRET || "";
@@ -238,16 +236,6 @@ function pickBot(preferIdx) {
238
  return bot;
239
  }
240
 
241
- function clampPreviewRange(start, end, size, lvl) {
242
- const pct = PREVIEW_PCT[lvl] || 30;
243
- if (pct >= 100 || size <= 0) return { start, end, deny: false };
244
- const headEnd = Math.max(0, Math.floor((size * pct) / 100) - 1);
245
- const tailStart = Math.max(0, size - MOOV_TAIL);
246
- if (start >= tailStart) return { start, end, deny: false };
247
- if (end <= headEnd) return { start, end, deny: false };
248
- if (start <= headEnd) return { start, end: headEnd, deny: false };
249
- return { start, end, deny: true };
250
- }
251
 
252
  async function startBot(token, idx) {
253
  const client = new TelegramClient(new StringSession(""), API_ID, API_HASH, {
@@ -510,13 +498,6 @@ async function handleStream(req, res, url, msgId) {
510
  }
511
  const size = rec.size;
512
  const rng = parseRange(req.headers.range, size);
513
- const cap = clampPreviewRange(rng.start, rng.end, size, ticket.l || "anonymous");
514
- if (cap.deny) {
515
- res.writeHead(416, { "Content-Range": "bytes */" + size, "Accept-Ranges": "bytes" });
516
- return res.end();
517
- }
518
- rng.start = cap.start;
519
- rng.end = cap.end;
520
  const headers = {
521
  "Content-Type": httpVideoType(rec.mime, rec.name),
522
  "Accept-Ranges": "bytes",
 
18
  const MIN_ALIGN = 4096;
19
  const BOT_MAX = 12;
20
  const FAST_CHUNK = 512 * 1024;
 
 
21
  const FB_PROJECT = process.env.FIREBASE_PROJECT_ID || "";
22
  const FB_DB = String(process.env.FIREBASE_DB_URL || "").replace(/\/?$/, "/");
23
  const FB_SECRET = process.env.FIREBASE_DB_SECRET || "";
 
236
  return bot;
237
  }
238
 
 
 
 
 
 
 
 
 
 
 
239
 
240
  async function startBot(token, idx) {
241
  const client = new TelegramClient(new StringSession(""), API_ID, API_HASH, {
 
498
  }
499
  const size = rec.size;
500
  const rng = parseRange(req.headers.range, size);
 
 
 
 
 
 
 
501
  const headers = {
502
  "Content-Type": httpVideoType(rec.mime, rec.name),
503
  "Accept-Ranges": "bytes",