DEV Community

Naman sharma
Naman sharma

Posted on

find youtube videos in just 2 lines of python.

for this tutorial we will use pywhatkit library
you can install it by

pip install pywhatkit
Enter fullscreen mode Exit fullscreen mode
import pywhatkit
pywhakit.playonyt('godzilla eminem')
Enter fullscreen mode Exit fullscreen mode

and done.
if you don't want to open it in browser so just set open_video to False, just like this:-

import pywhatkit
print(pywhatkit.playonyt('godzilla eminem',open_video=False))
Enter fullscreen mode Exit fullscreen mode

Discussion (2)

Collapse
chemacortes profile image
Chema Cortés

There is a typo with the name of module. It miss a 't', as import pywhatkit.

Collapse
naman23coder profile image
Naman sharma Author

Corrected :-)