Skip to content

Commit

Permalink
1.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
WaveringAna committed Dec 11, 2023
1 parent 604692c commit bd30f3e
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 66 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
23 changes: 16 additions & 7 deletions app/lib/ffmpeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const ffmpegDownscale = (
path: string,
filename: string,
extension: string,
) => {
): Promise<void> => {
const startTime = Date.now();
const outputOptions = [
"-vf",
Expand All @@ -143,8 +143,11 @@ export const ffmpegDownscale = (
.input(path)
.outputOptions(outputOptions)
.output(`uploads/720p-${filename}${extension}`)
.on("progress", function(progress) {
fs.writeFileSync(progressFile, JSON.stringify({ progress: progress.percent / 100 }));
.on("progress", function (progress) {
fs.writeFileSync(
progressFile,
JSON.stringify({ progress: progress.percent / 100 }),
);
})
.on("end", () => {
console.log(
Expand Down Expand Up @@ -189,7 +192,7 @@ export const ffmpegConvert = (
path: string,
filename: string,
extension: string,
) => {
): Promise<void> => {
const startTime = Date.now();
const outputOptions = [
"-vf",
Expand Down Expand Up @@ -225,8 +228,11 @@ export const ffmpegConvert = (
.output("uploads/")
.outputFormat(outputFormat)
.output(`uploads/${filename}${outputFormat}`)
.on("progress", function(progress) {
fs.writeFileSync(progressFile, JSON.stringify({ progress: progress.percent / 100 }));
.on("progress", function (progress) {
fs.writeFileSync(
progressFile,
JSON.stringify({ progress: progress.percent / 100 }),
);
})
.on("end", function () {
console.log(
Expand All @@ -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}`);
}
Expand Down
19 changes: 16 additions & 3 deletions app/lib/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
Expand All @@ -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;
}

Expand Down
18 changes: 8 additions & 10 deletions app/lib/multer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 (
Expand All @@ -67,7 +62,7 @@ export const fileStorage = multer.diskStorage({
},
});

export const allowedMimeTypes = [
export let allowedMimeTypes = [
"image/png",
"image/jpg",
"image/jpeg",
Expand All @@ -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,
Expand All @@ -91,4 +90,3 @@ export const fileFilter = (
callback(null, false);
}
};

24 changes: 23 additions & 1 deletion app/public/js/index.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
83 changes: 49 additions & 34 deletions app/views/adduser.ejs
Original file line number Diff line number Diff line change
@@ -1,37 +1,52 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<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">
<head>
<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" />
</head>
<body>
<section class="prompt">
<h3>Embedder</h3>
<h1>Add User</h1>
<form action="/adduser" method="post">
<section>
<label for="username">Username</label>
<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>
</section>
<button type="submit">Add User</button>
</form>
<hr>
</section>
<footer class="info">
<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>
<body>
<section class="prompt">
<h3>Embedder</h3>
<h1>Add User</h1>
<form action="/adduser" method="post">
<section>
<label for="username">Username</label>
<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
/>
</section>
<button type="submit">Add User</button>
</form>
<hr />
</section>
<footer class="info">
<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>
</html>
10 changes: 4 additions & 6 deletions app/views/gifv.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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>
Expand All @@ -119,6 +117,6 @@ footer a:hover {

<footer>
<p>Powered by <a href="https://github.com/waveringana/embedder">Embedder</a> created by <a href="https://github.com/waveringana">WaveringAna</a></p>
</footer>
</footer>
</body>
</html>
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down

0 comments on commit bd30f3e

Please sign in to comment.