WebVideoAwards / app.py
awacke1's picture
Update app.py
497d573
raw
history blame
1.42 kB
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
def create_search_url(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')
# Parsing the data
data = parse_data("data.txt")
# Streamlit page configuration
st.set_page_config(page_title="MTV VMAs 2023 Awards", layout="wide")
# Main title
st.title("πŸ† Video Awards Presentation Streamlit for 2023!")
# Displaying data
for category, nominees in data.items():
st.header(f"{category} 🎢")
with st.expander("View Nominees"):
for nominee in nominees:
col1, col2 = st.columns([3, 1])
with col1:
st.markdown(f"* {nominee}")
with col2:
st.markdown(f"[Wikipedia]({create_search_url(nominee)})")
# Footer
st.caption("Source: MTV Video Music Awards 2023")