from bs4 import BeautifulSoup import requests import gradio as gr import bs4 def get_lyrics(link): r = requests.get(link) soup = BeautifulSoup(r.text, 'lxml') if 'linkco.re' in link: lyrics = '\n'.join([tag.text for tag in soup.find('div', 'lyric_text').find_all('p')]) elif 's.awa.fm' in link: lyrics = soup.find(string='歌詞').next_element.text lyrics = lyrics.strip() return gr.Textbox(lyrics, lines=len(lyrics.splitlines())) app = gr.Interface( get_lyrics, inputs=gr.Text(label='TuneCore/AWA Link'), outputs=gr.Textbox(label='Lyrics'), title='TuneCore/AWA Lyrics', description="Input a link to a song's lyrics from `linkco.re` or `s.awa.fm` to get lyrics you can actually highlight. Man I'm tired of having to right-click and inspect page just to search up a word I don't know (I know I can just write it in a dictionary but fuck it I'm lazy as shit).", examples=[ 'https://linkco.re/FAcMyDty/songs/3754057/lyrics', 'https://linkco.re/mXebcYE3/songs/3839431/lyrics', 'https://s.awa.fm/track/b6b84c7f85befa80a916', 'https://s.awa.fm/track/be77be6584a791823e31' ], cache_examples=False, flagging_mode='never' ) app.launch()