Sunday, November 30, 2014

Reading ID3 tags using python

A server-side python code that is still under progress:

#! "C:/Python27/python.exe"
# -*- coding: UTF-8 -*-

# enable debugging

from mutagen.id3 import ID3, TIT2

print """Content-Type: text/html\n\n"""
print """<!DOCTYPE html><html><head><title>Python Programming on Server-side</title></head><body><h1>Music Album Details</h1>"""


audio_file_location = "audioFiles/Sleep Away.mp3"
audio_handler = ID3(audio_file_location)
print ("Work Title : " + audio_handler['TIT2'][0] + "\n" )
print """<br />"""


print ("Track Number : " + audio_handler['TRCK'][0] +"\n")
print """<br />"""
print ("Album Name 1: " +audio_handler['TALB'][0] +"\n")
print """<br />"""
print ("Year of Recording : " +audio_handler['TDRC'][0] +"\n")
print """<br />"""
print ("DDMM Recording: " +audio_handler['TDAT'][0] +"\n")
print """<br />"""
print ("Encoded By : " +audio_handler['TENC'][0] +"\n")
print """<br />"""
print ("Comments : " +audio_handler['COMM'][0] +"\n")
print """<br />"""
print ("Artist Name : " + audio_handler['TPE1'][0] + "\n")
print """<br />"""
print ("Genre Name : " +audio_handler['TCON'][0] +"\n")
print """<br />"""
print ("Copyright : " +audio_handler['TCOM'][0] +"\n")

audio_handler.add(TIT2(encoding=3, text=u"test"))
audio_handler.add(TPE1(text=u"test"))
audio_handler.save()

print """</body></html>"""


Following resources were useful while writing this code:




No comments:

Post a Comment