Metadata Organizing Your iTunes Write a PYTHON program that

Metadata: Organizing Your iTunes

Write a PYTHON 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

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 texteditor 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\".

Solution

import win32com.client sh=win32com.client.gencache.EnsureDispatch(\'Shell.Application\',0) ns = sh.NameSpace(r\'m:\\music\\Aerosmith\\Classics Live!\') colnum = 0 columns = [] while True: colname=ns.GetDetailsOf(None, colnum) if not colname: break columns.append(colname) colnum += 1 for item in ns.Items(): print (item.Path) for colnum in range(len(columns)): colval=ns.GetDetailsOf(item, colnum) if colval: print(\'\\t\', columns[colnum], colval)
Metadata: Organizing Your iTunes Write a PYTHON program that does the following: (a) Reads the metadata from a file into a dictionary (b) Loops to repeatedly pr

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site