Skip to content

Instantly share code, notes, and snippets.

@kenos1
Last active January 12, 2022 03:44
Show Gist options
  • Save kenos1/0a9623ed3a6382b1c8d5807098941cce to your computer and use it in GitHub Desktop.
Save kenos1/0a9623ed3a6382b1c8d5807098941cce to your computer and use it in GitHub Desktop.
Simple youtube script
#!/bin/bash
rm -f .cache/yt-query .cache/yt-scrap
read -p "Search: " search # Ask for search
search=$(echo $search | sed s/" "/"+"/g)
curl "https://yewtu.be/search?q=type%3Avideo+$search" > ~/.cache/yt-scrap
grep "youtube.com" ~/.cache/yt-scrap | sed -e s/" <a title=\"Watch on YouTube\" href=\""//g -e s/"\">"//g > ~/.cache/yt-query
grep "<p dir=\"auto\"" ~/.cache/yt-scrap | sed -e s/" <p dir=\"auto\">"//g -e s/"<\/p>"//g > ~/.cache/yt-titles
selected_video=$(cat -n ~/.cache/yt-titles | fzf | awk '{print $1}') # video selectiom
video=$(awk "NR==$selected_video{print;exit}" ~/.cache/yt-query) # get video id
mpv $video # play video
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment