diff options
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | yts | 4 |
2 files changed, 3 insertions, 3 deletions
@@ -1,6 +1,6 @@ # ytsearch -ytsearch is a shell script that searches a query in youtube and displays the link and the title of the videos in dmenu, you can then select the video to open in your browser. +ytsearch is a shell script that searches a query in youtube and displays the link and the title of the videos in dmenu, you can then select the video to open in your browser. You can also change the browser to mpv instead or use yt-dlp to download the video. ## Requirements @@ -1,7 +1,7 @@ #!/bin/sh query=$(printf "" | dmenu -p "Search: " | sed 's/\ /+/g' ) -videos=$(curl -sL "https://www.youtube.com/results?search_query=${query}" | sed 's/},{/\n/g' | sed -nE 'N;N; s@.*\"videoRenderer\":\{\"videoId\":\"(.{11})\".*\"title\":\{\"runs\":\[\{\"text\":\"(.{1,100})\"\}\],.*@www.youtube.com/watch?v=\1 | \2@p') +videos=$(curl -sL "https://www.youtube.com/results?search_query=${query}" | sed 's/},{/\n/g' | sed -nE 'N;N; s@.*\"videoRenderer\":\{\"videoId\":\"(.{11})\".*\"title\":\{\"runs\":\[\{\"text\":\"(.{1,100})\"\}\],.*@https://www.youtube.com/watch?v=\1 | \2@p') url=$(printf "%s" "${videos}" | dmenu -i -l 15) [ -z "${url}" ] && exit -${BROWSER} "$(printf "%s" "${url}" | grep -Po '^.{35}')" +${BROWSER} "$(printf "%s" "${url}" | cut -d' ' -f1)" |