#!/bin/sh -e
#
# Usage:
# ytpl song title
# ytpl < titles
#
go() {
echo "Playing $1"
# Force TTY input for controls even if titles are read from input
echo https://youtu.be/ > tmp1.txt
youtube-dl --get-id "ytsearch:$1" > tmp2.txt
youtube-dl --get-title "ytsearch:$1" > tmp4.txt
paste -d" " tmp1.txt tmp2.txt > tmp3.txt
paste -d" " tmp3.txt tmp4.txt > tmp5.txt
sed 's/ //' tmp5.txt > tmp6.txt
cat tmp6.txt
mpv --vid=no "$(youtube-dl -g "ytsearch:$1" | tail -1)" < /dev/tty
rm tmp*.txt
}
# All arguments as a single space separated string
if [ -n "$*" ]; then
go "$*"
exit
fi
# Read one title per line
while read title; do
go "$title"
done
1
1 ответ
1
echo https://youtu.be/ > tmp1.txt
youtube-dl --get-id "ytsearch:$1" >> tmp1.txt
youtube-dl --get-title "ytsearch:$1" >> tmp1.txt
cat tmp1.txt |tr '\n' ' '|sed 's/ //' > tmp2.txt
cat tmp2.txt
mpv --vid=no "$(youtube-dl -g "ytsearch:$1" | tail -1)" < /dev/tty
rm tmp*.txt
Пример кода 2 Следуйте этим многочисленным инструкциям:http://www.unixmen.com/access-twitter-via-command-line-terminal/
a=$(youtube-dl --get-id "ytsearch:$1")
b=$(youtube-dl --get-title "ytsearch:$1")
c="https://youtu.be/$a $b"
echo $c
t update "$c"
mpv --vid=no "$(youtube-dl -g "ytsearch:$1" | tail -1)" < /dev/tty