Spaces:
Runtime error
Runtime error
import streamlit as st | |
# Function to parse the text file | |
def parse_data(filename): | |
with open(filename, "r") as file: | |
lines = file.readlines() | |
categories = {} | |
current_category = None | |
for line in lines: | |
line = line.strip() | |
if not line: | |
continue | |
if line.startswith('Best'): | |
current_category = line | |
categories[current_category] = [] | |
else: | |
categories[current_category].append(line) | |
return categories | |
# Function to create a search URL for Wikipedia: | |
def create_search_url_wikipedia(artist_song): | |
base_url = "https://www.wikipedia.org/search-redirect.php?family=wikipedia&language=en&search=" | |
return base_url + artist_song.replace(' ', '+').replace('–', '%E2%80%93').replace('&', 'and') | |
# Function to create a search URL for YouTube: | |
def create_search_url_youtube(artist_song): | |
base_url = "https://www.youtube.com/results?search_query=" | |
return base_url + artist_song.replace(' ', '+').replace('–', '%E2%80%93').replace('&', 'and') | |
# Function to create a search URL for Chords: | |
def create_search_url_chords(artist_song): | |
base_url = "https://www.ultimate-guitar.com/search.php?search_type=title&value=" | |
return base_url + artist_song.replace(' ', '+').replace('–', '%E2%80%93').replace('&', 'and') | |
# Function to create a search URL for Lyrics: | |
def create_search_url_lyrics(artist_song): | |
base_url = "https://www.google.com/search?q=" | |
return base_url + artist_song.replace(' ', '+').replace('–', '%E2%80%93').replace('&', 'and') + '+lyrics' | |
# Parsing the data | |
data = parse_data("data.txt") | |
# Streamlit page configuration | |
st.set_page_config(page_title="MTV VMAs - 2023 Awards Wikipedia and Youtube", layout="wide") | |
# Main title | |
st.title("🏆 Video Awards 2023 - Wikipedia, Youtube, Chords, Lyrics") | |
# Displaying data | |
for category, nominees in data.items(): | |
st.header(f"{category} 🎶") | |
with st.expander("View Nominees"): | |
for nominee in nominees: | |
col1, col2, col3, col4, col5 = st.columns([4, 1, 1, 1, 1]) | |
with col1: | |
st.markdown(f"* {nominee}") | |
with col2: | |
st.markdown(f"[📚Wikipedia]({create_search_url_wikipedia(nominee)})") | |
with col3: | |
st.markdown(f"[🎥YouTube]({create_search_url_youtube(nominee)})") | |
with col4: | |
st.markdown(f"[🎸Chords]({create_search_url_chords(nominee)})") | |
with col5: | |
st.markdown(f"[🎶Lyrics]({create_search_url_lyrics(nominee)})") | |
# Footer | |
st.caption("Source: MTV Video Music Awards 2023") | |