Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Metadata: Organizing Your iTunes Digitized music such as that managed by iTunes

ID: 3775359 • Letter: M

Question

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(" "). Remember that we can specify the tab character with " ".

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.

9. C+ 0/4 points l Previous Answers LarCalc10 13.3.075 Find the four second partial derivatives. Observe that the second mixed partials are equal z 4x2 10xy 5y2 02z 0x2 02z 02z 0x0y

Explanation / Answer

private void correctChunkOffsets(IsoFile tempIsoFile, long correction) {
List<Box> chunkOffsetBoxes = Path.getPaths(tempIsoFile, "/moov[0]/trak/mdia[0]/minf[0]/stbl[0]/stco[0]");
for (Box chunkOffsetBox : chunkOffsetBoxes) {

LinkedList<Box> stblChildren = new LinkedList<Box>(chunkOffsetBox.getParent().getBoxes());
stblChildren.remove(chunkOffsetBox);

long[] cOffsets = ((ChunkOffsetBox) chunkOffsetBox).getChunkOffsets();
for (int i = 0; i < cOffsets.length; i++) {
cOffsets[i] += correction;
}

StaticChunkOffsetBox cob = new StaticChunkOffsetBox();
cob.setChunkOffsets(cOffsets);
stblChildren.add(cob);
chunkOffsetBox.getParent().setBoxes(stblChildren);
}
}