-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathindex.js
127 lines (112 loc) · 3.93 KB
/
index.js
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
import express from "express";
import cors from "cors";
import os from "node:os";
import 'dotenv/config';
import chalk from "chalk";
const app = express();
app.use(express.urlencoded({ extended: true }));
import fs from "fs";
app.use(express.json());
// const PORT = process.env.DHRUV_JTV_PORT || 3500;
const PORT = process.env.PORT || 3500;
import path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// import { handler } from "file://D:/projects/JTVServer github/WEB/build/handler.js";
// let networkInterfaces = os.networkInterfaces();
// let ip = networkInterfaces["eth0"][0]["address"];
// fs["writeFileSync"]("./ipData.jiotv", ip);
if (!fs.existsSync("channel.db")) {
fs["writeFileSync"]("./channel.db", '{"channel": {}}');
}
if (!fs.existsSync("channel-catchup.db")) {
fs["writeFileSync"]("./channel-catchup.db", '{"channel": {}}');
}
app.get("/login.html", (req, res) => {
res.sendFile(path.join(__dirname, "public", "login.html"));
});
app.get("/login", (req, res) => {
res.sendFile(path.join(__dirname, "public", "login.html"));
});
app.get("/admin", (req, res) => {
res.sendFile(path.join(__dirname, "public", "login.html"));
});
app.get("/admin.html", (req, res) => {
res.sendFile(path.join(__dirname, "public", "login.html"));
});
app.use(cors());
import loginRoute from "./routes/login.mjs";
import ipRoute from "./routes/ip.mjs";
import channelsRoute from "./routes/channel.mjs";
import playlistRoute from "./routes/playlist.mjs";
import catchulRoute from "./routes/catchup/index.mjs";
app.use("/", loginRoute);
app.use("/", ipRoute);
app.use("/", channelsRoute);
app.use("/", playlistRoute);
app.use("/catchup", catchulRoute);
// app.use(express.static(path.join(__dirname, "public")));
app.get("/favicon.ico", (req, res) => {
return res.sendFile(path.join(__dirname + "/public/favicon.ico"));
});
import { handler } from "./build/handler.js";
app.use(handler);
app.listen(PORT, "0.0.0.0", async () => {
let r
try {
r = await fetch("https://api.github.com/repos/dhruv-2015/JIOTVServer/releases/latest");
r = await r.json();
r = r['tag_name']
} catch (error) {
}
console.log(
"==================================================================="
);
console.log(
chalk.green("THIS SERVER IS 100% FREE. PLEASE DON'T PAY ANYONE.")
);
console.log(
chalk.green(
"STRICT ACTION WILL BE TAKEN AGAINST THOSE WHO ARE SELLING THIS."
)
);
console.log(
chalk.green(
"IF ANYONE TRYING TO SELL IT, PLEASE REPORT IT ON OUR DISCORD SERVER\nhttps://discord.gg/suyzkCQKhC"
)
);
console.log(
chalk.green("Please Stare Repo https://github.com/dhruv-2015/JIOTVServer")
);
if (r) {
// console.log(chalk.green("VERSION 2.8.6"));
console.log(chalk.green(`VERSION ${r}`));
}
console.log(
chalk.green(
"980+ CHANNELS AVAILABLE. MORE FEATURES WILL COME SOON. STAY TUNED"
)
);
console.log(
"==================================================================="
);
console.log(
chalk.red(
" __ ____ ____ ______ _ __ \n / // _// __ \\ /_ __/| | / / \n __ / / / / / / / / / / | | / / \n/ /_/ /_/ / / /_/ / / / | |/ / \n\\____//___/ \\____/ /_/ |___/ \n "
)
);
console.log(
"==================================================================="
);
console.log(`TV server is running on port ${PORT}`);
console.log(
`Please open http://localhost:${PORT}/login from the host to login and get playlist if running server for the first time`
);
console.log(
`Note: If hosted in a website, you may want to use the domain or its IP`
);
// console.log(chalk.red("need to login every 24 hours even if you are already logged in"));
console.log("If facing any errors, please login from portal again");
console.log("you can use server m3u8 links in other websites and apps");
});