DEV Community

tagouli
tagouli

Posted on

How I built a CLI music player in Python and what I learned

After months of learning Python through tutorials, I decided to build something I'd actually use every day and I really want to build instead of todo app.

The result: a command line music player that integrates with the Deezer API, plays audio through yt-dlp and VLC, and stores playlists and favorite artists in a local SQLite database.

What I used:

Deezer API > search artists and songs
yt-dlp > fetch and stream audio
VLC > handle playback controls
SQLite > local database for playlists and favorites
requests > API calls

The interesting part, a bug that taught me something:

When I added the feature to save artists and songs simultaneously, I kept getting a "database locked" error. My first assumption was a missing commit, I was committing twice, once after each insert. Merged them into one commit after both insertions. Same error.

Turned out a previous version during development had left a database connection open. That old process was still running in the background locking the database. Killed the processes, added proper connection closing on exit, fixed immediately.

Lesson: sometimes the bug isn't in the code you're currently looking at, maybe the system or the environment itself.

What's next:

GUI version
Packaging for easy install
Tests

GitHub: https://github.com/Iheb-eng/music-app

Would love any feedback or suggestions.

Top comments (0)