From 36a2a8e15b5fa9ed1ddc006150d1c2fc16e5c0e4 Mon Sep 17 00:00:00 2001 From: siengrain Date: Mon, 20 Dec 2021 23:01:00 +0000 Subject: [PATCH 1/5] Upload files to '' --- letras.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 letras.py diff --git a/letras.py b/letras.py new file mode 100644 index 0000000..9e45345 --- /dev/null +++ b/letras.py @@ -0,0 +1,34 @@ +from bs4 import BeautifulSoup +import requests +from requests import get + +def getLink(artist, title): + base_start = 'https://www.letras.com/' + artist = artist.lower() + artist = artist.replace(' ', '-') + title = title.lower() + title = title.replace(' ', '-') + link = base_start + artist + '/' + title + return(link) + +def getLyrics(link): + w = requests.get(link) + soup = BeautifulSoup(w.text, 'html.parser') + lyr = soup.find_all('p', class_=False) + let = str(lyr) + return(let) + +def parsero(lyrics): + lyrics = lyrics.replace('

,', '\n') + lyrics = lyrics.replace('
,', '\n') + lyrics = lyrics.replace('
', '\n') + lyrics = lyrics.replace('

', '') + lyrics = lyrics.replace('
', '\n') + lyrics = lyrics.replace('
', '\n') + lyrics = lyrics.replace('

Quiero recibir notificaciones de artistas destacados y noticias.

', '') + lyrics = lyrics.replace('Música comienza con letras', '') + lyrics = lyrics.replace('Asociados:', '') + lyrics = lyrics.replace(' © 2003 - 2021, 3.1 millones de canciones', '') + lyrics = lyrics.replace(' Hecho con amor en Belo Horizonte - Brasil', '') + return('\n'+lyrics[1:-1]) + From daba81de065c3056e3a598e00e7d1bedc24b1373 Mon Sep 17 00:00:00 2001 From: siengrain Date: Mon, 20 Dec 2021 23:01:14 +0000 Subject: [PATCH 2/5] Delete 'main.py' --- main.py | 63 --------------------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 main.py diff --git a/main.py b/main.py deleted file mode 100644 index 8a88fde..0000000 --- a/main.py +++ /dev/null @@ -1,63 +0,0 @@ -from bs4 import BeautifulSoup -import requests -from requests import get -import webbrowser - -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) - -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 - else: - print('Something went wrong') - break From 28b6263ac3b6ededd0e5737af876ef9e71682d29 Mon Sep 17 00:00:00 2001 From: siengrain Date: Mon, 20 Dec 2021 23:01:37 +0000 Subject: [PATCH 3/5] Upload files to '' --- azl.py | 36 ++++++++++++++++++++++++++++++++++++ main.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 azl.py create mode 100644 main.py diff --git a/azl.py b/azl.py new file mode 100644 index 0000000..d7af1ff --- /dev/null +++ b/azl.py @@ -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('
', ' ') + 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]) diff --git a/main.py b/main.py new file mode 100644 index 0000000..a7f3244 --- /dev/null +++ b/main.py @@ -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 From b60e351faa2df184ce6ed517d5bfddda676dbef9 Mon Sep 17 00:00:00 2001 From: siengrain Date: Sun, 6 Feb 2022 02:17:09 +0000 Subject: [PATCH 4/5] removed annoying div thingy now it doesn't say "
something" when the song isn't available on azl --- main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index a7f3244..e74781b 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +#!/bin/env python import azl import letras @@ -12,16 +13,21 @@ while True: 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<------------------------------------------------------------->') print(fin) elif web == 'l': song_url = letras.getLink(artist, title) un_lyr = letras.getLyrics(song_url) fin = letras.parsero(un_lyr) + print('\n<------------------------------------------------------------->') print(fin) else: print("I didn't give u that option dude") continue 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 @@ -36,4 +42,4 @@ while True: break else: print('SOMETHING WENT HORRIBLY WRONG GOTTA GO') - break + break \ No newline at end of file From 2c286c9d39834861d7e7b93662c4e7932bd07b8f Mon Sep 17 00:00:00 2001 From: siengrain Date: Sat, 12 Feb 2022 04:54:30 +0000 Subject: [PATCH 5/5] removed web selector now u dont have to pick a website to scrap (less annoying to use) --- main.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/main.py b/main.py index e74781b..9891ce2 100644 --- a/main.py +++ b/main.py @@ -1,31 +1,25 @@ -#!/bin/env python +#!/usr/bin/env python3 + 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) - if fin == '
': - fin = "Sorry I couldn't find that song :(" - print('\n<------------------------------------------------------------->') + 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) - elif web == 'l': + else: song_url = letras.getLink(artist, title) un_lyr = letras.getLyrics(song_url) fin = letras.parsero(un_lyr) - print('\n<------------------------------------------------------------->') print(fin) - else: - print("I didn't give u that option dude") - continue while True: print('<------------------------------------------------------------->') res = input("What's the move? (s to search for another song/q to quit): ") @@ -42,4 +36,4 @@ while True: break else: print('SOMETHING WENT HORRIBLY WRONG GOTTA GO') - break \ No newline at end of file + break \ No newline at end of file