Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use mutagen to get unsynced lyrics from an MP3 file.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"[u'APIC:',\n",
" u'PRIV:AverageLevel:{!\\x00\\x00',\n",
" u'PRIV:PeakValue:\\xa1\\x7f\\x00\\x00',\n",
" 'TALB',\n",
" 'TCMP',\n",
" 'TCOM',\n",
" 'TCON',\n",
" 'TCOP',\n",
" 'TDOR',\n",
" 'TDRC',\n",
" 'TEXT',\n",
" 'TIT2',\n",
" 'TMED',\n",
" 'TPE1',\n",
" 'TPE2',\n",
" 'TPOS',\n",
" 'TPUB',\n",
" 'TRCK',\n",
" 'TSO2',\n",
" 'TSOP',\n",
" 'TSSE',\n",
" u'TXXX:ASIN',\n",
" u'TXXX:BARCODE',\n",
" u'TXXX:CATALOGNUMBER',\n",
" u'TXXX:MusicBrainz Album Artist Id',\n",
" u'TXXX:MusicBrainz Album Id',\n",
" u'TXXX:MusicBrainz Album Release Country',\n",
" u'TXXX:MusicBrainz Album Status',\n",
" u'TXXX:MusicBrainz Album Type',\n",
" u'TXXX:MusicBrainz Artist Id',\n",
" u'TXXX:MusicBrainz Release Group Id',\n",
" u'TXXX:SCRIPT',\n",
" u'UFID:http://musicbrainz.org',\n",
" u\"USLT::'eng'\",\n",
" u'WXXX:']"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from mutagen.mp3 import MP3\n",
"file = '/mnt/Entertainment/Music/#Soundtracks/Bollywood/Rang De Basanti/03 Paathshala, Part 1.mp3'\n",
"tags = MP3(file)\n",
"sorted(tags.keys())"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\"say Hoi Ho Oh Hoi Ho (x2)\r\n",
"\r\n",
"Loose Control\r\n",
"\r\n",
"Be A Rebel\r\n",
"\r\n",
"To The Mahal Of The Taj\r\n",
"To The Minar Of Qutub\r\n",
"To The Kumari Of Kanya (say Hoi Oh Hoi)\r\n",
"To The Panjim Of Goa (say Hoi Oh Hoi)\r\n",
"To The Kaancheepuram\r\n",
"Zindabad Zindagood\r\n",
"All Have Something To Say (say Hoi Oh Hoi)\r\n",
"They All Have Something To Say\r\n",
"They All Have Something To Say\r\n",
"\r\n",
"Follow Me Follow Me Follow Me Now!\r\n",
"\r\n",
"Apni Tho Paatshala, Masti Ki Paatshala\r\n",
"Be A Rebel\r\n",
"\r\n",
"Chorus:\r\n",
"Naa Koi Padne Waala, Naa Koi Seekne Wala\r\n",
"Naa Koi Padne Waala, Naa Koi Seekne Wala\r\n",
"Apni Tho Paatshala, Masti Ki Paatshala\r\n",
"Apni Tho Paatshala, Masti Ki Paatshala\r\n",
"Loose Control\r\n",
"\r\n",
"India And Pakistan\r\n",
"Bangladesh All In The Soul\r\n",
"Khajuraho To Coimbatore\r\n",
"Say Hoi Oh Hoi\r\n",
"(say Hoi Hoh Hoi)\r\n",
"\r\n",
">from The Gateway Of India\r\n",
"Upto The Himalayas\r\n",
"Across The Ganga Yamuna\r\n",
"Say Hoi Oh Hoi\r\n",
"(say Hoi Hoh Hoi)\r\n",
"\r\n",
"To Shirdi To The Red Fort\r\n",
"Rourkela Yeah U Know\r\n",
">from Ajmer To Orissa\r\n",
"Say Hoi Oh Hoi\r\n",
"(say Hoi Hoh Hoi)\r\n",
"\r\n",
"Loose Control\r\n",
"\r\n",
"Be A Rebel\r\n",
"\r\n",
"Amar Akbar Antony\r\n",
"Ram Rahim Abdullah\r\n",
"Searching For A Bright Star\r\n",
"Say Hoi Oh Hoi\r\n",
"(say Hoi Hoh Hoi)\r\n",
"\r\n",
"To The Corners Of The Earth\r\n",
"What Is Our (search??) Worth?\r\n",
"What Is Our Destiny?\r\n",
"Say Hoi Oh Hoi\r\n",
"(say Hoi Hoh Hoi)\r\n",
"\r\n",
"Imagine We Go Back In Time\r\n",
"Free Your Soul, Free Your Mind\r\n",
"Take A Look What Do You Find?\r\n",
"Say Hoi Oh Hoi\r\n",
"(say Hoi Hoh Hoi)\r\n",
"\r\n",
"Loose Control\r\n",
"One More Time!!\r\n",
"Loose.. Loose..\r\n",
"Loose Control\r\n",
"Haha (x3)!!\r\n",
"\r\n",
"Be A Rebel\r\n",
"\r\n",
"- www.Songs4you.net\n"
]
}
],
"source": [
"lyrics = tags[\"USLT::'eng'\"]\n",
"print(lyrics.text)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment