docker and youtube, docs

This commit is contained in:
Ondrej Zara 2019-10-29 08:49:04 +01:00
parent 3c0b41ab7f
commit 8add38bee4
6 changed files with 31 additions and 4 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules
_youtube
_youtube/*
!_youtube/.empty
cyp.service

View File

@ -1,6 +1,7 @@
FROM node:10
RUN curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
RUN chmod a+rx /usr/local/bin/youtube-dl
WORKDIR /cyp
RUN ["mkdir", "_youtube"]
COPY package.json .
RUN npm i
COPY index.js .

View File

@ -27,4 +27,10 @@ watch: all
clean:
rm -f $(SERVICE) $(CSS)
docker-image:
docker build -t cyp .
docker-run:
docker run --network=host -v "$$(pwd)"/_youtube:/cyp/_youtube cyp
.PHONY: all watch icons service clean

View File

@ -38,6 +38,25 @@ docker build -t cyp .
docker run --network=host cyp
```
## Youtube-dl integration
You will need a working [youtube-dl](https://ytdl-org.github.io/youtube-dl/index.html) installation. Audio files are downloaded into the `_youtube` directory, so make sure it is available to your MPD library (use a symlink).
If you use Docker, you need to mount the `_youtube` directory into the image:
```sh
docker run --network=host -v "$(pwd)"/_youtube:/cyp/_youtube cyp
```
## Changing the port
...is done via the `PORT` environment variable. If you use Docker, the `-e` switch does the trick:
```sh
docker run --network=host -e PORT=12345 cyp
```
## Technology
- Connected to MPD via WebSockets (using the [ws2mpd](https://github.com/ondras/ws2mpd/) bridge)
@ -53,5 +72,5 @@ docker run --network=host cyp
## TODO
- [ ] Bundling
- [ ] Range styling
- [X] Range styling
- [ ] Browser testing

0
_youtube/.empty Normal file
View File

View File

@ -1,6 +1,6 @@
const static = require("node-static");
const app = new static.Server("./app");
const port = Number(process.argv[2]) || 8080;
const port = Number(process.argv[2]) || process.env.PORT || 8080;
let tickets = [];