About this blog

This is my secondary, extremely-seldomly updated blog about music.

Sunday, November 27, 2011

Song Titles

I'm a rather fastidious record-keeper when it comes to my music collection--I update an annotated chart of my library size by time every few months. I also sometimes look for odder attributes of my music. Today I wrote two simple Python scripts--one to look for the most common song titles in my library, the other to find songs that have the same title, artist name, and album name. To get the music metadata into a form easily readable by Python, I selected my whole library in the main music list of iTunes and copy-pasted it into Excel. (You can do that) I then picked out the columns I needed (title for one; title, artist, and album for the other) and copy-pasted these into tab-separated text files that Python can easily digest. My results are below.

Top 50 Most Common Song Titles

Allegro - 36
Intro - 16
Overture - 15
Andante - 11
Forever - 10
Prelude - 9
Lost - 9
Home - 9
The End - 9
Adagio - 9
Coming Home - 9
Hidden Track - 8
Disappear - 8
Silent Night - 8
Broken - 8
Farewell - 8
Presto - 8
O Holy Night - 8
Beautiful - 7
Revolution - 7
O Come All Ye Faithful - 7
Falling Down - 7
One - 7
Wake Up - 7
Allegro Moderato - 7
Credits - 7
Rain - 7
Tonight - 7
The Promise - 7
Hope - 7
Alive - 7
Believe - 6
Savior - 6
Save Me - 6
Main Menu - 6
Falling - 6
Alone - 6
Grace - 6
Afterlife - 6
Escape - 6
I'm Alive - 6
Free - 6
Scream - 6
Largo - 6
Without You - 6
Revelation - 6
Hero - 6
Sacrifice - 6
Judgment Day - 5
Ganondorf - 5

(I can't say I'm surprised about #1...and I don't even have that much classical music)

Songs with the Same Title, Artist, and Album



Amesoeurs - Amesoeurs - Amesoeurs
Bang Camaro - Bang Camaro - Bang Camaro
Iced Earth - Iced Earth - Iced Earth
Into Eternity - Into Eternity - Into Eternity
Iron Savior - Iron Savior - Iron Savior
Outworld - Outworld - Outworld
Primal Fear - Primal Fear - Primal Fear
Theocracy - Theocracy - Theocracy


For those who are curious, here are the scripts I wrote in about 5 minutes each to do this parsing.

SongNames.py

import sys


topvalues = 50


if len(sys.argv) < 2:
   sys.exit()


filename = sys.argv[1]
counts = dict()


for line in open(filename, 'r'):
   l = line.strip()
   if l in counts:
      counts[l] += 1
   else:
      counts[l] = 1


topcounts = sorted(counts.keys(), key=lambda x: counts[x], reverse=True)


for title in topcounts[:topvalues]:
   print title,'-',counts[title]

SongData.py

import sys


if len(sys.argv) < 2:
   sys.exit()


filename = sys.argv[1]
finds = list()


for line in open(filename, 'r'):
   l = line.strip().split('\t')
   if len(l) == 3 and (l[0] == l[1] == l[2]):
      finds.append("%s - %s - %s" % tuple(l))


print '\n'.join(sorted(finds))

No comments:

Post a Comment