Compare commits
6 Commits
v1.0.1
...
8b28537fb8
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b28537fb8 | |||
| db731053fc | |||
| 8623e6be8d | |||
| 0933b591fe | |||
| 16d971d8bb | |||
| 3792de3c91 |
3
AUTHORS.md
Normal file
3
AUTHORS.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
### Authors
|
||||||
|
|
||||||
|
- Joe Fleming ([w33ble](https://github.com/w33ble))
|
||||||
8
CHANGELOG.md
Normal file
8
CHANGELOG.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
### Changelog
|
||||||
|
|
||||||
|
#### 1.1.0 (27 November 2019)
|
||||||
|
- initial commit [`b66eb8a`](https://git.w33ble.com/w33ble/youtube-dl-web/commit/b66eb8abe793f7d551f1c44612a0b7e32d9b05b4)
|
||||||
|
- feat: functional download server [`eb35ae5`](https://git.w33ble.com/w33ble/youtube-dl-web/commit/eb35ae5dfdb76c6f144920e0c49b0313c9dbfb22)
|
||||||
|
- doc: update readme [`a955d20`](https://git.w33ble.com/w33ble/youtube-dl-web/commit/a955d20a52201d7d6ed56d8db077adf654e18636)
|
||||||
|
- feat: allow cleanup via REMOVE_DOWNLOAD env [`3792de3`](https://git.w33ble.com/w33ble/youtube-dl-web/commit/3792de3c91f307403eee6acec5a914cdf5ab9809)
|
||||||
|
- docs: add note about REMOVE_DOWNLOAD to readme [`16d971d`](https://git.w33ble.com/w33ble/youtube-dl-web/commit/16d971d8bbc9f82d83d3aee40119b179123303e2)
|
||||||
30
Dockerfile
30
Dockerfile
@@ -1,17 +1,37 @@
|
|||||||
|
# create build from source
|
||||||
|
FROM python:3 AS build
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
RUN set -xe \
|
||||||
|
&& apt-get update -y \
|
||||||
|
&& apt-get install -y zip pandoc \
|
||||||
|
&& curl -L https://github.com/ytdl-org/youtube-dl/archive/master.zip -o youtube-dl-master.zip \
|
||||||
|
&& unzip youtube-dl-master.zip
|
||||||
|
|
||||||
|
WORKDIR /build/youtube-dl-master
|
||||||
|
|
||||||
|
RUN set -xe \
|
||||||
|
&& make
|
||||||
|
|
||||||
|
# add the build to the web container
|
||||||
FROM node:12-alpine
|
FROM node:12-alpine
|
||||||
|
|
||||||
# install youtube-dl
|
WORKDIR /app
|
||||||
|
|
||||||
|
# copy the build
|
||||||
|
COPY --from=build /build/youtube-dl-master/youtube-dl /usr/local/bin
|
||||||
|
|
||||||
|
# install dependencies
|
||||||
RUN set -xe \
|
RUN set -xe \
|
||||||
|
&& chmod a+rx /usr/local/bin/youtube-dl \
|
||||||
&& apk add --no-cache ca-certificates \
|
&& apk add --no-cache ca-certificates \
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
openssl \
|
openssl \
|
||||||
python3 \
|
python3 \
|
||||||
&& pip3 install --upgrade pip \
|
&& ln -s /usr/bin/python3 /usr/bin/python
|
||||||
&& pip3 install youtube-dl
|
|
||||||
|
|
||||||
# install app dependencies
|
# install app dependencies
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
RUN npm install -g yarn
|
RUN npm install -g yarn
|
||||||
COPY package.json yarn.lock ./
|
COPY package.json yarn.lock ./
|
||||||
RUN yarn install
|
RUN yarn install
|
||||||
|
|||||||
24
README.md
24
README.md
@@ -13,14 +13,30 @@ Meant to be used with Docker, but it would work locally if you have [youtube-dl]
|
|||||||
docker run -it --rm -p 8080:8080 -v $PWD/data:/app/data w33ble/youtube-dl-web
|
docker run -it --rm -p 8080:8080 -v $PWD/data:/app/data w33ble/youtube-dl-web
|
||||||
```
|
```
|
||||||
|
|
||||||
Then hit `http://localhost:8080`, passing in a `url` and optionally a `format` query parameter for where to download from.
|
Then hit `http://localhost:8080`, passing in a `url` and optionally a `format` query parameter for where to download from. For example:
|
||||||
|
|
||||||
|
```text
|
||||||
|
http://localhost:8080?url=https://www.youtube.com/watch?v=YE7VzlLtp-4
|
||||||
|
```
|
||||||
|
|
||||||
|
### Automatic cleanup
|
||||||
|
|
||||||
|
By default, this image will both send the download in the web response as well as save it to disk. This is handy if you're saving those downloads via a volume.
|
||||||
|
|
||||||
|
If you don't want to keep the downloads around, you can use the `REMOVE_DOWNLOAD` environment to tell the server to clean up the download after sending it in the web request. Setting the value to `1` or `true` is all it takes:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker run -it --rm -p 8080:8080 --env REMOVE_DOWNLOAD=1 w33ble/youtube-dl-web
|
||||||
|
```
|
||||||
|
|
||||||
|
Running it like this, the result from youtube-dl will only be useful from the web response. The file is cleaned up after sending so using the shared volume doesn't make sense.
|
||||||
|
|
||||||
## Deploy to Docker Hub
|
## Deploy to Docker Hub
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker build . -t youtube-dl
|
docker build . -t youtube-dl-web
|
||||||
docker tag youtube-dl USERNAME/youtube-dl:latest
|
docker tag youtube-dl w33ble/youtube-dl-web:latest
|
||||||
docker push USERNAME/youtube-dl:latest
|
docker push w33ble/youtube-dl-web:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "youtube-dl-web",
|
"name": "youtube-dl-web",
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"description": "youtube-dl wrapped in a simple web server",
|
"description": "youtube-dl wrapped in a simple web server",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -89,6 +89,19 @@ module.exports = async function server(req, res) {
|
|||||||
sent = true;
|
sent = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sent = true;
|
sent = true;
|
||||||
|
|
||||||
|
// clean up the download if told to
|
||||||
|
res.on('finish', () => {
|
||||||
|
const { REMOVE_DOWNLOAD } = process.env;
|
||||||
|
if (!REMOVE_DOWNLOAD) return;
|
||||||
|
|
||||||
|
const shouldRemove = REMOVE_DOWNLOAD === '1' || REMOVE_DOWNLOAD.toLowerCase() === 'true';
|
||||||
|
if (shouldRemove) {
|
||||||
|
logger.info('Removing local file:', dlFilepath);
|
||||||
|
fs.unlinkSync(dlFilepath);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user