Merge branch 'main' of github.com:koush/scrypted

This commit is contained in:
Koushik Dutta
2024-01-13 16:01:37 -08:00
4 changed files with 5 additions and 29 deletions

View File

@@ -25,13 +25,13 @@
"linkfs": "^2.1.0",
"lodash": "^4.17.21",
"memfs": "^4.6.0",
"mime": "^4.0.1",
"nan": "^2.18.0",
"node-dijkstra": "^2.5.0",
"node-forge": "^1.3.1",
"node-gyp": "^10.0.1",
"router": "^1.3.8",
"semver": "^7.5.4",
"send": "^0.18.0",
"sharp": "^0.33.2",
"source-map-support": "^0.5.21",
"tar": "^6.2.0",
@@ -52,7 +52,6 @@
"@types/http-auth": "^4.1.4",
"@types/ip": "^1.1.3",
"@types/lodash": "^4.14.202",
"@types/mime": "^3.0.4",
"@types/node-dijkstra": "^2.5.6",
"@types/node-forge": "^1.3.11",
"@types/pem": "^1.14.4",
@@ -2490,20 +2489,6 @@
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/mime/-/mime-4.0.1.tgz",
"integrity": "sha512-5lZ5tyrIfliMXzFtkYyekWbtRXObT9OWa8IwQ5uxTBDHucNNwniRqo0yInflj+iYi5CBa6qxadGzGarDfuEOxA==",
"funding": [
"https://github.com/sponsors/broofa"
],
"bin": {
"mime": "bin/cli.js"
},
"engines": {
"node": ">=16"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",

View File

@@ -19,13 +19,13 @@
"linkfs": "^2.1.0",
"lodash": "^4.17.21",
"memfs": "^4.6.0",
"mime": "^3.0.0",
"nan": "^2.18.0",
"node-dijkstra": "^2.5.0",
"node-forge": "^1.3.1",
"node-gyp": "^10.0.1",
"router": "^1.3.8",
"semver": "^7.5.4",
"send": "^0.18.0",
"sharp": "^0.33.2",
"source-map-support": "^0.5.21",
"tar": "^6.2.0",
@@ -43,7 +43,6 @@
"@types/http-auth": "^4.1.4",
"@types/ip": "^1.1.3",
"@types/lodash": "^4.14.202",
"@types/mime": "^3.0.4",
"@types/node-dijkstra": "^2.5.6",
"@types/node-forge": "^1.3.11",
"@types/pem": "^1.14.4",

View File

@@ -5,7 +5,6 @@ import net from 'net';
import { join as pathJoin } from 'path';
import { RpcPeer } from "./rpc";
const mime = require('mime/lite');
export class HttpResponseImpl implements HttpResponse {
constructor(public res: Response, public unzippedDir: string, public filesPath: string) {
}
@@ -49,13 +48,6 @@ export class HttpResponseImpl implements HttpResponse {
this.res.status(options.code);
this.#setHeaders(options);
if (!this.res.getHeader('Content-Type')) {
const type = mime.getType(path);
if (type) {
this.res.contentType(mime.getExtension(type));
}
}
let filePath = pathJoin(this.unzippedDir, 'fs', path);
if (!fs.existsSync(filePath)) {
filePath = pathJoin(this.filesPath, path);

View File

@@ -2,13 +2,13 @@ import { BufferConverter, DeviceManager, FFmpegInput, MediaManager, MediaObject
import pathToFfmpeg from 'ffmpeg-static';
import fs from 'fs';
import https from 'https';
import mimeType from 'mime';
import Graph from 'node-dijkstra';
import os from 'os';
import path from 'path';
import MimeType from 'whatwg-mimetype';
import { MediaObject } from "./mediaobject";
import { MediaObjectRemote } from "./plugin-api";
import send from 'send';
function typeMatches(target: string, candidate: string): boolean {
// candidate will accept anything
@@ -78,7 +78,7 @@ export abstract class MediaManagerBase implements MediaManager {
}
const ab = await fs.promises.readFile(filename);
const mt = mimeType.getType(data.toString());
const mt = send.mime.lookup(filename);
const mo = this.createMediaObject(ab, mt);
return mo;
}
@@ -231,7 +231,7 @@ export abstract class MediaManagerBase implements MediaManager {
ensureMediaObjectRemote(mediaObject: string | MediaObjectInterface): MediaObjectRemote {
if (typeof mediaObject === 'string') {
const mime = mimeType.getType(mediaObject);
const mime = send.mime.lookup(mediaObject);
return this.createMediaObjectRemote(mediaObject, mime);
}
return mediaObject as MediaObjectRemote;