diff --git a/dist/immich.js b/dist/immich.js index 7c4434f..edaa202 100644 --- a/dist/immich.js +++ b/dist/immich.js @@ -1,35 +1,59 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); +const types_1 = require("./types"); class Immich { - request(endpoint_1) { - return tslib_1.__awaiter(this, arguments, void 0, function* (endpoint, json = true) { + request(endpoint) { + return tslib_1.__awaiter(this, void 0, void 0, function* () { const res = yield fetch(process.env.IMMICH_URL + '/api' + endpoint, { headers: { 'x-api-key': process.env.API_KEY || '' } }); - if (json) { - return res.json(); - } - else { - return res; + if (res.status === 200) { + const contentType = res.headers.get('Content-Type') || ''; + if (contentType.includes('application/json')) { + return res.json(); + } + else { + return res; + } } }); } getShareByKey(key) { return tslib_1.__awaiter(this, void 0, void 0, function* () { - const links = yield this.request('/shared-links'); - return links.find(x => x.key === key); + const res = ((yield this.request('/shared-links')) || []); + return res === null || res === void 0 ? void 0 : res.find(x => x.key === key); }); } - getImage(id_1) { - return tslib_1.__awaiter(this, arguments, void 0, function* (id, size = 'original') { - size = size === 'thumbnail' ? 'thumbnail' : 'original'; - return this.request('/assets/' + id + '/' + size, false); + getAssetBuffer(asset, size) { + return tslib_1.__awaiter(this, void 0, void 0, function* () { + switch (asset.type) { + case types_1.AssetType.image: + size = size === types_1.ImageSize.thumbnail ? types_1.ImageSize.thumbnail : types_1.ImageSize.original; + return this.request('/assets/' + asset.id + '/' + size); + case types_1.AssetType.video: + return this.request('/assets/' + asset.id + '/video/playback'); + } }); } + getContentType(asset) { + return tslib_1.__awaiter(this, void 0, void 0, function* () { + const assetBuffer = yield this.getAssetBuffer(asset); + return assetBuffer.headers.get('Content-Type'); + }); + } + photoUrl(id, size) { + return `${process.env.SERVER_URL}/photo/${id}` + (size ? `?size=${size}` : ''); + } + videoUrl(id) { + return `${process.env.SERVER_URL}/video/${id}`; + } + isId(id) { + return !!id.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]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8gJ3RodW1ibmFpbCcgOiAnb3JpZ2luYWwnXG4gICAgcmV0dXJuIHRoaXMucmVxdWVzdCgnL2Fzc2V0cy8nICsgaWQgKyAnLycgKyBzaXplLCBmYWxzZSlcbiAgfVxufVxuXG5jb25zdCBhcGkgPSBuZXcgSW1taWNoKClcblxuZXhwb3J0IGRlZmF1bHQgYXBpXG4iXX0= \ No newline at end of file +const immich = new Immich(); +exports.default = immich; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1taWNoLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ltbWljaC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxtQ0FBaUU7QUFFakUsTUFBTSxNQUFNO0lBQ0osT0FBTyxDQUFFLFFBQWdCOztZQUM3QixNQUFNLEdBQUcsR0FBRyxNQUFNLEtBQUssQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLFVBQVUsR0FBRyxNQUFNLEdBQUcsUUFBUSxFQUFFO2dCQUNsRSxPQUFPLEVBQUU7b0JBQ1AsV0FBVyxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUMsT0FBTyxJQUFJLEVBQUU7aUJBQ3ZDO2FBQ0YsQ0FBQyxDQUFBO1lBQ0YsSUFBSSxHQUFHLENBQUMsTUFBTSxLQUFLLEdBQUcsRUFBRSxDQUFDO2dCQUN2QixNQUFNLFdBQVcsR0FBRyxHQUFHLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxjQUFjLENBQUMsSUFBSSxFQUFFLENBQUE7Z0JBQ3pELElBQUksV0FBVyxDQUFDLFFBQVEsQ0FBQyxrQkFBa0IsQ0FBQyxFQUFFLENBQUM7b0JBQzdDLE9BQU8sR0FBRyxDQUFDLElBQUksRUFBRSxDQUFBO2dCQUNuQixDQUFDO3FCQUFNLENBQUM7b0JBQ04sT0FBTyxHQUFHLENBQUE7Z0JBQ1osQ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0QnVmZmVyID0gYXdhaXQgdGhpcy5nZXRBc3NldEJ1ZmZlcihhc3NldClcbiAgICByZXR1cm4gYXNzZXRCdWZmZXIuaGVhZGVycy5nZXQoJ0NvbnRlbnQtVHlwZScpXG4gIH1cblxuICBwaG90b1VybCAoaWQ6IHN0cmluZywgc2l6ZT86IEltYWdlU2l6ZSkge1xuICAgIHJldHVybiBgJHtwcm9jZXNzLmVudi5TRVJWRVJfVVJMfS9waG90by8ke2lkfWAgKyAoc2l6ZSA/IGA/c2l6ZT0ke3NpemV9YCA6ICcnKVxuICB9XG5cbiAgdmlkZW9VcmwgKGlkOiBzdHJpbmcpIHtcbiAgICByZXR1cm4gYCR7cHJvY2Vzcy5lbnYuU0VSVkVSX1VSTH0vdmlkZW8vJHtpZH1gXG4gIH1cblxuICBpc0lkIChpZDogc3RyaW5nKSB7XG4gICAgcmV0dXJuICEhaWQubWF0Y2goL15bMC05YS1mXXs4fS1bMC05YS1mXXs0fS1bMC05YS1mXXs0fS1bMC05YS1mXXs0fS1bMC05YS1mXXsxMn0kLylcbiAgfVxufVxuXG5jb25zdCBpbW1pY2ggPSBuZXcgSW1taWNoKClcblxuZXhwb3J0IGRlZmF1bHQgaW1taWNoXG4iXX0= \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 4f5dd14..08ae955 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3,35 +3,64 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const express_1 = tslib_1.__importDefault(require("express")); const immich_1 = tslib_1.__importDefault(require("./immich")); +const render_1 = tslib_1.__importDefault(require("./render")); const dayjs_1 = tslib_1.__importDefault(require("dayjs")); -const app = (0, express_1.default)(); +const types_1 = require("./types"); require('dotenv').config(); -app.get('/share/:key', (req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { +const app = (0, express_1.default)(); +app.set('view engine', 'ejs'); +app.use(express_1.default.static('public')); +const getSize = (req) => { var _a; + return ((_a = req === null || req === void 0 ? void 0 : req.query) === null || _a === void 0 ? void 0 : _a.size) === 'thumbnail' ? types_1.ImageSize.thumbnail : types_1.ImageSize.original; +}; +app.get('/share/:key', (req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { if (req.params.key.match(/[^\w-]/)) { // Invalid characters in the incoming URL res.status(404).send(); } else { const share = yield immich_1.default.getShareByKey(req.params.key); - if (((_a = share === null || share === void 0 ? void 0 : share.assets) === null || _a === void 0 ? void 0 : _a.length) === 1) { + if (!share || !share.assets.length) { + res.status(404).send(); + } + else if (share.assets.length === 1) { // This is an individual item (not a gallery) - // Return the full-size image. - const size = req.query.size === 'thumbnail' ? 'thumbnail' : 'original'; - const image = yield immich_1.default.getImage(share.assets[0].id, size); - for (const header of ['content-type', 'content-length']) { - res.set(header, image.headers[header]); + const asset = share.assets[0]; + if (asset.type === types_1.AssetType.image) { + // Output the image directly + yield render_1.default.assetBuffer(res, share.assets[0], getSize(req)); + } + else if (asset.type === types_1.AssetType.video) { + // Show the video as a web player + yield render_1.default.gallery(res, share.assets, 1); } - const data = yield image.arrayBuffer(); - console.log((0, dayjs_1.default)().format() + ' Serving image ' + share.assets[0].id); - res.send(Buffer.from(data)); } else { - res.send(); + // Multiple images - render as a gallery + yield render_1.default.gallery(res, share.assets); } } })); +// Output the buffer data for an photo or video +app.get('/:type(photo|video)/:id', (req, res) => { + if (!immich_1.default.isId(req.params.id)) { + // Invalid characters in the incoming URL + res.status(404).send(); + return; + } + const asset = { + id: req.params.id, + type: req.params.type === 'video' ? types_1.AssetType.video : types_1.AssetType.image + }; + switch (req.params.type) { + case 'photo': + case 'video': + render_1.default.assetBuffer(res, asset, getSize(req)).then(); + break; + } +}); app.listen(3000, () => { console.log((0, dayjs_1.default)().format() + ' Server started'); }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXM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9yIGFuIHBob3RvIG9yIHZpZGVvXG5hcHAuZ2V0KCcvOnR5cGUocGhvdG98dmlkZW8pLzppZCcsIChyZXEsIHJlcykgPT4ge1xuICBpZiAoIWltbWljaC5pc0lkKHJlcS5wYXJhbXMuaWQpKSB7XG4gICAgLy8gSW52YWxpZCBjaGFyYWN0ZXJzIGluIHRoZSBpbmNvbWluZyBVUkxcbiAgICByZXMuc3RhdHVzKDQwNCkuc2VuZCgpXG4gICAgcmV0dXJuXG4gIH1cbiAgY29uc3QgYXNzZXQgPSB7XG4gICAgaWQ6IHJlcS5wYXJhbXMuaWQsXG4gICAgdHlwZTogcmVxLnBhcmFtcy50eXBlID09PSAndmlkZW8nID8gQXNzZXRUeXBlLnZpZGVvIDogQXNzZXRUeXBlLmltYWdlXG4gIH1cbiAgc3dpdGNoIChyZXEucGFyYW1zLnR5cGUpIHtcbiAgICBjYXNlICdwaG90byc6XG4gICAgY2FzZSAndmlkZW8nOlxuICAgICAgcmVuZGVyLmFzc2V0QnVmZmVyKHJlcywgYXNzZXQsIGdldFNpemUocmVxKSkudGhlbigpXG4gICAgICBicmVha1xuICB9XG59KVxuXG5hcHAubGlzdGVuKDMwMDAsICgpID0+IHtcbiAgY29uc29sZS5sb2coZGF5anMoKS5mb3JtYXQoKSArICcgU2VydmVyIHN0YXJ0ZWQnKVxufSlcbiJdfQ== \ No newline at end of file diff --git a/dist/render.js b/dist/render.js new file mode 100644 index 0000000..12cac94 --- /dev/null +++ b/dist/render.js @@ -0,0 +1,58 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +const immich_1 = tslib_1.__importDefault(require("./immich")); +const types_1 = require("./types"); +const dayjs_1 = tslib_1.__importDefault(require("dayjs")); +class Render { + assetBuffer(res, asset, size) { + return tslib_1.__awaiter(this, void 0, void 0, function* () { + const data = yield immich_1.default.getAssetBuffer(asset, size); + if (data) { + for (const header of ['content-type', 'content-length']) { + res.set(header, data.headers[header]); + } + console.log(`${(0, dayjs_1.default)().format()} Serving asset ${asset.id}`); + res.send(Buffer.from(yield data.arrayBuffer())); + } + else { + res.status(404).send(); + } + }); + } + gallery(res, assets, openItem) { + return tslib_1.__awaiter(this, void 0, void 0, function* () { + const items = []; + for (const asset of assets) { + let video; + if (asset.type === types_1.AssetType.video) { + // Populate the data-video property + video = JSON.stringify({ + source: [ + { + src: immich_1.default.videoUrl(asset.id), + type: yield immich_1.default.getContentType(asset) + } + ], + attributes: { + preload: false, + controls: true + } + }); + } + items.push({ + originalUrl: immich_1.default.photoUrl(asset.id), + thumbnailUrl: immich_1.default.photoUrl(asset.id, types_1.ImageSize.thumbnail), + video + }); + } + res.render('gallery', { + items, + openItem + }); + }); + } +} +const render = new Render(); +exports.default = render; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVuZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3JlbmRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSw4REFBNkI7QUFFN0IsbUNBQXFEO0FBQ3JELDBEQUF5QjtBQUV6QixNQUFNLE1BQU07SUFDSixXQUFXLENBQUUsR0FBYSxFQUFFLEtBQVksRUFBRSxJQUFnQjs7WUFDOUQsTUFBTSxJQUFJLEdBQUcsTUFBTSxnQkFBTSxDQUFDLGNBQWMsQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLENBQUE7WUFDckQsSUFBSSxJQUFJLEVBQUUsQ0FBQztnQkFDVCxLQUFLLE1BQU0sTUFBTSxJQUFJLENBQUMsY0FBYyxFQUFFLGdCQUFnQixDQUFDLEVBQUUsQ0FBQztvQkFDeEQsR0FBRyxDQUFDLEdBQUcsQ0FBQyxNQUFNLEVBQUUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFBO2dCQUN2QyxDQUFDO2dCQUNELE9BQU8sQ0FBQyxHQUFHLEN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90b1VybChhc3NldC5pZCwgSW1hZ2VTaXplLnRodW1ibmFpbCksXG4gICAgICAgIHZpZGVvXG4gICAgICB9KVxuICAgIH1cbiAgICByZXMucmVuZGVyKCdnYWxsZXJ5Jywge1xuICAgICAgaXRlbXMsXG4gICAgICBvcGVuSXRlbVxuICAgIH0pXG4gIH1cbn1cblxuY29uc3QgcmVuZGVyID0gbmV3IFJlbmRlcigpXG5cbmV4cG9ydCBkZWZhdWx0IHJlbmRlclxuIl19 \ No newline at end of file diff --git a/dist/types.js b/dist/types.js index 29423b6..a27ede2 100644 --- a/dist/types.js +++ b/dist/types.js @@ -1,3 +1,14 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBpbnRlcmZhY2UgU2hhcmVkTGlua0Fzc2V0IHtcbiAgaWQ6IHN0cmluZztcbn1cblxuZXhwb3J0IGludGVyZmFjZSBTaGFyZWRMaW5rIHtcbiAga2V5OiBzdHJpbmc7XG4gIGFzc2V0czogU2hhcmVkTGlua0Fzc2V0W11cbn1cbiJdfQ== \ No newline at end of file +exports.ImageSize = exports.AssetType = void 0; +var AssetType; +(function (AssetType) { + AssetType["image"] = "IMAGE"; + AssetType["video"] = "VIDEO"; +})(AssetType || (exports.AssetType = AssetType = {})); +var ImageSize; +(function (ImageSize) { + ImageSize["thumbnail"] = "thumbnail"; + ImageSize["original"] = "original"; +})(ImageSize || (exports.ImageSize = ImageSize = {})); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsSUFBWSxTQUdYO0FBSEQsV0FBWSxTQUFTO0lBQ25CLDRCQUFlLENBQUE7SUFDZiw0QkFBZSxDQUFBO0FBQ2pCLENBQUMsRUFIVyxTQUFTLHlCQUFULFNBQVMsUUFHcEI7QUFZRCxJQUFZLFNBR1g7QUFIRCxXQUFZLFNBQVM7SUFDbkIsb0NBQXVCLENBQUE7SUFDdkIsa0NBQXFCLENBQUE7QUFDdkIsQ0FBQyxFQUhXLFNBQVMseUJBQVQsU0FBUyxRQUdwQiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBlbnVtIEFzc2V0VHlwZSB7XG4gIGltYWdlID0gJ0lNQUdFJyxcbiAgdmlkZW8gPSAnVklERU8nXG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgQXNzZXQge1xuICBpZDogc3RyaW5nO1xuICB0eXBlOiBBc3NldFR5cGU7XG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgU2hhcmVkTGluayB7XG4gIGtleTogc3RyaW5nO1xuICBhc3NldHM6IEFzc2V0W11cbn1cblxuZXhwb3J0IGVudW0gSW1hZ2VTaXplIHtcbiAgdGh1bWJuYWlsID0gJ3RodW1ibmFpbCcsXG4gIG9yaWdpbmFsID0gJ29yaWdpbmFsJ1xufVxuIl19 \ No newline at end of file