refactor
This commit is contained in:
11
Dockerfile
11
Dockerfile
@@ -1,9 +1,14 @@
|
|||||||
FROM node:14
|
FROM node:16-bullseye
|
||||||
VOLUME /downloads
|
RUN mkdir -p /usr/src/yt-dlp-webui/downloadsd
|
||||||
|
VOLUME /usr/src/yt-dlp-webui/downloads
|
||||||
WORKDIR /usr/src/yt-dlp-webui
|
WORKDIR /usr/src/yt-dlp-webui
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get install curl ffmpeg -y
|
||||||
RUN npm install
|
RUN npm install
|
||||||
RUN npm run build
|
|
||||||
COPY . .
|
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
|
EXPOSE 3022
|
||||||
CMD [ "node" , "./server.js" ]
|
CMD [ "node" , "./server.js" ]
|
||||||
12
README.md
12
README.md
@@ -8,12 +8,13 @@ I will eventually make this better as soon as I can. Not in the immediate.
|
|||||||
|
|
||||||
## Docker install
|
## Docker install
|
||||||
```
|
```
|
||||||
// download the yt-dl build and put it in the lib folder and make it executable
|
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
|
||||||
mkdir downloads
|
```
|
||||||
|
or
|
||||||
|
```
|
||||||
docker build -t yt-dlp-webui .
|
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
|
## Manual install
|
||||||
@@ -22,6 +23,7 @@ docker run -d -p 3022:3022 yt-dlp-webui
|
|||||||
|
|
||||||
npm i
|
npm i
|
||||||
npm run build
|
npm run build
|
||||||
|
npm run fetch
|
||||||
|
|
||||||
// edit the settings.json specifying the download path or
|
// edit the settings.json specifying the download path or
|
||||||
// it will use the following folder
|
// it will use the following folder
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const { spawn } = require('child_process')
|
const { spawn } = require('child_process');
|
||||||
const logger = require('./logger')
|
const logger = require('./logger');
|
||||||
let settings
|
let settings;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
settings = require('../settings.json')
|
settings = require('../settings.json')
|
||||||
@@ -13,14 +13,15 @@ const isWindows = process.platform === 'win32'
|
|||||||
|
|
||||||
const download = (socket, url) => {
|
const download = (socket, url) => {
|
||||||
const ytldp = spawn(`./lib/yt-dlp${isWindows ? '.exe' : ''}`,
|
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 => {
|
ytldp.stdout.on('data', data => {
|
||||||
socket.emit('progress', data.toString())
|
socket.emit('progress', data.toString())
|
||||||
console.log(data.toString())
|
logger('download', `Fetching ${data.toString()}`)
|
||||||
})
|
})
|
||||||
ytldp.on('exit', () => {
|
ytldp.on('exit', () => {
|
||||||
socket.emit('progress', 'Done!')
|
socket.emit('progress', 'Done!')
|
||||||
|
logger('download', 'Done!')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ const abortDownload = (socket) => {
|
|||||||
spawn('killall', ['yt-dlp'])
|
spawn('killall', ['yt-dlp'])
|
||||||
res.stdout.on('data', data => {
|
res.stdout.on('data', data => {
|
||||||
socket.emit('progress', 'Aborted!')
|
socket.emit('progress', 'Aborted!')
|
||||||
console.log(data.toString())
|
logger('download', `Aborting ${data.toString()}`)
|
||||||
})
|
})
|
||||||
logger('download', 'Aborted')
|
logger('download', 'Aborted')
|
||||||
}
|
}
|
||||||
|
|||||||
15
lib/fetch-yt-dlp.sh
Executable file
15
lib/fetch-yt-dlp.sh
Executable 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!"
|
||||||
@@ -3,10 +3,11 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node --harmony app.js",
|
"start": "node --harmony server.js",
|
||||||
"dev": "nodemon app.js",
|
"dev": "nodemon app.js",
|
||||||
"build": "parcel build ./frontend/index.html",
|
"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": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ io.on('connection', socket => {
|
|||||||
socket.on('abort', () => {
|
socket.on('abort', () => {
|
||||||
abortDownload(socket)
|
abortDownload(socket)
|
||||||
})
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
io.on('disconnect', () => {
|
io.on('disconnect', () => {
|
||||||
logger('ws', 'disconnesso')
|
logger('ws', 'disconnesso')
|
||||||
});
|
})
|
||||||
|
|
||||||
app
|
app
|
||||||
.use(cors())
|
.use(cors())
|
||||||
|
|||||||
Reference in New Issue
Block a user