From d2fbe8e7946f087bc50b29d80ac4b89cb75fad87 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Mon, 23 Jan 2023 21:05:05 -0500 Subject: initial commit --- docker-compose.yaml | 23 +++++++++ index.html | 19 +++++++ metube-README.md | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++ metube-disabled.cnf | 10 ++++ metube.cnf | 11 +++++ metube.service | 16 ++++++ metube.xml | 6 +++ 7 files changed, 225 insertions(+) create mode 100644 docker-compose.yaml create mode 100644 index.html create mode 100644 metube-README.md create mode 100644 metube-disabled.cnf create mode 100644 metube.cnf create mode 100644 metube.service create mode 100644 metube.xml diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..2a740c8 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,23 @@ +# File: docker-compose.yaml +# Project: metube +# Startdate: 2023-01-23 +version: "3" +services: + metube: + image: alexta69/metube + container_name: metube + restart: unless-stopped + ports: + - "8081:8081" + volumes: + - /mnt/public/Video/Downloads:/downloads + environment: + # Most of this was suggested by readme. I added restrictfilenames to use only ascii and no spaces + YTDL_OPTIONS: '{"writesubtitles": true, "subtitleslangs": ["en", "-live_chat"], "postprocessors": [{"key": "Exec", "exec_cmd": "chmod 0664", "when": "after_move"}, {"key": "FFmpegEmbedSubtitle", "already_have_subtitle": false}, {"key": "FFmpegMetadata", "add_chapters": true}], "restrictfilenames": true}' + # personal preference; I like to include id, which also helps jellyfin + OUTPUT_TEMPLATE: "%(title)s.%(id)s.%(ext)s" + # prefix for reverse proxy in httpd metube.cnf + URL_PREFIX: "/metube" + # user and group public + UID: 960600006 + GID: 960600005 diff --git a/index.html b/index.html new file mode 100644 index 0000000..7480bfe --- /dev/null +++ b/index.html @@ -0,0 +1,19 @@ + + + +Metube help + + +

Bookmarklets

+Save this bookmarklet in your browser. On a page with the video to save, click the bookmarklet! +
Chrome: +Save to Jellyfin +
Firefox: +Save to Jellyfin +

Status page +

Notes

+On mobile devices, you will need to use the sharing menu from, e.g., the Youtube app, select "Copy link," and then visit the status page and paste the URL. Some mobile devices should be able to save the status page URL on the home page, which is just a dedicated shortcut to this page in a web browser. + + + diff --git a/metube-README.md b/metube-README.md new file mode 100644 index 0000000..59a6bbe --- /dev/null +++ b/metube-README.md @@ -0,0 +1,140 @@ + + +# README for Metube on Internal network +Metube is a web frontent for yt-dlp that makes it convenient to download youtube videos and place them in the Downloads directory for Jellyfin. + +## Upstream +This project's upstream is at . It depends entirely on the third-party upstream [metube](https://github.com/alexta69/metube) project. + +## Installing +The architecture is fairly simple. Vm4 runs the app in docker-compose, and server3 reverse-proxies it for local web requests only. File storage is in the customary nfs export. The web components are served only on the local http/s ports of the web server; they are not supposed to be available to the public. + +### Configuring docker server +Set up a new user on vm4 which already has docker from previous projects. + + sudo useradd metube + sudo usermod -a -G docker metube + sudo su - metube < + Include conf.d/metube.cnf + + + # DO NOT INCLUDE metube on public http vhost + Include conf.d/metube-disabled.cnf + + + Include conf.d/metube.cnf + + + # DO NOT INCLUDE metube on public https vhost + Include conf.d/metube-disabled.cnf + + +Reload httpd after a successful test. + + sudo httpd -t && sudo systemctl reload httpd + +Httpd needs the selinux permission for accessing network ports, which has been enabled already for other projects on this network. + +### Assumptions for Jellyfin +The mode on `/mnt/public/Video/Downloads` is 0777. + +Jellyfin uses real-time monitoring on the library that reads this directory, and that library is content type "Other." + +Jellyfin appears to read the video id at the end of the filename and fetches the .nfo contents! + +## Alternatives +I bookmarked a few alternative projects, primarily in 2022-07 (on system vm2 Firefox bookmarks). + +* **Tested** this one, but it was slightly out of date and had probably minor internal app problems that broke it, and I don't want to fiddle with nodejs code. +* I just don't really care about material design. +* Did not appear to be a Web UI frontend. +* Looked incredibly spartan, even though it is in python which I can hope to understand. +* Not well-documented or otherwise just did not appear interesting. +* Not as slick-looking, but uses python+flask which appeals to me. This **should be my first line** of research if my current solution fails. +* Is a web frontend that resembles youtube itself, but possibly does not provide the yt-dlp functions at all, so belongs in a different category. I tested this, and uploading to it made duplicate files and was just below adequate for that category of usage. + +I actually tested only a few alternatives, which are indicated in the above list. + +## Reason for existence +To provide a simple way to add Internet videos into the local Jellyfin instance so users do not have to go out to the Internet with the possibility of autoplay that goes beyond user acceptability. + +## Using and Operations +Tasks that will probably repeat. + +### Visiting +Visit the main page via one of these following links. The main page is where you can add new videos by url and view current and completed downloads: + + http://vm4:8081/metube/ + https://server3.ipa.internal.com/metube/ + http://server3/metube/ + +Notably, the reverse proxy configuration does not allow external access to `/metube/` path. This is to protect the server from outside access which could be abused more easily. Also, the direct server url is not published. + +### Using +Primarily, you visit the [status page](http://server3/metube/) and paste in a video url. On a mobile device, you can use the sharing menu to copy a link, and then paste it on this page. + +#### Bookmarklets +Upstream provides sample bookmarklets you can save as a browser bookmark. When visiting a video page, you can select this bookmarklet and it will send it to the app. + + Save to Jellyfin + +## Dependencies +Docker, httpd, jellyfin, existing selinux rule on server3 for `httpd_can_connect_network` or similar. + +## Improve +WORKHERE Combine all files into this support dir, and make scm repo and publish. + +## Related files +On vm4 + +* `/home/metube/git/docker-compose.yaml` +* `/etc/systemd/system/metube.service` +* `/usr/lib/firewalld/services/metube.xml` + +On server3 + +* `/etc/httpd/conf.d/metube.cnf` +* `/etc/httpd/conf.d/metube-disabled.cnf` +* `/etc/httpd/conf.d/local_mirror.conf`, just relevant lines +* `/var/server3/shares/public/www/metube-help/index.html` + +## References diff --git a/metube-disabled.cnf b/metube-disabled.cnf new file mode 100644 index 0000000..b7a517a --- /dev/null +++ b/metube-disabled.cnf @@ -0,0 +1,10 @@ +# File: server3:/etc/httpd/conf.d/metube-disabled.cnf +# Startdate: 2023-01-23-2 +# History: +# Usage: +# included in public-facing vhost 180, 444 to simply show "not found" instead of a 403 +# Reference: +# https://stackoverflow.com/questions/1092475/404-error-mod-rewrite-not-working/1092505#1092505 + + RewriteRule "^.*$" "\1" [L,R=404] + diff --git a/metube.cnf b/metube.cnf new file mode 100644 index 0000000..31887b3 --- /dev/null +++ b/metube.cnf @@ -0,0 +1,11 @@ +# File: server3:/etc/httpd/conf.d/metube.cnf +# Startdate: 2023-01-23-2 +# History: +# Usage: +# included in LAN-only vhost 80, 443 but not in public-facing vhost 180, 444 + + RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME} + ProxyPreserveHost on + ProxyPass http://vm4.ipa.internal.com:8081/metube nocanon + ProxyPassReverse http://vm4.ipa.internal.com:8081/metube + diff --git a/metube.service b/metube.service new file mode 100644 index 0000000..e1fcbdb --- /dev/null +++ b/metube.service @@ -0,0 +1,16 @@ +# Startdate: 2023-01-23-2 16:54 +# Project: metube +[Unit] +Description=Metube with docker-compose +Requires=docker.service +After=docker.service + +[Service] +Type=simple +RemainAfterExit=true +WorkingDirectory=/home/metube/git +ExecStart=/bin/docker-compose up -d +ExecStop=/bin/docker-compose stop + +[Install] +WantedBy=multi-user.target diff --git a/metube.xml b/metube.xml new file mode 100644 index 0000000..0289113 --- /dev/null +++ b/metube.xml @@ -0,0 +1,6 @@ + + + metube + Metube is a web ui front-end for yt-dlp which runs in docker-compose. + + -- cgit