@home-cinema/app 0.0.2 → 0.0.6-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +14 -4
- package/dist/api/routes/config.js +5 -4
- package/dist/api/routes/streamFiles.js +51 -40
- package/dist/api/routes/tv_shows.js +89 -83
- package/dist/client/assets/index-BUIPTbGd.js +682 -0
- package/dist/client/assets/index-KLlodciu.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/lib/idb.js +37 -1
- package/dist/server.js +12 -1
- package/dist/serverBoot.js +44 -8
- package/home_cinema_config.json +2 -2
- package/package.json +41 -37
- package/dist/client/assets/index-CeKR2k9Q.js +0 -749
- package/dist/client/assets/index-DWHHH3Bn.css +0 -1
package/dist/api/index.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import * as Config from "./routes/config.js";
|
|
2
|
+
import * as tvShows from "./routes/tv_shows.js";
|
|
3
|
+
import * as playlist from "./routes/streamFiles.js";
|
|
4
|
+
import { Router } from "express";
|
|
5
|
+
const router = Router();
|
|
6
|
+
export function declareRoutes(config) {
|
|
7
|
+
tvShows.TVShows(router, config);
|
|
8
|
+
tvShows.TVShowsSearch(router, config);
|
|
9
|
+
tvShows.TVShowsDetails(router, config);
|
|
10
|
+
tvShows.TVShowsSeasonDetails(router, config);
|
|
11
|
+
playlist.Playlist(router, config);
|
|
12
|
+
Config.getConfigs(router, config);
|
|
13
|
+
return router;
|
|
14
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Router } from "express";
|
|
2
|
-
import data from "../../../home_cinema_config.json" with { type: "json" };
|
|
3
2
|
export const router = Router();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export function getConfigs(router, config) {
|
|
4
|
+
router.get("/api/config", (_, res) => {
|
|
5
|
+
res.status(200).json(config);
|
|
6
|
+
});
|
|
7
|
+
}
|
|
@@ -1,42 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
3
|
-
router.get("/api/playlist", (req, res) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
export function Playlist(router, _) {
|
|
3
|
+
router.get("/api/playlist", (req, res) => {
|
|
4
|
+
let streams = [];
|
|
5
|
+
if (typeof req.query.streams === "string") {
|
|
6
|
+
streams = [req.query.streams];
|
|
7
|
+
}
|
|
8
|
+
else if (req.query.streams instanceof Array) {
|
|
9
|
+
streams = req.query.streams;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
res.status(400).json({
|
|
13
|
+
error: "Stream urls are required",
|
|
14
|
+
});
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
let names = [];
|
|
18
|
+
if (typeof req.query.names === "string") {
|
|
19
|
+
names = [req.query.names];
|
|
20
|
+
}
|
|
21
|
+
else if (req.query.names instanceof Array) {
|
|
22
|
+
names = req.query.names;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
res.status(400).json({
|
|
26
|
+
error: "stream names are required",
|
|
27
|
+
});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let fileName = req.query.fileName;
|
|
31
|
+
if (!fileName) {
|
|
32
|
+
fileName = "playlist";
|
|
33
|
+
}
|
|
34
|
+
let playlist = "#EXTM3U\n";
|
|
35
|
+
streams.forEach((url, index) => {
|
|
36
|
+
playlist += `#EXTINF:-1,${names[index]}\n${url}\n`;
|
|
14
37
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
let fileName = req.query.fileName;
|
|
31
|
-
if (!fileName) {
|
|
32
|
-
fileName = "playlist";
|
|
33
|
-
}
|
|
34
|
-
let playlist = "#EXTM3U\n";
|
|
35
|
-
streams.forEach((url, index) => {
|
|
36
|
-
playlist += `#EXTINF:-1,${names[index]}\n${url}\n`;
|
|
38
|
+
// Set response headers
|
|
39
|
+
res.setHeader("Content-Type", "audio/x-mpegurl");
|
|
40
|
+
res.setHeader("Content-Disposition", `attachment; filename="${fileName}.m3u"`);
|
|
41
|
+
res.send(playlist);
|
|
42
|
+
try {
|
|
43
|
+
const url = new URL("/api/play-vlc", "http://" + req.get("host"));
|
|
44
|
+
streams.map((s) => {
|
|
45
|
+
url.searchParams.append("streams", s);
|
|
46
|
+
});
|
|
47
|
+
axios.get(url.href);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
console.log(err);
|
|
51
|
+
}
|
|
37
52
|
});
|
|
38
|
-
|
|
39
|
-
res.setHeader("Content-Type", "audio/x-mpegurl");
|
|
40
|
-
res.setHeader("Content-Disposition", `attachment; filename="${fileName}.m3u"`);
|
|
41
|
-
res.send(playlist);
|
|
42
|
-
});
|
|
53
|
+
}
|
|
@@ -1,98 +1,104 @@
|
|
|
1
|
-
import { Router } from "express";
|
|
2
1
|
import { TMDBApi, TMDBError } from "../../lib/tmdb_api.js";
|
|
3
|
-
export
|
|
4
|
-
|
|
2
|
+
export function TVShows(router, config) {
|
|
3
|
+
router.get("/api/tv_shows", async (req, res) => {
|
|
4
|
+
try {
|
|
5
|
+
const tmApi = new TMDBApi(process.env.TMDB_KEY);
|
|
6
|
+
let page = req.query.page;
|
|
7
|
+
if (page && isNaN(+page)) {
|
|
8
|
+
page = "1";
|
|
9
|
+
}
|
|
10
|
+
const data = await tmApi.getTVShows(page);
|
|
11
|
+
res.status(200).json(data);
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
if (err instanceof TMDBError) {
|
|
15
|
+
res.status(err.statusCode || 500).json({
|
|
16
|
+
error: err.message,
|
|
17
|
+
});
|
|
18
|
+
console.log(TMDBError.format(err));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
res.status(500).json({
|
|
22
|
+
error: "internal server error",
|
|
23
|
+
});
|
|
24
|
+
console.log("error when getting TV SHOWS");
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export function HandlerTMDBApiErr(res, err) {
|
|
5
29
|
console.log(TMDBError.format(err));
|
|
6
30
|
res.status(err.statusCode || 500).json({
|
|
7
31
|
error: err.message,
|
|
8
32
|
});
|
|
9
33
|
return;
|
|
10
34
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
35
|
+
export function TVShowsSearch(router, config) {
|
|
36
|
+
router.get("/api/tv_shows/search", async (req, res) => {
|
|
37
|
+
try {
|
|
38
|
+
const query = req.query.query;
|
|
39
|
+
let page = +req.query.page;
|
|
40
|
+
if (typeof query !== "string") {
|
|
41
|
+
res.status(400).json({
|
|
42
|
+
error: "search query is required",
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!page) {
|
|
47
|
+
page = 1;
|
|
48
|
+
}
|
|
49
|
+
const api = new TMDBApi(process.env.TMDB_KEY);
|
|
50
|
+
const data = await api.searchTvShows(query, page.toString());
|
|
51
|
+
res.status(200).json(data);
|
|
17
52
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
error: err.message,
|
|
53
|
+
catch (err) {
|
|
54
|
+
if (err instanceof TMDBError) {
|
|
55
|
+
return HandlerTMDBApiErr(res, err);
|
|
56
|
+
}
|
|
57
|
+
res.status(500).json({
|
|
58
|
+
error: "Internal Server Error",
|
|
25
59
|
});
|
|
26
|
-
console.log(TMDBError.format(err));
|
|
27
|
-
return;
|
|
28
60
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
let page = +req.query.page;
|
|
39
|
-
if (typeof query !== "string") {
|
|
40
|
-
res.status(400).json({
|
|
41
|
-
error: "search query is required",
|
|
42
|
-
});
|
|
43
|
-
return;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
export function TVShowsDetails(router, config) {
|
|
64
|
+
router.get("/api/tv_shows/:id", async (req, res) => {
|
|
65
|
+
try {
|
|
66
|
+
const id = req.params.id;
|
|
67
|
+
const api = new TMDBApi(process.env.TMDB_KEY);
|
|
68
|
+
const data = await api.getTVShowDetails(id);
|
|
69
|
+
res.status(200).json(data);
|
|
44
70
|
}
|
|
45
|
-
|
|
46
|
-
|
|
71
|
+
catch (err) {
|
|
72
|
+
if (err instanceof TMDBError) {
|
|
73
|
+
console.log(TMDBError.format(err));
|
|
74
|
+
res.status(err.statusCode || 500).json({
|
|
75
|
+
error: err.message,
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
console.log("Internal Server Error !! : ", err);
|
|
80
|
+
res.status(500).json({
|
|
81
|
+
error: "internal server error",
|
|
82
|
+
});
|
|
47
83
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
export function TVShowsSeasonDetails(router, config) {
|
|
87
|
+
router.get("/api/tv_shows/:id/season/:season_number", async (req, res) => {
|
|
88
|
+
try {
|
|
89
|
+
const id = req.params.id;
|
|
90
|
+
const seasonNumber = req.params.season_number;
|
|
91
|
+
const api = new TMDBApi(process.env.TMDB_KEY);
|
|
92
|
+
const data = await api.getSeasonDetails(id, seasonNumber);
|
|
93
|
+
res.status(200).json(data);
|
|
55
94
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
const id = req.params.id;
|
|
64
|
-
const api = new TMDBApi(process.env.TMDB_KEY);
|
|
65
|
-
const data = await api.getTVShowDetails(id);
|
|
66
|
-
res.status(200).json(data);
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
if (err instanceof TMDBError) {
|
|
70
|
-
console.log(TMDBError.format(err));
|
|
71
|
-
res.status(err.statusCode || 500).json({
|
|
72
|
-
error: err.message,
|
|
95
|
+
catch (err) {
|
|
96
|
+
if (err instanceof TMDBError) {
|
|
97
|
+
return HandlerTMDBApiErr(res, err);
|
|
98
|
+
}
|
|
99
|
+
res.status(500).json({
|
|
100
|
+
error: "Internal Server Error",
|
|
73
101
|
});
|
|
74
|
-
return;
|
|
75
102
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
error: "internal server error",
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
router.get("/api/tv_shows/:id/season/:season_number", async (req, res) => {
|
|
83
|
-
try {
|
|
84
|
-
const id = req.params.id;
|
|
85
|
-
const seasonNumber = req.params.season_number;
|
|
86
|
-
const api = new TMDBApi(process.env.TMDB_KEY);
|
|
87
|
-
const data = await api.getSeasonDetails(id, seasonNumber);
|
|
88
|
-
res.status(200).json(data);
|
|
89
|
-
}
|
|
90
|
-
catch (err) {
|
|
91
|
-
if (err instanceof TMDBError) {
|
|
92
|
-
return HandlerTMDBApiErr(res, err);
|
|
93
|
-
}
|
|
94
|
-
res.status(500).json({
|
|
95
|
-
error: "Internal Server Error",
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
});
|
|
103
|
+
});
|
|
104
|
+
}
|