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
|
||||
|
||||
```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
|
||||
|
@ -76,7 +76,7 @@ services:
|
|||
volumes:
|
||||
- ./db:/var/db
|
||||
- ./uploads:/uploads
|
||||
image: ghcr.io/waveringana/embedder:1.9.2
|
||||
image: ghcr.io/waveringana/embedder:1.10.1
|
||||
```
|
||||
|
||||
## 📜 License
|
||||
|
|
|
@ -123,7 +123,7 @@ export const ffmpegDownscale = (
|
|||
path: string,
|
||||
filename: string,
|
||||
extension: string,
|
||||
) => {
|
||||
): Promise<void> => {
|
||||
const startTime = Date.now();
|
||||
const outputOptions = [
|
||||
"-vf",
|
||||
|
@ -144,7 +144,10 @@ export const ffmpegDownscale = (
|
|||
.outputOptions(outputOptions)
|
||||
.output(`uploads/720p-${filename}${extension}`)
|
||||
.on("progress", function (progress) {
|
||||
fs.writeFileSync(progressFile, JSON.stringify({ progress: progress.percent / 100 }));
|
||||
fs.writeFileSync(
|
||||
progressFile,
|
||||
JSON.stringify({ progress: progress.percent / 100 }),
|
||||
);
|
||||
})
|
||||
.on("end", () => {
|
||||
console.log(
|
||||
|
@ -189,7 +192,7 @@ export const ffmpegConvert = (
|
|||
path: string,
|
||||
filename: string,
|
||||
extension: string,
|
||||
) => {
|
||||
): Promise<void> => {
|
||||
const startTime = Date.now();
|
||||
const outputOptions = [
|
||||
"-vf",
|
||||
|
@ -226,7 +229,10 @@ export const ffmpegConvert = (
|
|||
.outputFormat(outputFormat)
|
||||
.output(`uploads/${filename}${outputFormat}`)
|
||||
.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 () {
|
||||
console.log(
|
||||
|
@ -246,7 +252,10 @@ export const ffProbe = async (
|
|||
extension: string,
|
||||
) => {
|
||||
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}`);
|
||||
reject(`Submitted file is neither a video nor an image: ${path}`);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,14 @@ export const checkSharexAuth: Middleware = (req, res, 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) => {
|
||||
const files = req.files as Express.Multer.File[];
|
||||
for (const file in files) {
|
||||
|
@ -90,7 +97,14 @@ export const createEmbedData: Middleware = async (req, res, 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) => {
|
||||
const files = req.files as Express.Multer.File[];
|
||||
console.log("convert to 720p running");
|
||||
|
@ -103,7 +117,6 @@ export const convertTo720p: Middleware = (req, res, next) => {
|
|||
fileExtension !== ".gif"
|
||||
) {
|
||||
console.log(`${files[file].filename} is not a video file`);
|
||||
console.log(fileExtension);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ export const fileStorage = multer.diskStorage({
|
|||
console.log(err);
|
||||
callback(err, null);
|
||||
}
|
||||
|
||||
if (exists.length != 0) {
|
||||
const suffix = new Date().getTime() / 1000;
|
||||
|
||||
|
@ -41,15 +42,9 @@ export const fileStorage = multer.diskStorage({
|
|||
request.body.title == null ||
|
||||
request.body.title == undefined
|
||||
) {
|
||||
callback(
|
||||
null,
|
||||
filename + "-" + suffix + fileExtension,
|
||||
);
|
||||
callback(null, filename + "-" + suffix + fileExtension);
|
||||
} else {
|
||||
callback(
|
||||
null,
|
||||
request.body.title + "-" + suffix + fileExtension,
|
||||
);
|
||||
callback(null, request.body.title + "-" + suffix + fileExtension);
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
|
@ -67,7 +62,7 @@ export const fileStorage = multer.diskStorage({
|
|||
},
|
||||
});
|
||||
|
||||
export const allowedMimeTypes = [
|
||||
export let allowedMimeTypes = [
|
||||
"image/png",
|
||||
"image/jpg",
|
||||
"image/jpeg",
|
||||
|
@ -80,6 +75,10 @@ export const allowedMimeTypes = [
|
|||
"audio/ogg",
|
||||
];
|
||||
|
||||
export const setAllowedMimeTypes = (mimeTypes: string[]): void => {
|
||||
allowedMimeTypes = mimeTypes;
|
||||
};
|
||||
|
||||
export const fileFilter = (
|
||||
request: Request,
|
||||
file: Express.Multer.File,
|
||||
|
@ -91,4 +90,3 @@ export const fileFilter = (
|
|||
callback(null, false);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,30 @@
|
|||
/* eslint-disable no-undef */
|
||||
/* eslint no-use-before-define: 0 */
|
||||
/* eslint-env browser: true */
|
||||
|
||||
let newMediaList;
|
||||
|
||||
const videoExtensions = [
|
||||
".mp4",
|
||||
".mov",
|
||||
".avi",
|
||||
".flv",
|
||||
".mkv",
|
||||
".wmv",
|
||||
".webm",
|
||||
];
|
||||
|
||||
const imageExtensions = [
|
||||
".jpg",
|
||||
".jpeg",
|
||||
".png",
|
||||
".gif",
|
||||
".bmp",
|
||||
".svg",
|
||||
".tiff",
|
||||
".webp",
|
||||
];
|
||||
|
||||
|
||||
function copyURI(evt) {
|
||||
evt.preventDefault();
|
||||
navigator.clipboard
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Embedder</title>
|
||||
<link rel="stylesheet" href="/css/base.css">
|
||||
<link rel="stylesheet" href="/css/index.css">
|
||||
<link rel="stylesheet" href="/css/login.css">
|
||||
<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="16x16" href="/favicon-16x16.png">
|
||||
<link rel="manifest" href="/site.webmanifest">
|
||||
<link rel="stylesheet" href="/css/base.css" />
|
||||
<link rel="stylesheet" href="/css/index.css" />
|
||||
<link rel="stylesheet" href="/css/login.css" />
|
||||
<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="16x16" href="/favicon-16x16.png" />
|
||||
<link rel="manifest" href="/site.webmanifest" />
|
||||
</head>
|
||||
<body>
|
||||
<section class="prompt">
|
||||
|
@ -19,18 +19,33 @@
|
|||
<form action="/adduser" method="post">
|
||||
<section>
|
||||
<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>
|
||||
<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>
|
||||
<button type="submit">Add User</button>
|
||||
</form>
|
||||
<hr>
|
||||
<hr />
|
||||
</section>
|
||||
<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>
|
||||
</footer>
|
||||
</body>
|
||||
|
|
|
@ -80,11 +80,6 @@ p {
|
|||
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 {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
|
@ -108,6 +103,9 @@ footer a:hover {
|
|||
text-decoration: underline; /* Adds an underline on hover for better user experience */
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "embedder",
|
||||
"version": "1.9.2",
|
||||
"version": "1.10.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "embedder",
|
||||
"version": "1.9.2",
|
||||
"version": "1.10.1",
|
||||
"hasInstallScript": true,
|
||||
"license": "Unlicense",
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "embedder",
|
||||
"version": "1.9.2",
|
||||
"version": "1.10.1",
|
||||
"private": true,
|
||||
"description": "Media host for quick embeds to sites like discord",
|
||||
"keywords": [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue