def get_details_letssingit(song_name):
'''
Gets the song details if song details not found through spotify
'''
song_name = improvename.songname(song_name)
url = "http://search.letssingit.com/cgi-exe/am.cgi?a=search&artist_id=&l=archive&s=" + \
quote(song_name.encode('utf-8'))
html = urlopen(url).read()
soup = BeautifulSoup(html, "html.parser")
link = soup.find('a', {'class': 'high_profile'})
try:
link = link.get('href')
link = urlopen(link).read()
soup = BeautifulSoup(link, "html.parser")
album_div = soup.find('div', {'id': 'albums'})
title_div = soup.find('div', {'id': 'content_artist'}).find('h1')
try:
lyrics = soup.find('div', {'id': 'lyrics'}).text
lyrics = lyrics[3:]
except AttributeError:
lyrics = ""
log.log_error("* Couldn't find lyrics", indented=True)
try:
song_title = title_div.contents[0]
song_title = song_title[1:-8]
except AttributeError:
log.log_error("* Couldn't reset song title", indented=True)
song_title = song_name
try:
artist = title_div.contents[1].getText()
except AttributeError:
log.log_error("* Couldn't find artist name", indented=True)
artist = "Unknown"
try:
album = album_div.find('a').contents[0]
album = album[:-7]
except AttributeError:
log.log_error("* Couldn't find the album name", indented=True)
album = artist
except AttributeError:
log.log_error("* Couldn't find song details", indented=True)
album = song_name
song_title = song_name
artist = "Unknown"
lyrics = ""
match_bool, score = matching_details(song_name, song_title, artist)
return artist, album, song_title, lyrics, match_bool, score
评论列表
文章目录