from urllib.request import urlopen
from urllib.parse import quote
from xml.dom import minidom

def lyrics(artist, song):
	# url = "http://lyrics.wikia.com/api.php?artist={}&song={}&fmt=xml".format(quote(artist), quote(song))
	url = "http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist={}&song={}".format(quote(artist), quote(song))
	connection = urlopen(url)
	document = minidom.parse(connection)
	connection.close()
	
	for lyric in document.getElementsByTagName("Lyric"):
		text = lyric.firstChild.nodeValue
		return text
	
	return False

if __name__ == "__main__":
	try:
		text = lyrics("Black Sabbath", "Iron Man")
		print(text)
	except ConnectionResetError as error:
		print(error)
	
	input() # pridano na konec zdrojaku, aby se okno nezaviralo
