Have you ever had such terrible RAM that you literally cannot stream any music on YouTube? Here's an alternative if you're streaming from a potato - a Spotify/YouTube-esque music player that you can operate right from your CLI (Powershell, Bash, Zsh, CMD, etc)
This is a simple (could be unnecessary) command-line application built using Python, where you can store a bunch of songs and their URLs from a YouTube playlist into a .txt file, and control the playback using CLI commands.
'Hacker-oriented' project right here. It gives you the following ;
Zero tolerance for search buttons, and
Enormous hate for modern GUIs
P.S.: You'll need internet connection because the music is streamed from YouTube using yt-dlp
and python-vlc
With this overkill tool you can play, pause, skip, and manage songs. The libraries python-vlc
and yt-dlp
are used for audio playback & for downloading YouTube audio streams, respectively. You can play a specific song based on its index (think of the songs arranged in an array), without having to use YouTube's GUI and even skip ads!
- Command-line interface
- Play songs from a playlist of YouTube URLs.
- Pause and resume playback.
- Skip to the next song
- Go back to the previous song.
- Display the metadata of the song playing.
- List all songs in the playlist.
- Python 3.9 or higher
- VLC Media Player (if you don't have it already then they should confiscate your PC)
python-vlc
libraryyt-dlp
library
-
Clone repository:
git clone https://github.com/yourusername/music_player.git cd music_player
-
Install required Python libraries:
pip install python-vlc yt-dlp
-
Install VLC Media Player(Optional):
- Download and install VLC from the official VLC website. Ensure that VLC is added to your system's PATH (this is usually done automatically during installation).
-
Create a
songs.txt
file and put a bunch of YouTube URLs of the songs you want to play, one URL per line. For example:https://www.youtube.com/watch?v=bnc7hO8UGXU https://www.youtube.com/watch?v=Yhivl6fln3s
-
Run the music player:
python music_player.py
-
Commands to control playback:
-
play <index>
: Play the song at the specified index (e.g.,play 0
). -
pause
: Pause the currently playing song. -
resume
: Resume the currently paused song. -
next
orskip
: Skip to the next song in the playlist. -
previous
orpr
: Go back to the previous song. -
stop
: Stop the currently playing song. -
show status
orss
: Display the current song's metadata (title, index, status). -
list songs
orls
: List all songs in the playlist. -
help
orh
: Show available commands. -
exit
orq
: Exit the music player.
-
-
To play the first song (index = 0):
play 0
-
To pause the current song:
pause
-
To skip to the next song:
next
-
To go back to the previous song:
previous
-
To list all songs in the playlist:
list songs
To ensure that all functionalities work correctly, you can run the provided test suite using unittest
.
- Run the tests:
python -m unittest test_music_player.py
This tool is provided for personal use only. Users are responsible for complying with YouTube's Terms of Service and all applicable copyright laws. The script facilitates playback of YouTube content through legal open-source tools (mpv and youtube-dl) but does not download, store, or redistribute any copyrighted content. Please respect content creators' rights and YouTube's terms of service when using this tool.
This project is licensed under the MIT License. See the LICENSE file for details.