Problem

Metadata: Organizing Your iTunesDigitized music such as that managed by iTunes has metadat...

Metadata: Organizing Your iTunes

Digitized music such as that managed by iTunes has metadata such as the name, artist, and so on. Internally, iTunes uses the XML format to manage its metadata, and Python has modules to work with XML, but XML has more complexity than we can deal with in a problem (or even a few chapters). However, using copy-and-paste you can copy your iTunes metadata from the text “list” view of your playlist into your favorite text editor such as TextEdit or WordPad. The result is a file that is tab separated, i.e., fields are separated by the tab character. Because the split() method can take an argument of what to split on, we can split the lines of your text file using line.split(" \t") . Remember that we can specify the tab character with "\t".

What is an appropriate data structure? It is natural to organize music around the artist, and an artist’s name is immutable, so a dictionary is suggested with the artist as the key. The remaining metadata becomes the value of each record. You can read in your metatdata and place it in a dictionary.

Write a program that does the following:

(a) Reads the metadata from a file into a dictionary


(b) Loops to repeatedly prompt for:

i. Name: list all songs by the specified artist.


ii. Album: list all songs on the specified album.


iii. Genre: list all songs in a specified genre.


iv. Add: add a song.


v. Delete: delete a specified song (specify its name).


vi. Popular: find the artist with the most songs in your collection.


vii. Longest: find the longest song in your collection and prints its metadata.

Hint: To sort to find the most popular or longest, you need to convert your dictionary into a data structure that you can sort, such as a list or tuple. Remember that the Python sort will sort on the first item in each list (or tuple), so you will need to arrange your lists appropriately.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 9
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT