Last active
January 12, 2022 03:44
-
-
Save kenos1/0a9623ed3a6382b1c8d5807098941cce to your computer and use it in GitHub Desktop.
Simple youtube script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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