From: Jakub Czajka Date: Thu, 23 Nov 2023 23:25:18 +0000 (+0100) Subject: Switch from a python server to nginx + fastcgi. X-Git-Url: https://git.ekhem.eu.org/?a=commitdiff_plain;h=26a9ce500c2e77a46a9ee796b0c8131453fe1985;p=ydlpd.git Switch from a python server to nginx + fastcgi. --- diff --git a/README b/README index 30f3cb5..99183f8 100644 --- a/README +++ b/README @@ -3,17 +3,3 @@ yt-dlp-server HTTP interface for `yt-dlp`. Exposes a GET / endpoint with a HTML form for obtaining download parameters. - -Dependencies ------------- - -* ffmpeg - -Install -------- - -``` -python3 -m venv site-packages -source site-packages/bin/activate -pip install -r requirements.txt -``` diff --git a/download.sh b/download.sh new file mode 100755 index 0000000..29c4f9b --- /dev/null +++ b/download.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# Copyright (c) 2023 Jakub Czajka +# License: GPL-3.0 or later. + +FULL_URL=$(echo ${URL} | sed 's/%3A/:/g ; s/%2F/\//g ; s/%3F/\?/g ; s/%3D/=/g') + +LINK_ID=$(echo ${FULL_URL} | sed 's/^.*\=//') + +# Clear /tmp for download. +if [ -e "/tmp/${LINK_ID}" ] +then + rm -rf "/tmp/${LINK_ID}" +fi + +case "${FORMAT}" in + "video") + EXT=".mp4" + ARGS="--format mp4" + ;; + "audio") + EXT=".ogg" + ARGS="--format 251 --extract-audio --postprocessor-args ar:16000\ + --remux-video ogg --prefer-ffmpeg" + ;; +esac + +echo "HTTP/1.1 200 OK" +echo "Content-Type: text/html" +echo " + + + + + + +" +echo "Downloading ${FULL_URL} as ${FORMAT}" +yt-dlp ${ARGS} --output /tmp/"${LINK_ID}${EXT}" "${FULL_URL}" +echo "\ + +" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index a90ebb6..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -yt-dlp==2023.9.24 diff --git a/server.py b/server.py deleted file mode 100644 index bfc6b76..0000000 --- a/server.py +++ /dev/null @@ -1,169 +0,0 @@ -# Copyright (c) 2023 Jakub Czajka -# License: GPL-3.0 or later. - -import argparse -import os -import re -import tempfile -import urllib.parse -import uuid -import yt_dlp - -from wsgiref.simple_server import make_server - -FORMAT_OPTS = { - 'video': { - 'mime': 'video/mp4', - 'extension': 'mp4', - 'ydl_opts': { - 'format': 'mp4', - } - }, - 'audio': { - 'mime': 'audio/ogg', - 'extension': 'ogg', - 'ydl_opts': { - 'format': '251', - 'postprocessors': [{ - 'key': 'FFmpegExtractAudio', - }], - 'postprocessor_args': [ - '-ar', '16000' - ], - 'prefer_ffmpeg': True - } - } -} - -VIDEO_PARAMETERS_FORM = ''' - - - - YT Download - - - -
-
- - - - - - - - {0} - - - -
-
- - -''' - -YOUTUBE_URL_RE = '(https:\/\/)?(www\.)?youtu(\.be|be\.com)\/watch\?v=([\w\-_]+)' - -def build_form_for_video_parameters(): - formats_as_html = ['