pythiofy music player

I created a Music Player in Python – “Pythiofy”

Music has been there for centuries, We have seen the advancement of music distribution and listening from cassettes, tapes, Radio to CDs, DVDs, and the Internet. In this internet era. We have lots and lots of options from youtube music to online music platforms like Spotify, Jio Saavn, etc.

But, as a proud citizen of Pythonation, It’s our duty to develop instead of just consume. Python is a very great language to develop anything and that’s why I have developed a Music Player in Python, with a very unique name called Pythiofy. Don’t say it sounds similar to. No, there isn’t anything like Pythiofy.

only pythiofy

So, how to make it, well for that, we have to see What do we want to do.

Ingredients for our Pythiofy

  • A music player, which is able to play a song in a folder.
  • The user must be able to select the song.
  • Create a menu and allow the option to choose.
  • The user is greeted with a particular username. Username can be changed also.
  • User can search for a particular song.
  • User can search for a song on the web if can’t find it on local machine.
  • A notification pop up, whenever a song is played.
  • Can download songs from the internet if the user wants.

Those features seems a lot, but believe me, every goal is achievable, Let’s see some code now, and then I will walk you through that.

The making of Pythiofy

from playsound import playsound  # importing playsound module

import pyfiglet  # importing pyufiglet

import os  # importing os

import webbrowser  # importing webbrowser

from notifypy import Notify  # importing notify

ascii_banner = pyfiglet.figlet_format("\t \t \t \t \t Pythiofy ")

f = open('username.txt', 'r')

username =

# MENU for Pythiofy

print(f" \t \t Welcome to Pythiofy {username}")

print("\t1. Tracks ")
print("\t2. Artist ")
print("\t3. Search for some cool shit ")
print("\t4. Download some cool shit ")
print("\t5. Change User")
print("\t6. Exit")

user_input = int(input(f"\tEnter your choice {username} : "))

# Track function to play tracks.

def Tracks():

    path = "e:\\Programming\\Auromation\\Songs"

    songs_list = os.listdir(path)

    for items in songs_list:
        items = items.strip('.mp3')
        print("\t \t ", items)

    count = 0

    for items in songs_list:

        dummy = "xyz.mp3"

        choice = "e:\\Programming\\Auromation\\Songs\\" + dummy


        if count == 0:

            name = input(" \t Enter Track's Name : ")
            name = name + '.mp3'

            index = songs_list.index(name)

        choice = choice.replace(dummy, songs_list[index])

        play_name = songs_list[index]

# Notification function for creating and delivering notifications

        def Notification():

            notification = Notify()
            notification.title = "Pythiofy"
            notification.message = f"Now Playing: {play_name}"
   = "e:\\Programming\\Auromation\\Notifications\\nigga.wav"
            notification.icon = "E:\\Programming\\Auromation\\Icons\\logo.png"



        print(f"\t\t Now Playing: {play_name}")
        print("\t\t Artist: Unknown")
        print("\t\t Album: Unknown")



        songs_list[index] = songs_list[index + 1]

        count = count + 1


# Search function for searching the local machine as well the internet

def Search():


        path = "e:\\Programming\\Auromation\\Songs"
        songs_list = os.listdir(path)
        find = input(" \tSearch: ")
        find = find + '.mp3'
        index = songs_list.index(find)

        print("\t ", songs_list[index])
        print(" \t Do you want to play the Track ?")

        yes = 'yes'
        play = input(" \t Type Yes or No:  ")

        if play == yes:
            print(" \t That's Fine Man, Keep Rocking !!!")


        print("\t No Tracks Found !!! ")
        print("\t Do you want to search the Web ?")

        yes = 'yes'
        play = input(" \t Type Yes or No:  ")

        if play == yes:
            find = find.strip('.mp3')
            url = ''
   + find)
            print("\t That's Fine Man, Keep Rocking !!!")

# Download function to download a track from a mp3 website

def Download():

    dwld = input("\tEnter Track to Download: ")

    download_url = ''

    webbrowser.open_new_tab(download_url + dwld)

# creating the options for MENU

if user_input == 1:
    print("\t\t TRACK LIST")

elif user_input == 2:
    print("\t\t No Artists Found ")

elif user_input == 3:

elif user_input == 4:

elif user_input == 5:

    user = input("\tEnter Username: ")
    f = open('username.txt', 'w')

elif user_input == 6:

hold = input()
if hold == exit:
    print("\t \t Thanks for using Pythiofy ")

pythiofy menu

pythiofy tracks

track playing

We start with importing certain modules in our program. The first is Playsound, which can be installed using “pip install playsound” for more CLICK HERE. Then we have Pyfiglet module for ASCII, it’s just for design purposes. Then we have the OS module, which helps us to manipulate files and directories on the system level. Then we have Web Browser, it’s simply to trigger browser and do stuff related to the internet and at last, we have the notify module for our Notification.

Next, we use file handling to open the file and see the username inside, and then we got the menu. Pretty standard stuff. Then the user can enter a song name to Play.

Now let’s move ahead. Now here’s the catch. Playsound module lets you play a song in a folder with a specified path. But it is very very basic, which means you can’t make a music player with that. Because it has zero functionality beyond playing a single mp3 file, But we are making our whole project on that, then how’s that possible. It’s possible, we have to make our own logic to extend its compatibility and features and the Track function just does the same.

First, we store our path’s name, then we store the list of songs using os.listdir which lists all the files in a list on a given path. Now we make a dummy variable which says xyz.mp3 as we know our file will be mp3. Then we use a for loop to add the dummy to the path. Now, we let the user enter the name of the song, then we use the list method index to find the index of the song in the list, and then we use the replace method of string to replace dummy variable in the path to the name of the song. As we know, playsound is capable of playing a song within a path, and we can now do it using the song name.


Next, we have a Notification function for our notification whenever our song will play. We specify the notification named “notification”. Then we specify the title, message, audio, and icon. And then we send it, block = False will force the notification, without the fear of being blocked.

search tracks

search web
song search on youtube

Next, we have the search function. First, it will search the track for you by looking at the folder for specific names. If found, it will ask you if you want to play it or not. If it doesn’t find you it will ask you to search the web. If yes, it will open up a browser using a browser module, use a youtube URL string and add our search name in order to search.


download from web

Now we have the Download function, it uses the same browser module technique and search a website for the song to download on your system.

At last, we have the menu options, which do whatever is specified there. One thing here is the username change option, which uses basic file handling here.

Well, that’s with the explanation of code, if you want to download this little Project. You can do that using the download button below.

Pythiofy for life

So, that was our little project called Pythiofy, a music player in python. The main thing in this project here is the use of basic modules to make them work according to your logic and needs. Hope you find it interesting, I recently made a GUESS GAME in python, Check it out HERE. And if you want to learn python, CLICK HERE. So on that note, this is Dolores Haze, signing off, I will meet you in next one, till then “Happy Coding” and Bye.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top