-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.py
40 lines (31 loc) · 1.31 KB
/
1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import streamlit as st
import pandas as pd
import random
# Load the CSV file
csv_filename = 'hit_songs.csv' # Replace with the actual file path
df = pd.read_csv(csv_filename)
# Sort the DataFrame by 'Views' in descending order
df_sorted = df.sort_values(by='Views', ascending=False)
# Streamlit App
st.title("(Kamal)---Music")
# Music player
selected_song = st.selectbox("Select a song to play:", df_sorted['Title'])
selected_song_url = df_sorted[df_sorted['Title']
== selected_song]['Video_URL'].values[0]
# Check if the URL is a YouTube video URL
if "youtube.com" in selected_song_url or "youtu.be" in selected_song_url:
st.video(selected_song_url)
# Display the title of the selected song
st.write(f"Now playing: {selected_song}")
# Button to play a random song
if st.button("Play Random Song"):
random_index = random.randint(0, len(df_sorted) - 1)
selected_song = df_sorted.iloc[random_index]['Title']
selected_song_url = df_sorted.iloc[random_index]['Video_URL']
st.write(f"Now playing: {selected_song}")
# Check if the URL is a YouTube video URL
if "youtube.com" in selected_song_url or "youtu.be" in selected_song_url:
st.video(selected_song_url)
# Display CSV file at the end
st.write("**CSV File:**")
st.write(df_sorted)