Browse Source

Added ytdl-gui - a GUI-wrapper for yt-dlp for playing videos in external mediaplayer

master
Sergey Kiselev 11 months ago
parent
commit
7dd0514c2c
  1. 13
      README.md
  2. BIN
      images/ytdl-gui.png
  3. 88
      ytdl-gui

13
README.md

@ -35,3 +35,16 @@ __scrn-sht__
--- ---
__ytdl-gui__
![](images/ytdl-gui.png)
GUI-обёртка над `www/yt-dlp` для воспроизведения видео с [RuTube](https://rutube.ru) и других видеохостингов с помощью [mpv](https://mpv.io/).
Для работы скрипта требуются следующие утилиты:
- `yt-dlp` (`www/yt-dlp`);
- `yad` (`x11/yad`);
- `mpv` (`multimedia/mpv`)
---

BIN
images/ytdl-gui.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

88
ytdl-gui

@ -0,0 +1,88 @@
#!/bin/sh
TMP="${HOME}/.local/tmp"
KEY=$(( $$ ))
FIFO="${TMP}/${KEY}.fifo"
_OPT="${TMP}/${KEY}.opt"
_URL="${TMP}/${KEY}.url"
_F="$( cat <<'EOF'
video_data() {
if [ -n "${1}" ]; then
TITLE="$( yt-dlp --no-warnings --get-title "${1}" )"
RESOLUTIONS="$( \
yt-dlp --no-warnings --list-formats "${1}" | \
grep -v "audio" | \
awk '$2=="mp4" {print $3}' | uniq | \
awk -F'x' 'ORS="p" {print "!"$2}' | \
cut -c 2- \
)"
echo "${TITLE}" >"${FIFO}"
echo "${RESOLUTIONS}" >"${FIFO}"
echo "" >"${FIFO}"
echo "" >"${FIFO}"
echo "" >"${FIFO}"
else
echo "Empty" >"${FIFO}"
echo "" >"${FIFO}"
echo "" >"${FIFO}"
echo "" >"${FIFO}"
echo "" >"${FIFO}"
fi
}
EOF
)"
export FIFO
export _F
mkfifo "${FIFO}"
( yad --plug="${KEY}" --tabnum=2 --form \
--cycle-read \
--separator=";" \
--field="Title::RO" \
--field="Resolution::CB" \
--field="On-Top:CHK" \
--field="Without borders:CHK" \
--field="On all workspaces:CHK" <"${FIFO}" | cut -d';' -f2-) >"${_OPT}" &
exec 3> "${FIFO}"
printf "\n\n\n\n\n" >"${FIFO}"
( yad --use-interp="/bin/sh -c '%s'" \
--plug="${KEY}" --tabnum=1 \
--image="youtube" --text="<b>Type the URL of the video</b>" \
--separator=";" \
--form --columns=1 \
--field="Video URL:" \
--field='Get info!gtk-find!:FBTN' \
"" 'eval "${_F}";video_data "%1"' | cut -d';' -f1 ) >"${_URL}" &
yad --paned --key="${KEY}" \
--tab="" --tab="Info" \
--window-icon="youtube" \
--title="yt-dlp GUI for mpv" \
--geometry=480x320 --center
URL="$( cat "${_URL}" )"
RES="$( cat "${_OPT}" | cut -d';' -f1 | sed 's/.$//' )"
OPTS="--no-terminal"
for i in $( seq 2 4 ); do
if [ "$( cat ${_OPT} | cut -d';' -f${i} )" == "TRUE" ]; then
case ${i} in
2) OPTS="${OPTS} --ontop" ;;
3) OPTS="${OPTS} --no-border" ;;
4) OPTS="${OPTS} --on-all-workspaces" ;;
esac
else
fi
done
if [ -n "${URL}" ]; then
mpv ${OPTS} --ytdl-format="bv*[height<=${RES}]+ba/b[height<=${RES}] / wv*+ba/w" "${URL}" &
fi
rm -f "${FIFO}" "${_OPT}" "${_URL}"
Loading…
Cancel
Save