@axium/kino 0.0.1 → 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.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Kino
2
+
3
+ Axium Kino is the official plugin for managing and watching your own movies and TV shows with Axium.
package/dist/server/db.js CHANGED
@@ -7,7 +7,9 @@ export async function getMovie(id) {
7
7
  const result = await database.selectFrom('kino_movies').where('id', '=', id).selectAll().executeTakeFirst();
8
8
  if (result)
9
9
  return result;
10
- const movie = await tmdb().movies.details(id).then(kt.Movie.parse);
10
+ const movie = await tmdb()
11
+ .movies.details(id)
12
+ .then(d => kt.Movie.parse(d));
11
13
  await database.insertInto('kino_movies').values(movie).returningAll().executeTakeFirstOrThrow();
12
14
  return movie;
13
15
  }
@@ -33,7 +35,9 @@ export async function getTv(id) {
33
35
  // Search caches shows without their seasons, so a row on its own is not enough to skip TMDB
34
36
  if (result?.seasons.length)
35
37
  return result;
36
- const tv = await tmdb().tvShows.details(id).then(kt.Tv.parse);
38
+ const tv = await tmdb()
39
+ .tvShows.details(id)
40
+ .then(d => kt.Tv.parse(d));
37
41
  await database
38
42
  .insertInto('kino_tv')
39
43
  .values(omit(tv, 'seasons'))
@@ -62,7 +66,9 @@ export async function getSeason(id, season_number) {
62
66
  */
63
67
  if (result?.episodes.length)
64
68
  return result;
65
- const season = await tmdb().tvSeasons.details({ tvShowID: id, seasonNumber: season_number }).then(kt.Season.parse);
69
+ const season = await tmdb()
70
+ .tvSeasons.details({ tvShowID: id, seasonNumber: season_number })
71
+ .then(d => kt.Season.parse(d));
66
72
  season.id = id;
67
73
  for (const episode of season.episodes || []) {
68
74
  episode.id = id;
@@ -89,7 +95,7 @@ export async function getEpisode(id, season_number, episode_number) {
89
95
  return result;
90
96
  const episode = await tmdb()
91
97
  .tvEpisode.details({ tvShowID: id, seasonNumber: season_number, episodeNumber: episode_number })
92
- .then(kt.Episode.parse);
98
+ .then(d => kt.Episode.parse(d));
93
99
  episode.id = id;
94
100
  await database
95
101
  .insertInto('kino_episodes')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/kino",
3
- "version": "0.0.1",
3
+ "version": "0.1.1",
4
4
  "author": "James Prevett <axium@jamespre.dev>",
5
5
  "description": "Movies and TV for Axium",
6
6
  "funding": {
@@ -76,7 +76,7 @@
76
76
  "allow_user_uploads": true,
77
77
  "data_dir": "/srv/axium/kino",
78
78
  "tmdb_api_key": "",
79
- "remux": "original",
79
+ "remux": "both",
80
80
  "upload": {
81
81
  "temp_dir": "/tmp/axium",
82
82
  "timeout": 15
@@ -1 +0,0 @@
1
- export {};
@@ -1,57 +0,0 @@
1
- import { requireSession } from '@axium/server/auth';
2
- import { database } from '@axium/server/database';
3
- import { error } from '@axium/server/requests';
4
- import { addRoute } from '@axium/server/routes';
5
- import * as io from 'ioium/node';
6
- import { episodePath, moviePath, removeMedia } from '../media.js';
7
- import { ID, SeasonNumber } from './metadata.js';
8
- /**
9
- * Deleting an upload throws away data for everyone, so it is restricted to administrators
10
- * regardless of `allow_user_uploads`.
11
- */
12
- async function requireAdmin(req) {
13
- const session = await requireSession(req);
14
- if (!session.user.isAdmin)
15
- error(403, 'Only administrators can delete uploads');
16
- }
17
- addRoute({
18
- path: '/api/kino/movies/:id/upload',
19
- params: { id: ID },
20
- async DELETE(req, { id }) {
21
- await requireAdmin(req);
22
- const upload = await database
23
- .deleteFrom('kino_movie_uploads')
24
- .where('id', '=', id)
25
- .returning(['uploadedAt', 'name', 'size', 'type'])
26
- .executeTakeFirst();
27
- if (!upload)
28
- error(404, 'This movie has not been uploaded');
29
- // The row is gone either way; a file we can't remove would only waste space
30
- const removed = removeMedia(moviePath(id));
31
- io.info(`Kino: deleted movie ${id} (${removed.length} file(s))`);
32
- // Progress against a movie nobody can watch anymore is meaningless
33
- await database.deleteFrom('kino_movie_views').where('id', '=', id).execute();
34
- return upload;
35
- },
36
- });
37
- addRoute({
38
- path: '/api/kino/tv/:id/season/:season/episode/:episode/upload',
39
- params: { id: ID, season: SeasonNumber, episode: ID },
40
- async DELETE(req, { id, season, episode }) {
41
- await requireAdmin(req);
42
- const upload = await database
43
- .deleteFrom('kino_tv_uploads')
44
- .where(eb => eb.and({ id, season_number: season, episode_number: episode }))
45
- .returning(['uploadedAt', 'name', 'size', 'type'])
46
- .executeTakeFirst();
47
- if (!upload)
48
- error(404, 'This episode has not been uploaded');
49
- const removed = removeMedia(episodePath(id, season, episode));
50
- io.info(`Kino: deleted episode ${id} S${season}E${episode} (${removed.length} file(s))`);
51
- await database
52
- .deleteFrom('kino_tv_views')
53
- .where(eb => eb.and({ id, season_number: season, episode_number: episode }))
54
- .execute();
55
- return upload;
56
- },
57
- });