Quem poderia simplificar este script melhor do que o que é ?, em relação principalmente aqueles tmp's

1
#!/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
    
por user3287029 26.02.2016 / 00:33

1 resposta

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

Exemplo de código 2 Siga estas instruções: link

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
    
por 26.02.2016 / 01:15