summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2023-01-23 21:05:05 -0500
committerB. Stack <bgstack15@gmail.com>2023-01-23 21:05:05 -0500
commitd2fbe8e7946f087bc50b29d80ac4b89cb75fad87 (patch)
treebd2edebe798ac76ec84ff622829688e08afc6a45
downloadmetube-internal-d2fbe8e7946f087bc50b29d80ac4b89cb75fad87.tar.gz
metube-internal-d2fbe8e7946f087bc50b29d80ac4b89cb75fad87.tar.bz2
metube-internal-d2fbe8e7946f087bc50b29d80ac4b89cb75fad87.zip
initial commit
-rw-r--r--docker-compose.yaml23
-rw-r--r--index.html19
-rw-r--r--metube-README.md140
-rw-r--r--metube-disabled.cnf10
-rw-r--r--metube.cnf11
-rw-r--r--metube.service16
-rw-r--r--metube.xml6
7 files changed, 225 insertions, 0 deletions
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 @@
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<title>Metube help</title>
+</head>
+<body>
+<h1>Bookmarklets</h1>
+Save this bookmarklet in your browser. On a page with the video to save, click the bookmarklet!
+<br/>Chrome:
+<a href='javascript:!function(){xhr=new XMLHttpRequest();xhr.open("POST","https://server3.ipa.internal.com/metube/add");xhr.send(JSON.stringify({"url":document.location.href,"quality":"best"}));xhr.onload=function(){if(xhr.status==200){alert("Sent to metube!")}else{alert("Send to metube failed. Check the javascript console for clues.")}}}();'>Save to Jellyfin</a>
+<br/>Firefox:
+<a href='javascript:(function(){xhr=new XMLHttpRequest();xhr.open("POST","https://server3.ipa.internal.com/metube/add");xhr.send(JSON.stringify({"url":document.location.href,"quality":"best"}));xhr.onload=function(){if(xhr.status==200){alert("Sent to metube!")}else{alert("Send to metube failed. Check the javascript console for clues.")}}})();'>Save to Jellyfin</a>
+<p><a href="/metube/">Status page</a>
+<h1>Notes</h1>
+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.
+</body>
+<footer>
+</footer>
+</html>
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 @@
+<!--
+.. File: metube-README.md
+.. Location: /mnt/public/Support/Programs/metube/
+.. Author: bgstack15
+.. Startdate: 2023-01-23-2 15:54
+.. Title: Readme for Metube on Internal network
+.. Project: metube
+.. Purpose: Document how this was setup and how to use it
+.. History:
+.. Usage: See heading "Usage and Operations"
+.. Reference: See heading References
+.. Improve: See heading Improve
+.. Dependencies: See heading Dependencies
+.. Documentation: This.
+-->
+
+# 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 <http://server3/cgit/metube-internal/>. 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 <<EOF
+git clone https://github.com/alexta69/metube ~/git
+EOF
+
+Establish `/home/metube/git/docker-compose.yaml`
+Establish `/usr/lib/firewalld/services/metube.xml`
+
+ sudo firewall-cmd --reload
+ sudo firewall-cmd --permanent --add-service=metube
+ sudo firewall-cmd --reload
+
+Establish `/etc/systemd/system/metube.service`
+
+ sudo systemctl daemon-reload
+ sudo systemctl enable --now metube.service
+
+### Configuring httpd server
+Establish the following files which do not get included directly by apache httpd.
+
+* `/etc/httpd/conf.d/metube.cnf`
+
+Modify `local_mirror.conf` virtual hosts 80 and 443 to include this new file.
+
+Establish relevant snippets in `/etc/httpd/conf.d/local_mirror.conf`:
+
+ <VirtualHost *:80>
+ Include conf.d/metube.cnf
+ </VirtualHost>
+ <VirtualHost *:180>
+ # DO NOT INCLUDE metube on public http vhost
+ Include conf.d/metube-disabled.cnf
+ </VirtualHost>
+ <VirtualHost *:443>
+ Include conf.d/metube.cnf
+ </VirtualHost>
+ <VirtualHost *:444>
+ # DO NOT INCLUDE metube on public https vhost
+ Include conf.d/metube-disabled.cnf
+ </VirtualHost>
+
+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).
+
+* <https://github.com/Enriquito/youtube-dl-front/> **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.
+* <https://github.com/Tzahi12345/YoutubeDL-Material> I just don't really care about material design.
+* <https://github.com/mikenye/docker-youtube-dl> Did not appear to be a Web UI frontend.
+* <https://github.com/manbearwiz/youtube-dl-server> Looked incredibly spartan, even though it is in python which I can hope to understand.
+* <https://github.com/dockermgr/youtubedl-web> Not well-documented or otherwise just did not appear interesting.
+* <https://github.com/d0u9/youtube-dl-webui> 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.
+* <https://git.mills.io/prologic/tube> 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.
+
+ <a href='javascript:(function(){xhr=new XMLHttpRequest();xhr.open("POST","https://server3.ipa.internal.com/metube/add");xhr.send(JSON.stringify({"url":document.location.href,"quality":"best"}));xhr.onload=function(){if(xhr.status==200){alert("Sent to metube!")}else{alert("Send to metube failed. Check the javascript console for clues.")}}})();'>Save to Jellyfin</a>
+
+## 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
+<Location /metube-help>
+ RewriteRule "^.*$" "\1" [L,R=404]
+</Location>
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
+<Location /metube>
+ 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
+</Location>
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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<service>
+ <short>metube</short>
+ <description>Metube is a web ui front-end for yt-dlp which runs in docker-compose.</description>
+ <port protocol="tcp" port="8081"/>
+</service>
bgstack15