I have found a nice way to search the YouTube website and play search results on the Linux command line. Firstly, install ytdl with Python.
╭──(john㉿DESKTOP-PF01IEE)───╮
╰───────────────────────────╾╯(/mnt/g)-(172.29.65.152)┋ pip install ytdl
Defaulting to user installation because normal site-packages is not writeable
Collecting ytdl
Downloading ytdl-1.0.0rc5-py3-none-any.whl (9.2 kB)
Collecting bella<3.0.0,>=2.1.5 (from ytdl)
Downloading bella-2.1.6-py3-none-any.whl (9.1 kB)
Collecting fire<0.4.0,>=0.3.1 (from ytdl)
Downloading fire-0.3.1.tar.gz (81 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 81.2/81.2 kB 1.7 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting python-youtube<0.7.0,>=0.6.0 (from ytdl)
Downloading python_youtube-0.6.4-py3-none-any.whl (39 kB)
Collecting pytube3<10.0.0,>=9.6.4 (from ytdl)
Downloading pytube3-9.6.4-py3-none-any.whl (38 kB)
Collecting ujson<6.0.0,>=5.4.0 (from bella<3.0.0,>=2.1.5->ytdl)
Downloading ujson-5.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (8.7 kB)
Collecting enum34 (from fire<0.4.0,>=0.3.1->ytdl)
Downloading enum34-1.1.10-py3-none-any.whl (11 kB)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from fire<0.4.0,>=0.3.1->ytdl) (1.16.0)
Collecting termcolor (from fire<0.4.0,>=0.3.1->ytdl)
Downloading termcolor-2.3.0-py3-none-any.whl (6.9 kB)
Collecting dataclasses-json<0.6.0,>=0.5.2 (from python-youtube<0.7.0,>=0.6.0->ytdl)
Downloading dataclasses_json-0.5.14-py3-none-any.whl.metadata (22 kB)
Collecting isodate<0.7.0,>=0.6.0 (from python-youtube<0.7.0,>=0.6.0->ytdl)
Downloading isodate-0.6.1-py2.py3-none-any.whl (41 kB)
Then, once you have it installed, use mpv and ytdl to search YouTube and play the first search result.
╭──(john㉿DESKTOP-PF01IEE)───╮
╰───────────────────────────╾╯(/mnt/g)-(172.29.65.152)┋ mpv ytdl://ytsearch:doom2
Playing: https://www.youtube.com/watch?v=PRI2rTwvWfk
(+) Video --vid=1 (*) (vp9 1920x1080 59.940fps)
(+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
Subs --sid=1 --slang=cs 'Czech' (webvtt) (external)
Subs --sid=2 --slang=en 'English' (webvtt) (external)
Subs --sid=3 --slang=es-419 'Spanish (Latin America)' (webvtt) (external)
Subs --sid=4 --slang=fr 'French' (webvtt) (external)
Subs --sid=5 --slang=it 'Italian' (webvtt) (external)
Subs --sid=6 --slang=ko 'Korean' (webvtt) (external)
Subs --sid=7 --slang=ru 'Russian' (webvtt) (external)
File tags:
Uploader: Civvie 11
Channel_URL: https://www.youtube.com/channel/UC21uZkfXpT8rPY-gPgMiCwA
[W][01435.932928] pw.conf | [ conf.c: 1016 try_load_conf()] can't load config client-rt.conf: No such file or directory
[E][01435.932954] pw.conf | [ conf.c: 1045 pw_conf_load_conf_for_context()] can't load config client-rt.conf: No such file or directory
AO: [pulse] 48000Hz stereo 2ch float
VO: [gpu] 1920x1080 yuv420p
AV: 00:00:06 / 00:31:53 (0%) A-V: 0.357 Cache: 4.8s/3MB
Audio/Video desynchronisation detected! Possible reasons include too slow
hardware, temporary CPU spikes, broken drivers, and broken files. Audio
position will not match to the video (see A-V status field).
AV: 00:00:21 / 00:31:53 (1%) A-V: 3.699 Cache: 23s/8MB
Exiting... (Quit)
Or listen to some dark Ambient music with audio only.
╭──(john㉿DESKTOP-PF01IEE)───╮
╰───────────────────────────╾╯(/mnt/g)-(172.29.65.152)┋ mpv --no-video ytdl://ytsearch:'dark ambient'
Playing: https://www.youtube.com/watch?v=3TnGiZLxb5U
(+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
[W][01771.133591] pw.conf | [ conf.c: 1016 try_load_conf()] can't load config client-rt.conf: No such file or directory
[E][01771.133615] pw.conf | [ conf.c: 1045 pw_conf_load_conf_for_context()] can't load config client-rt.conf: No such file or directory
AO: [pulse] 48000Hz stereo 2ch float
A: 00:00:15 / 00:50:05 (1%) Cache: 14s/612KB
Exiting... (Quit)
This is a very interesting trick for a Linux user, this means that it is possible to listen to a YouTube music video on the command line.