This commit is contained in:
2021-11-24 00:04:37 +01:00
parent 697138d3fa
commit 88cbba61ef
6 changed files with 42 additions and 18 deletions

View File

@@ -1,9 +1,14 @@
FROM node:14
VOLUME /downloads
FROM node:16-bullseye
RUN mkdir -p /usr/src/yt-dlp-webui/downloadsd
VOLUME /usr/src/yt-dlp-webui/downloads
WORKDIR /usr/src/yt-dlp-webui
COPY package*.json ./
RUN apt-get update
RUN apt-get install curl ffmpeg -y
RUN npm install
RUN npm run build
COPY . .
RUN npm run build
RUN chmod +x ./lib/fetch-yt-dlp.sh
RUN ./lib/fetch-yt-dlp.sh && mv yt-dlp ./lib
EXPOSE 3022
CMD [ "node" , "./server.js" ]

View File

@@ -8,12 +8,13 @@ I will eventually make this better as soon as I can. Not in the immediate.
## Docker install
```
// download the yt-dl build and put it in the lib folder and make it executable
mkdir downloads
docker pull marcobaobao/yt-dlp-webui:latest
docker run -d -p 3022:3022 -v <your dir>:/usr/src/yt-dlp-webui/downloads marcobaobao/yt-dlp-webui
```
or
```
docker build -t yt-dlp-webui .
docker run -d -p 3022:3022 yt-dlp-webui
docker run -d -p 3022:3022 -v <your dir>:/usr/src/yt-dlp-webui/downloads yt-dlp-webui
```
## Manual install
@@ -22,6 +23,7 @@ docker run -d -p 3022:3022 yt-dlp-webui
npm i
npm run build
npm run fetch
// edit the settings.json specifying the download path or
// it will use the following folder

View File

@@ -1,6 +1,6 @@
const { spawn } = require('child_process')
const logger = require('./logger')
let settings
const { spawn } = require('child_process');
const logger = require('./logger');
let settings;
try {
settings = require('../settings.json')
@@ -13,14 +13,15 @@ const isWindows = process.platform === 'win32'
const download = (socket, url) => {
const ytldp = spawn(`./lib/yt-dlp${isWindows ? '.exe' : ''}`,
['-o', `${settings.download_path || './downloads/'}%(title)s.%(ext)s`, url]
['-o', `${settings.download_path || 'downloads/'}%(title)s.%(ext)s`, url]
)
ytldp.stdout.on('data', data => {
socket.emit('progress', data.toString())
console.log(data.toString())
logger('download', `Fetching ${data.toString()}`)
})
ytldp.on('exit', () => {
socket.emit('progress', 'Done!')
logger('download', 'Done!')
})
}
@@ -30,7 +31,7 @@ const abortDownload = (socket) => {
spawn('killall', ['yt-dlp'])
res.stdout.on('data', data => {
socket.emit('progress', 'Aborted!')
console.log(data.toString())
logger('download', `Aborting ${data.toString()}`)
})
logger('download', 'Aborted')
}

15
lib/fetch-yt-dlp.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
echo "Downloading latest yt-dlp..."
rm -f yt-dlp
RELEASE=$(curl --silent "https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest" |
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/'
)
wget "https://github.com/yt-dlp/yt-dlp/releases/download/$RELEASE/yt-dlp"
chmod +x yt-dlp
echo "Done!"

View File

@@ -3,10 +3,11 @@
"version": "1.0.0",
"description": "",
"scripts": {
"start": "node --harmony app.js",
"start": "node --harmony server.js",
"dev": "nodemon app.js",
"build": "parcel build ./frontend/index.html",
"fe": "parcel ./frontend/index.html --open"
"fe": "parcel ./frontend/index.html --open",
"fetch":"./lib/fetch-yt-dlp.sh && mv yt-dlp ./lib"
},
"author": "",
"license": "ISC",

View File

@@ -27,11 +27,11 @@ io.on('connection', socket => {
socket.on('abort', () => {
abortDownload(socket)
})
});
})
io.on('disconnect', () => {
logger('ws', 'disconnesso')
});
})
app
.use(cors())