Upload files to ''
This commit is contained in:
parent
daba81de06
commit
28b6263ac3
|
@ -0,0 +1,36 @@
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
import requests
|
||||||
|
from requests import get
|
||||||
|
|
||||||
|
def getLink(artist, title):
|
||||||
|
base_start = 'https://www.azlyrics.com/lyrics/'
|
||||||
|
artist = artist.lower()
|
||||||
|
artist = artist.replace(' ', '')
|
||||||
|
artist = artist.replace('-', '')
|
||||||
|
title = title.lower()
|
||||||
|
title = title.replace(' ', '')
|
||||||
|
title = title.replace('?', '')
|
||||||
|
title = title.replace("'", '')
|
||||||
|
link = base_start + artist + '/' + title + '.html'
|
||||||
|
return(link)
|
||||||
|
|
||||||
|
def getLyrics(link):
|
||||||
|
w = requests.get(link)
|
||||||
|
soup = BeautifulSoup(w.text, 'html.parser')
|
||||||
|
lyr = soup.find_all('div', class_=False)
|
||||||
|
let = str(lyr)
|
||||||
|
return(let)
|
||||||
|
|
||||||
|
def parsero(lyrics):
|
||||||
|
let = lyrics
|
||||||
|
let = let.replace('<br/>', ' ')
|
||||||
|
let = let.replace('<i>', '')
|
||||||
|
let = let.replace('</i>', '')
|
||||||
|
let = let.replace('<div>', '')
|
||||||
|
let = let.replace('</div>,', '')
|
||||||
|
let = let.replace('</div>', '')
|
||||||
|
let = let.replace('<div id="RTK_vQAi">', '')
|
||||||
|
let = let.replace('<div id="RTK_QZjx">', '')
|
||||||
|
let = let.replace('<div id="RTK_sdL2">', '')
|
||||||
|
let = let.replace('<!-- Usage of azlyrics.com content by any third-party lyrics provider is prohibited by our licensing agreement. Sorry about that. -->', '')
|
||||||
|
return(let[1:-1])
|
|
@ -0,0 +1,39 @@
|
||||||
|
import azl
|
||||||
|
import letras
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
web = ''
|
||||||
|
val = ''
|
||||||
|
artist = input('Name of the artist/band: ')
|
||||||
|
title = input('Name of the song: ')
|
||||||
|
web = input('Where would u like to search? (a for azl/l for letras): ')
|
||||||
|
if web == 'a':
|
||||||
|
song_url = azl.getLink(artist, title)
|
||||||
|
un_lyr = azl.getLyrics(song_url)
|
||||||
|
fin = azl.parsero(un_lyr)
|
||||||
|
print(fin)
|
||||||
|
elif web == 'l':
|
||||||
|
song_url = letras.getLink(artist, title)
|
||||||
|
un_lyr = letras.getLyrics(song_url)
|
||||||
|
fin = letras.parsero(un_lyr)
|
||||||
|
print(fin)
|
||||||
|
else:
|
||||||
|
print("I didn't give u that option dude")
|
||||||
|
continue
|
||||||
|
while True:
|
||||||
|
res = input("What's the move? (s to search for another song/q to quit): ")
|
||||||
|
if res == 's' or res == 'q':
|
||||||
|
val = res
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print("what's wrong w u mate?")
|
||||||
|
continue
|
||||||
|
if val == 's':
|
||||||
|
continue
|
||||||
|
elif val == 'q':
|
||||||
|
print('see u')
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print('SOMETHING WENT HORRIBLY WRONG GOTTA GO')
|
||||||
|
break
|
Loading…
Reference in New Issue