Get youtube video title on termux

twitter logo github logo ・1 min read

Intro

The main reason of this tutorial is to share an akward experience I used to have on android and solve it. Sometimes when I share a video from youtube on twitter it only shares the url for the video. I wanted also get the title, so I wrote this script

#!/data/data/com.termux/files/usr/bin/bash

URL=$(termux-clipboard-get)

TITLE=$(youtube-dl --skip-download --get-title --no-warnings $URL | sed 2d | awk '{print tolower($0)}')

echo "$TITLE' '$URL"  | tee termux-clipboard-set


Setting pbcopy and pbpaste using termux

Open your termux and run

apt install termux-api neovim

Now on your termux edit your ~/.bashrc

alias pbcopy='termux-clipboard-get'
alias pbpaste='termux-clipboard-set'
twitter logo DISCUSS
Classic DEV Post from Feb 8

Life Can Be Tough, But We Are DAMN Good at What We Do!

We are problem solvers, thinkers, tinkers, and dreamers. Personal challenges, no matter how severe, can NEVER take that away

Sérgio Luiz Araújo Silva profile image
I am a Free Software enthusiast and a (neo)?vim addicted, I also like shell script, sed, awk, and as you can see I love Regular Expressions.