1.10.1
This commit is contained in:
parent
604692ca2a
commit
bd30f3ec85
9 changed files with 121 additions and 66 deletions
|
@ -58,7 +58,7 @@ Enabled at `/upload`. Requires authentication with key. `expire` key specifies d
|
||||||
### Using Docker
|
### Using Docker
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -d -p "3000:3000" -e EBPORT=3000 -e EBPASS=changeme -e EBAPI_KEY=changeme ghcr.io/waveringana/embedder:1.9.2
|
docker run -d -p "3000:3000" -e EBPORT=3000 -e EBPASS=changeme -e EBAPI_KEY=changeme ghcr.io/waveringana/embedder:1.10.1
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker Compose
|
### Docker Compose
|
||||||
|
@ -76,7 +76,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ./db:/var/db
|
- ./db:/var/db
|
||||||
- ./uploads:/uploads
|
- ./uploads:/uploads
|
||||||
image: ghcr.io/waveringana/embedder:1.9.2
|
image: ghcr.io/waveringana/embedder:1.10.1
|
||||||
```
|
```
|
||||||
|
|
||||||
## 📜 License
|
## 📜 License
|
||||||
|
|
|
@ -123,7 +123,7 @@ export const ffmpegDownscale = (
|
||||||
path: string,
|
path: string,
|
||||||
filename: string,
|
filename: string,
|
||||||
extension: string,
|
extension: string,
|
||||||
) => {
|
): Promise<void> => {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
const outputOptions = [
|
const outputOptions = [
|
||||||
"-vf",
|
"-vf",
|
||||||
|
@ -144,7 +144,10 @@ export const ffmpegDownscale = (
|
||||||
.outputOptions(outputOptions)
|
.outputOptions(outputOptions)
|
||||||
.output(`uploads/720p-${filename}${extension}`)
|
.output(`uploads/720p-${filename}${extension}`)
|
||||||
.on("progress", function (progress) {
|
.on("progress", function (progress) {
|
||||||
fs.writeFileSync(progressFile, JSON.stringify({ progress: progress.percent / 100 }));
|
fs.writeFileSync(
|
||||||
|
progressFile,
|
||||||
|
JSON.stringify({ progress: progress.percent / 100 }),
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.on("end", () => {
|
.on("end", () => {
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -189,7 +192,7 @@ export const ffmpegConvert = (
|
||||||
path: string,
|
path: string,
|
||||||
filename: string,
|
filename: string,
|
||||||
extension: string,
|
extension: string,
|
||||||
) => {
|
): Promise<void> => {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
const outputOptions = [
|
const outputOptions = [
|
||||||
"-vf",
|
"-vf",
|
||||||
|
@ -226,7 +229,10 @@ export const ffmpegConvert = (
|
||||||
.outputFormat(outputFormat)
|
.outputFormat(outputFormat)
|
||||||
.output(`uploads/${filename}${outputFormat}`)
|
.output(`uploads/${filename}${outputFormat}`)
|
||||||
.on("progress", function (progress) {
|
.on("progress", function (progress) {
|
||||||
fs.writeFileSync(progressFile, JSON.stringify({ progress: progress.percent / 100 }));
|
fs.writeFileSync(
|
||||||
|
progressFile,
|
||||||
|
JSON.stringify({ progress: progress.percent / 100 }),
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.on("end", function () {
|
.on("end", function () {
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -246,7 +252,10 @@ export const ffProbe = async (
|
||||||
extension: string,
|
extension: string,
|
||||||
) => {
|
) => {
|
||||||
return new Promise<FfprobeData>((resolve, reject) => {
|
return new Promise<FfprobeData>((resolve, reject) => {
|
||||||
if (!videoExtensions.includes(extension) && !imageExtensions.includes(extension)) {
|
if (
|
||||||
|
!videoExtensions.includes(extension) &&
|
||||||
|
!imageExtensions.includes(extension)
|
||||||
|
) {
|
||||||
console.log(`Extension is ${extension}`);
|
console.log(`Extension is ${extension}`);
|
||||||
reject(`Submitted file is neither a video nor an image: ${path}`);
|
reject(`Submitted file is neither a video nor an image: ${path}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,14 @@ export const checkSharexAuth: Middleware = (req, res, next) => {
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**Creates oembed json file for embed metadata */
|
/**
|
||||||
|
* Creates oembed data for uploaded files
|
||||||
|
*
|
||||||
|
* @param {Express Request Object} Express request object
|
||||||
|
* @param {Express Response Object} Express response object
|
||||||
|
* @param {Express NextFunction variable} Express next function
|
||||||
|
*
|
||||||
|
*/
|
||||||
export const createEmbedData: Middleware = async (req, res, next) => {
|
export const createEmbedData: Middleware = async (req, res, next) => {
|
||||||
const files = req.files as Express.Multer.File[];
|
const files = req.files as Express.Multer.File[];
|
||||||
for (const file in files) {
|
for (const file in files) {
|
||||||
|
@ -90,7 +97,14 @@ export const createEmbedData: Middleware = async (req, res, next) => {
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**Creates a 720p copy of video for smaller file */
|
/**
|
||||||
|
* Creates a 720p copy of uploaded videos
|
||||||
|
*
|
||||||
|
* @param {Express Request Object} req Express request object
|
||||||
|
* @param {Express Response Object} res Express response object
|
||||||
|
* @param {Express NextFunction} next Express next function
|
||||||
|
*
|
||||||
|
*/
|
||||||
export const convertTo720p: Middleware = (req, res, next) => {
|
export const convertTo720p: Middleware = (req, res, next) => {
|
||||||
const files = req.files as Express.Multer.File[];
|
const files = req.files as Express.Multer.File[];
|
||||||
console.log("convert to 720p running");
|
console.log("convert to 720p running");
|
||||||
|
@ -103,7 +117,6 @@ export const convertTo720p: Middleware = (req, res, next) => {
|
||||||
fileExtension !== ".gif"
|
fileExtension !== ".gif"
|
||||||
) {
|
) {
|
||||||
console.log(`${files[file].filename} is not a video file`);
|
console.log(`${files[file].filename} is not a video file`);
|
||||||
console.log(fileExtension);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ export const fileStorage = multer.diskStorage({
|
||||||
console.log(err);
|
console.log(err);
|
||||||
callback(err, null);
|
callback(err, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exists.length != 0) {
|
if (exists.length != 0) {
|
||||||
const suffix = new Date().getTime() / 1000;
|
const suffix = new Date().getTime() / 1000;
|
||||||
|
|
||||||
|
@ -41,15 +42,9 @@ export const fileStorage = multer.diskStorage({
|
||||||
request.body.title == null ||
|
request.body.title == null ||
|
||||||
request.body.title == undefined
|
request.body.title == undefined
|
||||||
) {
|
) {
|
||||||
callback(
|
callback(null, filename + "-" + suffix + fileExtension);
|
||||||
null,
|
|
||||||
filename + "-" + suffix + fileExtension,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
callback(
|
callback(null, request.body.title + "-" + suffix + fileExtension);
|
||||||
null,
|
|
||||||
request.body.title + "-" + suffix + fileExtension,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (
|
if (
|
||||||
|
@ -67,7 +62,7 @@ export const fileStorage = multer.diskStorage({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const allowedMimeTypes = [
|
export let allowedMimeTypes = [
|
||||||
"image/png",
|
"image/png",
|
||||||
"image/jpg",
|
"image/jpg",
|
||||||
"image/jpeg",
|
"image/jpeg",
|
||||||
|
@ -80,6 +75,10 @@ export const allowedMimeTypes = [
|
||||||
"audio/ogg",
|
"audio/ogg",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const setAllowedMimeTypes = (mimeTypes: string[]): void => {
|
||||||
|
allowedMimeTypes = mimeTypes;
|
||||||
|
};
|
||||||
|
|
||||||
export const fileFilter = (
|
export const fileFilter = (
|
||||||
request: Request,
|
request: Request,
|
||||||
file: Express.Multer.File,
|
file: Express.Multer.File,
|
||||||
|
@ -91,4 +90,3 @@ export const fileFilter = (
|
||||||
callback(null, false);
|
callback(null, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,30 @@
|
||||||
/* eslint-disable no-undef */
|
/* eslint no-use-before-define: 0 */
|
||||||
/* eslint-env browser: true */
|
/* eslint-env browser: true */
|
||||||
|
|
||||||
let newMediaList;
|
let newMediaList;
|
||||||
|
|
||||||
|
const videoExtensions = [
|
||||||
|
".mp4",
|
||||||
|
".mov",
|
||||||
|
".avi",
|
||||||
|
".flv",
|
||||||
|
".mkv",
|
||||||
|
".wmv",
|
||||||
|
".webm",
|
||||||
|
];
|
||||||
|
|
||||||
|
const imageExtensions = [
|
||||||
|
".jpg",
|
||||||
|
".jpeg",
|
||||||
|
".png",
|
||||||
|
".gif",
|
||||||
|
".bmp",
|
||||||
|
".svg",
|
||||||
|
".tiff",
|
||||||
|
".webp",
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
function copyURI(evt) {
|
function copyURI(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
navigator.clipboard
|
navigator.clipboard
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
<!doctype html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>Embedder</title>
|
<title>Embedder</title>
|
||||||
<link rel="stylesheet" href="/css/base.css">
|
<link rel="stylesheet" href="/css/base.css" />
|
||||||
<link rel="stylesheet" href="/css/index.css">
|
<link rel="stylesheet" href="/css/index.css" />
|
||||||
<link rel="stylesheet" href="/css/login.css">
|
<link rel="stylesheet" href="/css/login.css" />
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
|
||||||
<link rel="manifest" href="/site.webmanifest">
|
<link rel="manifest" href="/site.webmanifest" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<section class="prompt">
|
<section class="prompt">
|
||||||
|
@ -19,18 +19,33 @@
|
||||||
<form action="/adduser" method="post">
|
<form action="/adduser" method="post">
|
||||||
<section>
|
<section>
|
||||||
<label for="username">Username</label>
|
<label for="username">Username</label>
|
||||||
<input id="username" name="username" type="text" autocomplete="username" required autofocus>
|
<input
|
||||||
|
id="username"
|
||||||
|
name="username"
|
||||||
|
type="text"
|
||||||
|
autocomplete="username"
|
||||||
|
required
|
||||||
|
autofocus
|
||||||
|
/>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<label for="current-password">Password</label>
|
<label for="current-password">Password</label>
|
||||||
<input id="current-password" name="password" type="password" autocomplete="current-password" required>
|
<input
|
||||||
|
id="current-password"
|
||||||
|
name="password"
|
||||||
|
type="password"
|
||||||
|
autocomplete="current-password"
|
||||||
|
required
|
||||||
|
/>
|
||||||
</section>
|
</section>
|
||||||
<button type="submit">Add User</button>
|
<button type="submit">Add User</button>
|
||||||
</form>
|
</form>
|
||||||
<hr>
|
<hr />
|
||||||
</section>
|
</section>
|
||||||
<footer class="info">
|
<footer class="info">
|
||||||
<p><a href="https://l.nekomimi.pet/project">Created by Wavering Ana</a></p>
|
<p>
|
||||||
|
<a href="https://l.nekomimi.pet/project">Created by Wavering Ana</a>
|
||||||
|
</p>
|
||||||
<p><a href="https://github.com/WaveringAna/Embedder">Github</a></p>
|
<p><a href="https://github.com/WaveringAna/Embedder">Github</a></p>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -80,11 +80,6 @@ p {
|
||||||
line-height: 1.6; /* Improve readability */
|
line-height: 1.6; /* Improve readability */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Optionally, you can add media query for dark mode based on user's system preferences */
|
|
||||||
@media (prefers-color-scheme: dark) {
|
|
||||||
/* Dark mode styles */
|
|
||||||
}
|
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
|
@ -108,6 +103,9 @@ footer a:hover {
|
||||||
text-decoration: underline; /* Adds an underline on hover for better user experience */
|
text-decoration: underline; /* Adds an underline on hover for better user experience */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "embedder",
|
"name": "embedder",
|
||||||
"version": "1.9.2",
|
"version": "1.10.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "embedder",
|
"name": "embedder",
|
||||||
"version": "1.9.2",
|
"version": "1.10.1",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "Unlicense",
|
"license": "Unlicense",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "embedder",
|
"name": "embedder",
|
||||||
"version": "1.9.2",
|
"version": "1.10.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Media host for quick embeds to sites like discord",
|
"description": "Media host for quick embeds to sites like discord",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue