Sergey Kiselev
11 months ago
3 changed files with 101 additions and 0 deletions
After Width: | Height: | Size: 17 KiB |
@ -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…
Reference in new issue