jukebox-media-server 0.1.0 → 0.1.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.
@@ -29,8 +29,8 @@
29
29
  <script>
30
30
  document.documentElement.classList.add('dark')
31
31
  </script>
32
- <script async type="module" crossorigin src="/assets/index-D_um8N7Q.js"></script>
33
- <link rel="stylesheet" crossorigin href="/assets/index-DfXUcX5G.css">
32
+ <script async type="module" crossorigin src="/assets/index-Db82pRvr.js"></script>
33
+ <link rel="stylesheet" crossorigin href="/assets/index-Bxm6Lfvp.css">
34
34
  </head>
35
35
  <body>
36
36
  <div id="root"></div>
@@ -1,11 +1,11 @@
1
+ import { createReadStream, existsSync, mkdirSync, readFileSync, statSync } from "fs";
2
+ import path, { basename, extname, join } from "path";
3
+ import { fileURLToPath } from "url";
1
4
  import { createServer } from "http";
2
5
  import { Http2ServerRequest, constants } from "http2";
3
6
  import { Readable } from "stream";
4
7
  import crypto$1 from "crypto";
5
8
  import { createServer as createServer$1 } from "vite";
6
- import { createReadStream, existsSync, mkdirSync, readFileSync, statSync } from "fs";
7
- import path, { basename, extname, join } from "path";
8
- import { fileURLToPath } from "url";
9
9
  import { versions } from "process";
10
10
  import Database from "better-sqlite3";
11
11
  import crypto$2 from "node:crypto";
@@ -6720,8 +6720,8 @@ const watchProgress = sqliteTable("watch_progress", {
6720
6720
  ensureConfigDirectory();
6721
6721
  const sqlite = new Database(databasePath);
6722
6722
  const db = drizzle(sqlite, { schema: schema_exports });
6723
- const __dirname$1 = path.dirname(fileURLToPath(import.meta.url));
6724
- migrate(db, { migrationsFolder: path.resolve(__dirname$1, "../../drizzle") });
6723
+ const __dirname$2 = path.dirname(fileURLToPath(import.meta.url));
6724
+ migrate(db, { migrationsFolder: path.resolve(__dirname$2, "../../drizzle") });
6725
6725
  //#endregion
6726
6726
  //#region src/api/routes/episode-progress.ts
6727
6727
  const episodeProgressRoutes = new Hono();
@@ -7970,8 +7970,8 @@ app.route("/api/setup", setupRoutes);
7970
7970
  app.route("/api/stream/episode", episodeStreamRoutes);
7971
7971
  app.route("/api/stream", streamRoutes);
7972
7972
  app.get("/api", (c) => c.json({ message: "Jukebox API" }));
7973
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
7974
- const clientDir = path.resolve(__dirname, "../client");
7973
+ const __dirname$1 = path.dirname(fileURLToPath(import.meta.url));
7974
+ const clientDir = path.resolve(__dirname$1, "../client");
7975
7975
  function setupStaticServing() {
7976
7976
  app.use("*", serveStatic({
7977
7977
  root: clientDir,
@@ -8000,7 +8000,9 @@ function setupViteProxy(vitePort) {
8000
8000
  if (c.req.path.startsWith("/api")) return next();
8001
8001
  const viteUrl = `http://localhost:${vitePort}${c.req.path}`;
8002
8002
  const headers = new Headers();
8003
- for (const [key, value] of c.req.raw.headers.entries()) if (!hopByHopHeaders.has(key.toLowerCase())) headers.set(key, value);
8003
+ c.req.raw.headers.forEach((value, key) => {
8004
+ if (!hopByHopHeaders.has(key.toLowerCase())) headers.set(key, value);
8005
+ });
8004
8006
  try {
8005
8007
  const response = await fetch(viteUrl, {
8006
8008
  method: c.req.method,
@@ -8021,6 +8023,16 @@ function setupViteProxy(vitePort) {
8021
8023
  const port = process.env.PORT ? Number(process.env.PORT) : 1990;
8022
8024
  const vitePort = 5173;
8023
8025
  const isDevelopment = process.env.NODE_ENV !== "production";
8026
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8027
+ function readPackageVersion() {
8028
+ const candidates = [path.resolve(__dirname, "../../package.json"), path.resolve(__dirname, "../package.json")];
8029
+ for (const candidate of candidates) try {
8030
+ const content = JSON.parse(readFileSync(candidate, "utf-8"));
8031
+ if (content.name === "jukebox-media-server" && content.version) return content.version;
8032
+ } catch {}
8033
+ return "unknown";
8034
+ }
8035
+ const version = readPackageVersion();
8024
8036
  let viteServer = null;
8025
8037
  if (isDevelopment) {
8026
8038
  viteServer = await createServer$1({
@@ -8031,15 +8043,30 @@ if (isDevelopment) {
8031
8043
  }
8032
8044
  });
8033
8045
  await viteServer.listen();
8034
- console.log(`Vite dev server running at http://localhost:${vitePort}`);
8035
8046
  setupViteProxy(vitePort);
8036
8047
  } else setupStaticServing();
8037
8048
  const server = serve({
8038
8049
  fetch: app.fetch,
8039
8050
  port
8040
8051
  }, (info) => {
8041
- console.log(`Jukebox running at http://localhost:${info.port}`);
8052
+ printWelcome(info.port);
8042
8053
  });
8054
+ function printWelcome(boundPort) {
8055
+ const url = `http://localhost:${boundPort}`;
8056
+ const bold = "\x1B[1m";
8057
+ const cyan = "\x1B[36m";
8058
+ const dim = "\x1B[2m";
8059
+ const reset = "\x1B[0m";
8060
+ const lines = [
8061
+ "",
8062
+ ` ${bold}Jukebox${reset} ${dim}v${version}${reset}`,
8063
+ "",
8064
+ ` ${cyan}➜${reset} Open ${cyan}${url}${reset} in your browser`,
8065
+ ` ${dim}Press Ctrl+C to stop${reset}`,
8066
+ ""
8067
+ ];
8068
+ console.log(lines.join("\n"));
8069
+ }
8043
8070
  function shutdown(signal) {
8044
8071
  console.log(`\nReceived ${signal}, shutting down...`);
8045
8072
  setTimeout(() => process.exit(1), 2e3).unref();
@@ -1,66 +1,66 @@
1
- CREATE TABLE `episodes` (
2
- `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
3
- `show_id` integer NOT NULL,
4
- `season_id` integer NOT NULL,
5
- `season_number` integer NOT NULL,
6
- `episode_number` integer NOT NULL,
7
- `title` text NOT NULL,
8
- `file_path` text NOT NULL,
9
- `file_name` text NOT NULL,
10
- `file_size` integer,
11
- `extension` text,
12
- `tmdb_id` integer,
13
- `overview` text,
14
- `runtime` integer,
15
- `still_path` text,
16
- `created_at` integer NOT NULL,
17
- `updated_at` integer NOT NULL,
18
- FOREIGN KEY (`show_id`) REFERENCES `shows`(`id`) ON UPDATE no action ON DELETE no action,
19
- FOREIGN KEY (`season_id`) REFERENCES `seasons`(`id`) ON UPDATE no action ON DELETE no action
20
- );
21
- --> statement-breakpoint
22
- CREATE UNIQUE INDEX `episodes_file_path_unique` ON `episodes` (`file_path`);--> statement-breakpoint
23
- CREATE TABLE `seasons` (
24
- `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
25
- `show_id` integer NOT NULL,
26
- `season_number` integer NOT NULL,
27
- `name` text,
28
- `overview` text,
29
- `poster_path` text,
30
- `episode_count` integer,
31
- FOREIGN KEY (`show_id`) REFERENCES `shows`(`id`) ON UPDATE no action ON DELETE no action
32
- );
33
- --> statement-breakpoint
34
- CREATE TABLE `shows` (
35
- `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
36
- `title` text NOT NULL,
37
- `folder_path` text NOT NULL,
38
- `tmdb_id` integer,
39
- `year` integer,
40
- `overview` text,
41
- `genres` text,
42
- `rating` real,
43
- `poster_path` text,
44
- `backdrop_path` text,
45
- `created_at` integer NOT NULL,
46
- `updated_at` integer NOT NULL
47
- );
48
- --> statement-breakpoint
49
- CREATE UNIQUE INDEX `shows_folder_path_unique` ON `shows` (`folder_path`);--> statement-breakpoint
50
- PRAGMA foreign_keys=OFF;--> statement-breakpoint
51
- CREATE TABLE `__new_watch_progress` (
52
- `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
53
- `movie_id` integer,
54
- `episode_id` integer,
55
- `current_time` integer NOT NULL,
56
- `duration` integer,
57
- `updated_at` integer NOT NULL,
58
- FOREIGN KEY (`movie_id`) REFERENCES `movies`(`id`) ON UPDATE no action ON DELETE no action,
59
- FOREIGN KEY (`episode_id`) REFERENCES `episodes`(`id`) ON UPDATE no action ON DELETE no action
60
- );
61
- --> statement-breakpoint
62
- INSERT INTO `__new_watch_progress`("id", "movie_id", "episode_id", "current_time", "duration", "updated_at") SELECT "id", "movie_id", "episode_id", "current_time", "duration", "updated_at" FROM `watch_progress`;--> statement-breakpoint
63
- DROP TABLE `watch_progress`;--> statement-breakpoint
64
- ALTER TABLE `__new_watch_progress` RENAME TO `watch_progress`;--> statement-breakpoint
65
- PRAGMA foreign_keys=ON;--> statement-breakpoint
1
+ CREATE TABLE `episodes` (
2
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
3
+ `show_id` integer NOT NULL,
4
+ `season_id` integer NOT NULL,
5
+ `season_number` integer NOT NULL,
6
+ `episode_number` integer NOT NULL,
7
+ `title` text NOT NULL,
8
+ `file_path` text NOT NULL,
9
+ `file_name` text NOT NULL,
10
+ `file_size` integer,
11
+ `extension` text,
12
+ `tmdb_id` integer,
13
+ `overview` text,
14
+ `runtime` integer,
15
+ `still_path` text,
16
+ `created_at` integer NOT NULL,
17
+ `updated_at` integer NOT NULL,
18
+ FOREIGN KEY (`show_id`) REFERENCES `shows`(`id`) ON UPDATE no action ON DELETE no action,
19
+ FOREIGN KEY (`season_id`) REFERENCES `seasons`(`id`) ON UPDATE no action ON DELETE no action
20
+ );
21
+ --> statement-breakpoint
22
+ CREATE UNIQUE INDEX `episodes_file_path_unique` ON `episodes` (`file_path`);--> statement-breakpoint
23
+ CREATE TABLE `seasons` (
24
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
25
+ `show_id` integer NOT NULL,
26
+ `season_number` integer NOT NULL,
27
+ `name` text,
28
+ `overview` text,
29
+ `poster_path` text,
30
+ `episode_count` integer,
31
+ FOREIGN KEY (`show_id`) REFERENCES `shows`(`id`) ON UPDATE no action ON DELETE no action
32
+ );
33
+ --> statement-breakpoint
34
+ CREATE TABLE `shows` (
35
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
36
+ `title` text NOT NULL,
37
+ `folder_path` text NOT NULL,
38
+ `tmdb_id` integer,
39
+ `year` integer,
40
+ `overview` text,
41
+ `genres` text,
42
+ `rating` real,
43
+ `poster_path` text,
44
+ `backdrop_path` text,
45
+ `created_at` integer NOT NULL,
46
+ `updated_at` integer NOT NULL
47
+ );
48
+ --> statement-breakpoint
49
+ CREATE UNIQUE INDEX `shows_folder_path_unique` ON `shows` (`folder_path`);--> statement-breakpoint
50
+ PRAGMA foreign_keys=OFF;--> statement-breakpoint
51
+ CREATE TABLE `__new_watch_progress` (
52
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
53
+ `movie_id` integer,
54
+ `episode_id` integer,
55
+ `current_time` integer NOT NULL,
56
+ `duration` integer,
57
+ `updated_at` integer NOT NULL,
58
+ FOREIGN KEY (`movie_id`) REFERENCES `movies`(`id`) ON UPDATE no action ON DELETE no action,
59
+ FOREIGN KEY (`episode_id`) REFERENCES `episodes`(`id`) ON UPDATE no action ON DELETE no action
60
+ );
61
+ --> statement-breakpoint
62
+ INSERT INTO `__new_watch_progress`("id", "movie_id", "episode_id", "current_time", "duration", "updated_at") SELECT "id", "movie_id", "episode_id", "current_time", "duration", "updated_at" FROM `watch_progress`;--> statement-breakpoint
63
+ DROP TABLE `watch_progress`;--> statement-breakpoint
64
+ ALTER TABLE `__new_watch_progress` RENAME TO `watch_progress`;--> statement-breakpoint
65
+ PRAGMA foreign_keys=ON;--> statement-breakpoint
66
66
  ALTER TABLE `movies` ADD `trailer_url` text;
@@ -1,9 +1,9 @@
1
- CREATE TABLE `libraries` (
2
- `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
3
- `name` text NOT NULL,
4
- `path` text NOT NULL,
5
- `type` text NOT NULL,
6
- `created_at` integer NOT NULL
7
- );
8
- --> statement-breakpoint
1
+ CREATE TABLE `libraries` (
2
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
3
+ `name` text NOT NULL,
4
+ `path` text NOT NULL,
5
+ `type` text NOT NULL,
6
+ `created_at` integer NOT NULL
7
+ );
8
+ --> statement-breakpoint
9
9
  CREATE UNIQUE INDEX `libraries_path_unique` ON `libraries` (`path`);