Video Demo: https://youtu.be/rwQIOUpbqPY
This is a playlist application for your songs which is made using python programming language. The users can persistently store their favourite songs using this playlist. This playlist provides features to view your stored songs, add a song to your playlist, edit song name or artist name or both, delete a song in the playlist or clear list which deletes all songs in the user's playlist.
This playlist uses a .csv
file named playlist.csv
to store the playlist data which is used by programe to view, add, edit, delete and clear songs in playlist
The project.py
file is the main programe and it contains the all the code of the playlist and features. Below is the description and explaination for all the function in `project.py file.
-
main: The main function contains a list variable named
list
and an int variable namedid
initialized to 0. The programme edits or maipulates thislist
variable according to user's input and then writes or rewritesplaylist.csv
file with the data of the list variable to persistently store the playlist data. Theid
variable is the id of the song in the playlist and the programme references this id which is associated with songs to manipulate songs.The main function creates the
playlist.csv
file if it is not present in the project's directory else it just store data inplaylist.csv
file to thelist
variable.The main function runs the programme in an infinite loop and the loop breaks when the user enters the exit key. Starting of this loop there is Playlist Menu which asks user for their input and shows menu in form of tables using
tabulate
library, apart from this, the infinite loop calls the functions to perform the task directed by the user. -
view_playlist: The
view_playlist
function displays the songs in thelist
variable in the form of tables usingtabulate
library. -
add_song: The
add_song()
function add a new song to the playlist. It takeslist
andid
variable along with user entered song and artist and returns an incremented value ofid
variable by 1. -
compile_csv: The
compile_csv()
function takes thelist
variable and rewritesplaylist.csv
file with the data oflist
variable. -
edit_song: The
edit_song()
function takeslist
variable, anedit_id
and anew_song
both provided by the user. It then replaces the song in thelist
variable whose id matches with theedit_id
with thenew_song
. It returns the editedlist
variable.Throws error if there is no song whose id matches with
edit_id
. -
edit_artist: The
edit_artist()
function takeslist
variable, anedit_id
and anew_artist
both provided by the user. It then replaces the artist in thelist
variable whose id matches with theedit_id
with thenew_artist
. It returns the editedlist
variable.Throws error if there is no artist whose id matches with
edit_id.
-
edit_list: The
edit_list()
function takeslist
variable andchoice
provided by the user and callsedit_song
,edit_artist
or both according thechoice
provided by the user and returns the value returned by these functions. It also returns an unchangedlist
variable if user cancels edit or if the value ofchoice
is invalid.Throws error if
edit_id
does not match id of the song or artist on thelist
variable. -
delete_song:
The delete_song()
function takeslist
variable anddelete_song_id
which is provided by the user and then deletes the song whose id matches withdelete_song_id
in thelist
variable and then decrement id of all the songs below the deleted song by 1. Then it calls thecompile_csv()
function to update the playlist. Throws error if there is no song whose id matches withdelete_song_id
. -
clear_list: The
clear_list()
function takes thelist
variable and deletes elements from second index or second element to the end index. It then callscompile_csv
function and returns this edited list and an int whose value is 1.
This file contains functions which tests all function in project.py
file except edit_list
and main
function.
Contains dependencies for the project to run.