This Python script uses the rich
library to search YouTube, display results in a formatted table, and play selected audio with user choice of media player (mpv, mplayer, vlc).
Code Description:
This Python script utilizes the rich
, pytube
, and youtubesearchpython
libraries to create a user-friendly YouTube audio player. It enables users to search for YouTube videos, presents search results in a visually appealing table, and plays the selected audio with a choice of media players (mpv, mplayer, vlc).
Dependencies:
rich
library (for enhanced console output)pytube
library (for YouTube video handling)youtubesearchpython
library (for YouTube video search)- Media players: mpv, mplayer, vlc (for audio playback)
Instructions:
-
Installation:
Ensure you have Python 3.x installed on your system.
Install required Python libraries:
pip install rich pytube youtubesearchpython
Make sure you have one of the supported media players (mpv, mplayer, vlc) installed on your system.
-
Running the Script:
Save the script to a Python file (e.g.,
ytmusic.py
).Open your terminal and navigate to the directory containing the script.
Run the script using the following command:
python ytmusic.py
-
Using the Script:
- Enter a YouTube search query to search for videos.
- Results are displayed in a formatted table.
- Select a video by entering its corresponding number.
- Choose a media player (mpv, mplayer, vlc) for playback.
- Enjoy streaming and listening to audio from YouTube videos.
- Enter 'quit' to exit the script.
This script provides an interactive and visually appealing way to search for YouTube videos and play their audio content with your preferred media player.