From 8ba3ad1b6c92e98cb62d2a785e0b0a202908452b Mon Sep 17 00:00:00 2001 From: Pulguer Gonzalo Date: Sat, 12 Feb 2022 01:50:48 -0300 Subject: [PATCH] web selector removed (less annoying to use) --- main.py | 92 ++++++++++++++++++++++----------------------------------- 1 file changed, 35 insertions(+), 57 deletions(-) mode change 100644 => 100755 main.py diff --git a/main.py b/main.py old mode 100644 new mode 100755 index 8a88fde..8cac6a6 --- a/main.py +++ b/main.py @@ -1,63 +1,41 @@ -from bs4 import BeautifulSoup -import requests -from requests import get -import webbrowser +#!/usr/bin/env python3 -def getLink(): - artist = input('Name of the artist/band: ') - title = input('Name of the song: ') - base_start = 'https://www.azlyrics.com/lyrics/' - artist = artist.lower() - artist = artist.replace(' ', '') - artist = artist.replace('-', '') - title = title.lower() - title = title.replace(' ', '') - link = base_start + artist + '/' + title + '.html' - return(link) +import azl +import letras -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('
', ' ') - let = let.replace('', '') - let = let.replace('', '') - let = let.replace('
', '') - let = let.replace('
,', '') - let = let.replace('', '') - let = let.replace('
', '') - let = let.replace('
', '') - let = let.replace('
', '') - let = let.replace('', '') - return(let[1:-1]) while True: - song_url = getLink() - lyrics_ori = getLyrics(song_url) - fin = parsero(lyrics_ori) - print(fin) - print('\n') - vali = '' - while True: - res = input("What's the move? (s to search/q to quit): ") - try: - if res == 'q' or res == 's': - vali = res - break - else: - print("I didn't give u that option dude") - except: - print('What?') - if vali == 'q': - print('See u!') - break - elif vali == 's': - continue + web = '' + val = '' + artist = input('Name of the artist/band: ') + title = input('Name of the song: ') + song_url = azl.getLink(artist, title) + un_lyr = azl.getLyrics(song_url) + fin = azl.parsero(un_lyr) + if fin == '
': + fin = "Sorry I couldn't find that song :(" + print('\n<------------------------------------------------------------->') + if fin != "Sorry I couldn't find that song :(": + print(fin) else: - print('Something went wrong') + song_url = letras.getLink(artist, title) + un_lyr = letras.getLyrics(song_url) + fin = letras.parsero(un_lyr) + print(fin) + while True: + print('<------------------------------------------------------------->') + 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