Love it or hate it. Those are the only two terms I hear from people about iTunes. This article isn’t going to debate the pro’s and con’s of using iTunes. No matter which camp you are in, there is one undeniably missing feature – library statistics. With statistics generated from your library, you can learn a few things about yourself. I’ve used a couple of tools in the past, and even tried some different library management software that include some basic statistics. None kept my attention for various reasons ranging from size, ease of use, Java requirements, or simply not enough detail. This article explores the implementation of a standalone statistics generator that meets my needs.
To create this application, which I have called iStats, I had only a few requirements:
- Must be pleasing to look at (nice colorful graphs).
- Must be quick (short run time).
- Must be easy to invoke (as easy as launching a program).
The tools and resources I used:
- Atom editor – Very extensible, very easy to use. (https://atom.io)
- HTML5 – HyperText Markup Language (https://www.w3schools.com/html/html5_intro.asp)
- CSS – Cascading Style Sheets (https://www.w3schools.com/Css/)
- chart.js – Charting library (http://www.chartjs.org)
- list.js – List library (http://listjs.com)
The application once launched:
Use the “Choose file” button to open a native file selector. Locate and select the iTunes library XML file (“iTunes Music Library.xml” on a Mac):
Once processing is complete, about 10 seconds for my library of 6,700 songs, the page is rendered. At the top are three list sections. These were generated into the DOM using the “list.js” library. The first (leftmost) column are the overall library statistics. The second (middle) column are the statistics related to play counts. The third (right) column are statistics related to skip counts. The lists are ordered such that related items are on the same row:
The remainder of the page is consumed by graphs. A few examples follow. At the bottom of this article is a PDF of an entire iStats page where you can see all the graphs, and the iStats source code.
Notice the call out here. Hovering over a bar on the graph shows the exact value:
This happens to be the last graph of the page. It shows a timestamp of when the page was generated:
Example PDF of entire iStats output:
The code could stand to be tightened up. There is plenty of room for code re-use. I got it to the point where it does what I want and works, but I haven’t cleaned it up. iStats is being released under the Simplified BSD License. Feel free to use, modify and improve.
Link to the zip file containing everything you need (hosted at Google Drive): iStats.zip