@axium/kino 0.0.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.
Files changed (72) hide show
  1. package/LICENSE.md +157 -0
  2. package/db.json +106 -0
  3. package/dist/client/api.d.ts +49 -0
  4. package/dist/client/api.js +136 -0
  5. package/dist/client/frontend.d.ts +3 -0
  6. package/dist/client/frontend.js +33 -0
  7. package/dist/client/index.d.ts +1 -0
  8. package/dist/client/index.js +1 -0
  9. package/dist/client/web_hook.d.ts +8 -0
  10. package/dist/client/web_hook.js +4 -0
  11. package/dist/common.d.ts +749 -0
  12. package/dist/common.js +212 -0
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.js +1 -0
  15. package/dist/server/api/delete.d.ts +1 -0
  16. package/dist/server/api/delete.js +57 -0
  17. package/dist/server/api/metadata.d.ts +4 -0
  18. package/dist/server/api/metadata.js +153 -0
  19. package/dist/server/api/raw.d.ts +1 -0
  20. package/dist/server/api/raw.js +86 -0
  21. package/dist/server/api/search.d.ts +1 -0
  22. package/dist/server/api/search.js +108 -0
  23. package/dist/server/api/upload.d.ts +1 -0
  24. package/dist/server/api/upload.js +122 -0
  25. package/dist/server/api/views.d.ts +1 -0
  26. package/dist/server/api/views.js +128 -0
  27. package/dist/server/db.d.ts +11 -0
  28. package/dist/server/db.js +100 -0
  29. package/dist/server/hooks.d.ts +9 -0
  30. package/dist/server/hooks.js +19 -0
  31. package/dist/server/images.d.ts +12 -0
  32. package/dist/server/images.js +152 -0
  33. package/dist/server/media.d.ts +47 -0
  34. package/dist/server/media.js +136 -0
  35. package/dist/server/tmdb.d.ts +2 -0
  36. package/dist/server/tmdb.js +7 -0
  37. package/lib/EpisodeList.svelte +89 -0
  38. package/lib/MediaActions.svelte +110 -0
  39. package/lib/MediaCard.svelte +41 -0
  40. package/lib/MediaDetail.svelte +140 -0
  41. package/lib/MediaGrid.svelte +27 -0
  42. package/lib/Poster.svelte +49 -0
  43. package/lib/ProgressBar.svelte +22 -0
  44. package/lib/RecentGrid.svelte +82 -0
  45. package/lib/SearchBar.svelte +174 -0
  46. package/lib/SeasonList.svelte +50 -0
  47. package/lib/index.ts +10 -0
  48. package/lib/tsconfig.json +12 -0
  49. package/lib/watch.svelte.ts +93 -0
  50. package/locales/en.json +103 -0
  51. package/package.json +102 -0
  52. package/routes/+layout.svelte +22 -0
  53. package/routes/+layout.ts +21 -0
  54. package/routes/kino/+page.svelte +57 -0
  55. package/routes/kino/+page.ts +19 -0
  56. package/routes/movies/+page.svelte +22 -0
  57. package/routes/movies/+page.ts +12 -0
  58. package/routes/movies/[id]/+page.svelte +36 -0
  59. package/routes/movies/[id]/+page.ts +7 -0
  60. package/routes/movies/[id]/watch/+page.svelte +34 -0
  61. package/routes/movies/[id]/watch/+page.ts +18 -0
  62. package/routes/tsconfig.json +12 -0
  63. package/routes/tv/+page.svelte +22 -0
  64. package/routes/tv/+page.ts +12 -0
  65. package/routes/tv/[id]/+page.svelte +39 -0
  66. package/routes/tv/[id]/+page.ts +7 -0
  67. package/routes/tv/[id]/[season]/+page.svelte +43 -0
  68. package/routes/tv/[id]/[season]/+page.ts +11 -0
  69. package/routes/tv/[id]/[season]/[episode]/+page.svelte +46 -0
  70. package/routes/tv/[id]/[season]/[episode]/+page.ts +12 -0
  71. package/routes/tv/[id]/[season]/[episode]/watch/+page.svelte +46 -0
  72. package/routes/tv/[id]/[season]/[episode]/watch/+page.ts +22 -0
package/LICENSE.md ADDED
@@ -0,0 +1,157 @@
1
+ # GNU LESSER GENERAL PUBLIC LICENSE
2
+
3
+ Version 3, 29 June 2007
4
+
5
+ Copyright (C) 2007 Free Software Foundation, Inc.
6
+ <https://fsf.org/>
7
+
8
+ Everyone is permitted to copy and distribute verbatim copies of this
9
+ license document, but changing it is not allowed.
10
+
11
+ This version of the GNU Lesser General Public License incorporates the
12
+ terms and conditions of version 3 of the GNU General Public License,
13
+ supplemented by the additional permissions listed below.
14
+
15
+ ## 0. Additional Definitions.
16
+
17
+ As used herein, "this License" refers to version 3 of the GNU Lesser
18
+ General Public License, and the "GNU GPL" refers to version 3 of the
19
+ GNU General Public License.
20
+
21
+ "The Library" refers to a covered work governed by this License, other
22
+ than an Application or a Combined Work as defined below.
23
+
24
+ An "Application" is any work that makes use of an interface provided
25
+ by the Library, but which is not otherwise based on the Library.
26
+ Defining a subclass of a class defined by the Library is deemed a mode
27
+ of using an interface provided by the Library.
28
+
29
+ A "Combined Work" is a work produced by combining or linking an
30
+ Application with the Library. The particular version of the Library
31
+ with which the Combined Work was made is also called the "Linked
32
+ Version".
33
+
34
+ The "Minimal Corresponding Source" for a Combined Work means the
35
+ Corresponding Source for the Combined Work, excluding any source code
36
+ for portions of the Combined Work that, considered in isolation, are
37
+ based on the Application, and not on the Linked Version.
38
+
39
+ The "Corresponding Application Code" for a Combined Work means the
40
+ object code and/or source code for the Application, including any data
41
+ and utility programs needed for reproducing the Combined Work from the
42
+ Application, but excluding the System Libraries of the Combined Work.
43
+
44
+ ## 1. Exception to Section 3 of the GNU GPL.
45
+
46
+ You may convey a covered work under sections 3 and 4 of this License
47
+ without being bound by section 3 of the GNU GPL.
48
+
49
+ ## 2. Conveying Modified Versions.
50
+
51
+ If you modify a copy of the Library, and, in your modifications, a
52
+ facility refers to a function or data to be supplied by an Application
53
+ that uses the facility (other than as an argument passed when the
54
+ facility is invoked), then you may convey a copy of the modified
55
+ version:
56
+
57
+ - a) under this License, provided that you make a good faith effort
58
+ to ensure that, in the event an Application does not supply the
59
+ function or data, the facility still operates, and performs
60
+ whatever part of its purpose remains meaningful, or
61
+ - b) under the GNU GPL, with none of the additional permissions of
62
+ this License applicable to that copy.
63
+
64
+ ## 3. Object Code Incorporating Material from Library Header Files.
65
+
66
+ The object code form of an Application may incorporate material from a
67
+ header file that is part of the Library. You may convey such object
68
+ code under terms of your choice, provided that, if the incorporated
69
+ material is not limited to numerical parameters, data structure
70
+ layouts and accessors, or small macros, inline functions and templates
71
+ (ten or fewer lines in length), you do both of the following:
72
+
73
+ - a) Give prominent notice with each copy of the object code that
74
+ the Library is used in it and that the Library and its use are
75
+ covered by this License.
76
+ - b) Accompany the object code with a copy of the GNU GPL and this
77
+ license document.
78
+
79
+ ## 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that, taken
82
+ together, effectively do not restrict modification of the portions of
83
+ the Library contained in the Combined Work and reverse engineering for
84
+ debugging such modifications, if you also do each of the following:
85
+
86
+ - a) Give prominent notice with each copy of the Combined Work that
87
+ the Library is used in it and that the Library and its use are
88
+ covered by this License.
89
+ - b) Accompany the Combined Work with a copy of the GNU GPL and this
90
+ license document.
91
+ - c) For a Combined Work that displays copyright notices during
92
+ execution, include the copyright notice for the Library among
93
+ these notices, as well as a reference directing the user to the
94
+ copies of the GNU GPL and this license document.
95
+ - d) Do one of the following:
96
+ - 0) Convey the Minimal Corresponding Source under the terms of
97
+ this License, and the Corresponding Application Code in a form
98
+ suitable for, and under terms that permit, the user to
99
+ recombine or relink the Application with a modified version of
100
+ the Linked Version to produce a modified Combined Work, in the
101
+ manner specified by section 6 of the GNU GPL for conveying
102
+ Corresponding Source.
103
+ - 1) Use a suitable shared library mechanism for linking with
104
+ the Library. A suitable mechanism is one that (a) uses at run
105
+ time a copy of the Library already present on the user's
106
+ computer system, and (b) will operate properly with a modified
107
+ version of the Library that is interface-compatible with the
108
+ Linked Version.
109
+ - e) Provide Installation Information, but only if you would
110
+ otherwise be required to provide such information under section 6
111
+ of the GNU GPL, and only to the extent that such information is
112
+ necessary to install and execute a modified version of the
113
+ Combined Work produced by recombining or relinking the Application
114
+ with a modified version of the Linked Version. (If you use option
115
+ 4d0, the Installation Information must accompany the Minimal
116
+ Corresponding Source and Corresponding Application Code. If you
117
+ use option 4d1, you must provide the Installation Information in
118
+ the manner specified by section 6 of the GNU GPL for conveying
119
+ Corresponding Source.)
120
+
121
+ ## 5. Combined Libraries.
122
+
123
+ You may place library facilities that are a work based on the Library
124
+ side by side in a single library together with other library
125
+ facilities that are not Applications and are not covered by this
126
+ License, and convey such a combined library under terms of your
127
+ choice, if you do both of the following:
128
+
129
+ - a) Accompany the combined library with a copy of the same work
130
+ based on the Library, uncombined with any other library
131
+ facilities, conveyed under the terms of this License.
132
+ - b) Give prominent notice with the combined library that part of it
133
+ is a work based on the Library, and explaining where to find the
134
+ accompanying uncombined form of the same work.
135
+
136
+ ## 6. Revised Versions of the GNU Lesser General Public License.
137
+
138
+ The Free Software Foundation may publish revised and/or new versions
139
+ of the GNU Lesser General Public License from time to time. Such new
140
+ versions will be similar in spirit to the present version, but may
141
+ differ in detail to address new problems or concerns.
142
+
143
+ Each version is given a distinguishing version number. If the Library
144
+ as you received it specifies that a certain numbered version of the
145
+ GNU Lesser General Public License "or any later version" applies to
146
+ it, you have the option of following the terms and conditions either
147
+ of that published version or of any later version published by the
148
+ Free Software Foundation. If the Library as you received it does not
149
+ specify a version number of the GNU Lesser General Public License, you
150
+ may choose any version of the GNU Lesser General Public License ever
151
+ published by the Free Software Foundation.
152
+
153
+ If the Library as you received it specifies that a proxy can decide
154
+ whether future versions of the GNU Lesser General Public License shall
155
+ apply, that proxy's public statement of acceptance of any version is
156
+ permanent authorization for you to choose that version for the
157
+ Library.
package/db.json ADDED
@@ -0,0 +1,106 @@
1
+ {
2
+ "$schema": "../server/schemas/db.json",
3
+ "format": 1,
4
+ "versions": [
5
+ {
6
+ "delta": false,
7
+ "tables": {
8
+ "kino_movies": {
9
+ "columns": {
10
+ "id": { "type": "integer", "primary": true, "required": true },
11
+ "title": { "type": "text", "required": true },
12
+ "release_date": { "type": "date", "required": true },
13
+ "poster_path": { "type": "text" },
14
+ "adult": { "type": "boolean", "required": true },
15
+ "overview": { "type": "text", "required": true },
16
+ "backdrop_path": { "type": "text" }
17
+ }
18
+ },
19
+ "kino_movie_uploads": {
20
+ "columns": {
21
+ "id": { "type": "integer", "primary": true, "required": true },
22
+ "uploadedAt": { "type": "timestamptz", "required": true, "default": "now()" },
23
+ "hash": { "type": "bytea" },
24
+ "name": { "type": "text" },
25
+ "size": { "type": "bigint", "required": true },
26
+ "type": { "type": "text", "required": true }
27
+ }
28
+ },
29
+ "kino_tv": {
30
+ "columns": {
31
+ "id": { "type": "integer", "primary": true, "unique": true, "required": true },
32
+ "name": { "type": "text", "required": true },
33
+ "first_air_date": { "type": "date", "required": true },
34
+ "poster_path": { "type": "text" },
35
+ "adult": { "type": "boolean", "required": true },
36
+ "overview": { "type": "text", "required": true },
37
+ "backdrop_path": { "type": "text" }
38
+ }
39
+ },
40
+ "kino_seasons": {
41
+ "columns": {
42
+ "id": { "type": "integer", "primary": true, "required": true, "references": "kino_tv.id", "onDelete": "cascade" },
43
+ "season_number": { "type": "integer", "primary": true, "required": true },
44
+ "name": { "type": "text", "required": true },
45
+ "overview": { "type": "text", "required": true },
46
+ "air_date": { "type": "date", "required": true },
47
+ "poster_path": { "type": "text" }
48
+ }
49
+ },
50
+ "kino_episodes": {
51
+ "columns": {
52
+ "id": { "type": "integer", "primary": true, "required": true, "references": "kino_tv.id", "onDelete": "cascade" },
53
+ "season_number": { "type": "integer", "primary": true, "required": true },
54
+ "episode_number": { "type": "integer", "primary": true, "required": true },
55
+ "name": { "type": "text", "required": true },
56
+ "air_date": { "type": "date", "required": true },
57
+ "still_path": { "type": "text" }
58
+ }
59
+ },
60
+ "kino_tv_uploads": {
61
+ "columns": {
62
+ "id": { "type": "integer", "primary": true, "required": true },
63
+ "season_number": { "type": "integer", "primary": true, "required": true },
64
+ "episode_number": { "type": "integer", "primary": true, "required": true },
65
+ "uploadedAt": { "type": "timestamptz", "required": true, "default": "now()" },
66
+ "hash": { "type": "bytea" },
67
+ "name": { "type": "text" },
68
+ "size": { "type": "bigint", "required": true },
69
+ "type": { "type": "text", "required": true }
70
+ }
71
+ }
72
+ },
73
+ "indexes": {}
74
+ },
75
+ {
76
+ "delta": true,
77
+ "add_tables": {
78
+ "kino_movie_views": {
79
+ "columns": {
80
+ "userId": { "type": "uuid", "primary": true, "required": true, "references": "users.id", "onDelete": "cascade" },
81
+ "id": { "type": "integer", "primary": true, "required": true },
82
+ "viewedAt": { "type": "timestamptz", "required": true, "default": "now()" },
83
+ "position": { "type": "double precision", "required": true, "default": "0" },
84
+ "duration": { "type": "double precision" }
85
+ }
86
+ },
87
+ "kino_tv_views": {
88
+ "columns": {
89
+ "userId": { "type": "uuid", "primary": true, "required": true, "references": "users.id", "onDelete": "cascade" },
90
+ "id": { "type": "integer", "primary": true, "required": true },
91
+ "season_number": { "type": "integer", "primary": true, "required": true },
92
+ "episode_number": { "type": "integer", "primary": true, "required": true },
93
+ "viewedAt": { "type": "timestamptz", "required": true, "default": "now()" },
94
+ "position": { "type": "double precision", "required": true, "default": "0" },
95
+ "duration": { "type": "double precision" }
96
+ }
97
+ }
98
+ },
99
+ "add_indexes": {
100
+ "kino_movie_views_userId": { "on": "kino_movie_views", "columns": ["userId"] },
101
+ "kino_tv_views_userId": { "on": "kino_tv_views", "columns": ["userId"] }
102
+ }
103
+ }
104
+ ],
105
+ "wipe": []
106
+ }
@@ -0,0 +1,49 @@
1
+ import { type ProgressHandler } from '@axium/client/uploads';
2
+ import type * as kt from 'kinotool';
3
+ import type { ImageSize, ImageType, KinoEpisode, KinoMovie, KinoSearchResults, KinoSeason, KinoView, KinoViewInit } from '../common.js';
4
+ import { KinoUpload } from '../common.js';
5
+ /**
6
+ * The URL for a TMDB image path, e.g. `poster_path`.
7
+ * Query values are JSON-encoded since the server parses search parameters as JSON.
8
+ */
9
+ export declare function imageURL(path: string | null | undefined, type: ImageType, size?: ImageSize): string | undefined;
10
+ /**
11
+ * The URL a movie's file is served from.
12
+ * `download` asks for the original upload as an attachment rather than the playback copy.
13
+ */
14
+ export declare function movieDataURL(id: number, download?: boolean): string;
15
+ export declare function episodeDataURL(id: number, season: number, episode: number, download?: boolean): string;
16
+ export declare function searchMedia(query: string, type?: 'movie' | 'tv'): Promise<KinoSearchResults>;
17
+ /** All movies that have been uploaded */
18
+ export declare function getUploadedMovies(): Promise<KinoMovie[]>;
19
+ export declare function getMovie(id: number): Promise<KinoMovie>;
20
+ /** All TV shows with at least one uploaded episode */
21
+ export declare function getUploadedShows(): Promise<kt.Tv[]>;
22
+ export declare function getTv(id: number): Promise<kt.Tv>;
23
+ export declare function getSeason(id: number, season: number): Promise<KinoSeason>;
24
+ export declare function getEpisode(id: number, season: number, episode: number): Promise<KinoEpisode>;
25
+ /** Recently watched items, most recent first */
26
+ export declare function getViews(): Promise<KinoView[]>;
27
+ /** Record that something was watched, and how far through it the viewer is */
28
+ export declare function recordView(init: KinoViewInit): Promise<KinoView>;
29
+ /**
30
+ * Record a view while the page is going away.
31
+ *
32
+ * `keepalive` lets the request outlive the document; a normal fetch is cancelled on unload.
33
+ * `navigator.sendBeacon` can't be used here — it is POST-only and can't set the Authorization header.
34
+ */
35
+ export declare function recordViewClosing(init: KinoViewInit): void;
36
+ /** Delete a movie's upload and its files. Administrators only. */
37
+ export declare function deleteMovieUpload(id: number): Promise<KinoUpload>;
38
+ /** Delete an episode's upload and its files. Administrators only. */
39
+ export declare function deleteEpisodeUpload(id: number, season: number, episode: number): Promise<KinoUpload>;
40
+ export interface UploadOptions {
41
+ onProgress?: ProgressHandler;
42
+ signal?: AbortSignal;
43
+ }
44
+ /**
45
+ * Upload a movie file.
46
+ * When `id` is omitted the server resolves the movie from the file name.
47
+ */
48
+ export declare function uploadMovie(file: File, id?: number, options?: UploadOptions): Promise<KinoUpload>;
49
+ export declare function uploadEpisode(file: File, id: number, season: number, episode: number, options?: UploadOptions): Promise<KinoUpload>;
@@ -0,0 +1,136 @@
1
+ import { fetchAPI, origin, prefix, token } from '@axium/client/requests';
2
+ import { uploadChunked } from '@axium/client/uploads';
3
+ import { prettifyError } from 'zod';
4
+ import { KinoUpload } from '../common.js';
5
+ /** Build an absolute URL for one of kino's `/raw` endpoints */
6
+ function raw(suffix) {
7
+ if (prefix[0] == '/')
8
+ return new URL('/raw/kino/' + suffix, origin);
9
+ const url = new URL(prefix);
10
+ url.pathname = '/raw/kino/' + suffix;
11
+ return url;
12
+ }
13
+ /**
14
+ * The URL for a TMDB image path, e.g. `poster_path`.
15
+ * Query values are JSON-encoded since the server parses search parameters as JSON.
16
+ */
17
+ export function imageURL(path, type, size) {
18
+ if (!path)
19
+ return undefined;
20
+ // TMDB paths already start with a slash
21
+ const url = new URL('/raw/image' + path, origin);
22
+ url.searchParams.set('type', JSON.stringify(type));
23
+ if (size)
24
+ url.searchParams.set('size', JSON.stringify(size));
25
+ return url.href;
26
+ }
27
+ /**
28
+ * The URL a movie's file is served from.
29
+ * `download` asks for the original upload as an attachment rather than the playback copy.
30
+ */
31
+ export function movieDataURL(id, download = false) {
32
+ const url = raw('movies/' + id);
33
+ if (download)
34
+ url.searchParams.set('download', '');
35
+ return url.href;
36
+ }
37
+ export function episodeDataURL(id, season, episode, download = false) {
38
+ const url = raw(`tv/${id}/${season}/${episode}`);
39
+ if (download)
40
+ url.searchParams.set('download', '');
41
+ return url.href;
42
+ }
43
+ export async function searchMedia(query, type) {
44
+ return await fetchAPI('POST', 'kino/search', { query, type });
45
+ }
46
+ /** All movies that have been uploaded */
47
+ export async function getUploadedMovies() {
48
+ return await fetchAPI('GET', 'kino/movies');
49
+ }
50
+ export async function getMovie(id) {
51
+ return await fetchAPI('GET', 'kino/movies/:id', undefined, String(id));
52
+ }
53
+ /** All TV shows with at least one uploaded episode */
54
+ export async function getUploadedShows() {
55
+ return await fetchAPI('GET', 'kino/tv');
56
+ }
57
+ export async function getTv(id) {
58
+ return await fetchAPI('GET', 'kino/tv/:id', undefined, String(id));
59
+ }
60
+ export async function getSeason(id, season) {
61
+ return await fetchAPI('GET', 'kino/tv/:id/season/:season', undefined, String(id), String(season));
62
+ }
63
+ export async function getEpisode(id, season, episode) {
64
+ return await fetchAPI('GET', 'kino/tv/:id/season/:season/episode/:episode', undefined, String(id), String(season), String(episode));
65
+ }
66
+ /** Recently watched items, most recent first */
67
+ export async function getViews() {
68
+ return await fetchAPI('GET', 'kino/views');
69
+ }
70
+ /** Record that something was watched, and how far through it the viewer is */
71
+ export async function recordView(init) {
72
+ return await fetchAPI('PUT', 'kino/views', init);
73
+ }
74
+ /**
75
+ * Record a view while the page is going away.
76
+ *
77
+ * `keepalive` lets the request outlive the document; a normal fetch is cancelled on unload.
78
+ * `navigator.sendBeacon` can't be used here — it is POST-only and can't set the Authorization header.
79
+ */
80
+ export function recordViewClosing(init) {
81
+ const headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
82
+ if (token)
83
+ headers.Authorization = 'Bearer ' + token;
84
+ // Nothing can act on a failure at this point, so errors are dropped
85
+ void fetch(prefix + 'kino/views', {
86
+ method: 'PUT',
87
+ headers,
88
+ body: JSON.stringify(init),
89
+ keepalive: true,
90
+ }).catch(() => { });
91
+ }
92
+ /** Delete a movie's upload and its files. Administrators only. */
93
+ export async function deleteMovieUpload(id) {
94
+ return await fetchAPI('DELETE', 'kino/movies/:id', undefined, String(id));
95
+ }
96
+ /** Delete an episode's upload and its files. Administrators only. */
97
+ export async function deleteEpisodeUpload(id, season, episode) {
98
+ return await fetchAPI('DELETE', 'kino/tv/:id/season/:season/episode/:episode', undefined, String(id), String(season), String(episode));
99
+ }
100
+ async function _upload(endpoint, token, maxTransferSize, file, options) {
101
+ const result = await uploadChunked({
102
+ endpoint,
103
+ token,
104
+ stream: file.stream(),
105
+ itemSize: file.size,
106
+ maxTransferSize,
107
+ onProgress: options.onProgress,
108
+ signal: options.signal,
109
+ });
110
+ try {
111
+ return KinoUpload.parse(result);
112
+ }
113
+ catch (e) {
114
+ throw prettifyError(e);
115
+ }
116
+ }
117
+ /**
118
+ * Upload a movie file.
119
+ * When `id` is omitted the server resolves the movie from the file name.
120
+ */
121
+ export async function uploadMovie(file, id, options = {}) {
122
+ options.onProgress?.(0, file.size);
123
+ const { max_transfer_size, token } = await fetchAPI('PUT', 'kino/movies/upload', {
124
+ id,
125
+ name: file.name,
126
+ size: file.size,
127
+ type: file.type,
128
+ hash: null,
129
+ });
130
+ return await _upload(raw('movies/upload'), token, max_transfer_size, file, options);
131
+ }
132
+ export async function uploadEpisode(file, id, season, episode, options = {}) {
133
+ options.onProgress?.(0, file.size);
134
+ const { max_transfer_size, token } = await fetchAPI('PUT', 'kino/tv/:id/upload', { season, episode, name: file.name, size: file.size, type: file.type, hash: null }, String(id));
135
+ return await _upload(raw(`tv/${id}/upload`), token, max_transfer_size, file, options);
136
+ }
@@ -0,0 +1,3 @@
1
+ import type { KinoUpload } from '../common.js';
2
+ export declare function uploadMovieFile(file: File, id: number): Promise<KinoUpload | undefined>;
3
+ export declare function uploadEpisodeFile(file: File, id: number, season: number, episode: number): Promise<KinoUpload | undefined>;
@@ -0,0 +1,33 @@
1
+ import { text } from '@axium/client';
2
+ import { setProgressCancel, toast } from '@axium/client/toast';
3
+ import * as io from 'ioium';
4
+ import { uploadEpisode, uploadMovie } from './api.js';
5
+ /**
6
+ * Report the outcome of an upload as a toast, reporting cancellation as info rather than an error.
7
+ * Returns the upload when it succeeded so callers can update their state.
8
+ */
9
+ async function toastUpload(upload, name) {
10
+ const controller = new AbortController();
11
+ setProgressCancel(() => controller.abort());
12
+ io.start(text('kino.uploading', { name }));
13
+ try {
14
+ const result = await upload(controller.signal);
15
+ await toast('success', text('kino.upload_success'));
16
+ return result;
17
+ }
18
+ catch (e) {
19
+ if (e instanceof DOMException && e.name == 'AbortError')
20
+ await toast('info', text('kino.upload_cancelled'));
21
+ else
22
+ await toast('error', e);
23
+ }
24
+ finally {
25
+ io.done(true);
26
+ }
27
+ }
28
+ export function uploadMovieFile(file, id) {
29
+ return toastUpload(signal => uploadMovie(file, id, { signal, onProgress: (uploaded, total) => io.progress(uploaded, total) }), file.name);
30
+ }
31
+ export function uploadEpisodeFile(file, id, season, episode) {
32
+ return toastUpload(signal => uploadEpisode(file, id, season, episode, { signal, onProgress: (uploaded, total) => io.progress(uploaded, total) }), file.name);
33
+ }
@@ -0,0 +1 @@
1
+ export * from './api.js';
@@ -0,0 +1 @@
1
+ export * from './api.js';
@@ -0,0 +1,8 @@
1
+ import en from '../../locales/en.json';
2
+ import '../common.js';
3
+ type en = typeof en;
4
+ declare module '@axium/client/locales' {
5
+ interface Locale extends en {
6
+ }
7
+ }
8
+ export {};
@@ -0,0 +1,4 @@
1
+ import { extendLocale } from '@axium/client';
2
+ import en from '../../locales/en.json' with { type: 'json' };
3
+ import '../common.js';
4
+ extendLocale('en', en);