Update app.py
Browse files
app.py
CHANGED
@@ -41,57 +41,57 @@ def load_song_file(filename):
|
|
41 |
st.markdown(processed_sheet, unsafe_allow_html=True)
|
42 |
|
43 |
def main():
|
44 |
-
with st.sidebar:
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
if selected_file:
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
58 |
with col1:
|
59 |
-
|
60 |
-
song_name_input = st.text_input("🎵 Song Name", value=song_name)
|
61 |
-
artist_name_input = st.text_input("🎤 Artist Name", value=artist_name)
|
62 |
-
chord_sheet_input = st.text_area("Chord Sheet", height=300)
|
63 |
-
if st.button("💾 Save", key="save_song"):
|
64 |
-
if song_name_input and artist_name_input:
|
65 |
-
filename = f"{song_name_input} by {artist_name_input}.txt".replace(" ", "_")
|
66 |
-
with open(filename, "w") as file:
|
67 |
-
file.write(chord_sheet_input)
|
68 |
-
st.success("Chord sheet saved.")
|
69 |
-
else:
|
70 |
-
st.error("Both Song Name and Artist Name are required.")
|
71 |
with col2:
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
st.markdown(f"[🎶Lyrics]({create_search_url_lyrics(song_info)})")
|
80 |
-
|
81 |
-
st.header("🎼 Available Songs")
|
82 |
-
for file in all_files:
|
83 |
-
song_info = os.path.splitext(file)[0].replace("_", " ")
|
84 |
-
col1, col2, col3, col4, col5 = st.columns([4, 1, 1, 1, 1])
|
85 |
-
with col1:
|
86 |
-
st.markdown(f"* {song_info}")
|
87 |
-
with col2:
|
88 |
-
st.markdown(f"[📚Wikipedia]({create_search_url_wikipedia(song_info)})")
|
89 |
-
with col3:
|
90 |
-
st.markdown(f"[🎥YouTube]({create_search_url_youtube(song_info)})")
|
91 |
-
with col4:
|
92 |
-
st.markdown(f"[🎸Chords]({create_search_url_chords(song_info)})")
|
93 |
-
with col5:
|
94 |
-
st.markdown(f"[🎶Lyrics]({create_search_url_lyrics(song_info)})")
|
95 |
|
96 |
if __name__ == '__main__':
|
97 |
main()
|
|
|
41 |
st.markdown(processed_sheet, unsafe_allow_html=True)
|
42 |
|
43 |
def main():
|
44 |
+
#with st.sidebar:
|
45 |
+
st.title('🎵 Song Files')
|
46 |
+
with st.expander("Select Song File", expanded=True):
|
47 |
+
all_files = [f for f in glob.glob("*.txt") if ' by ' in f]
|
48 |
+
selected_file = st.selectbox("Choose a file", all_files)
|
49 |
+
if selected_file:
|
50 |
+
song_name, artist_name = os.path.splitext(selected_file)[0].split(' by ')
|
51 |
+
song_name = song_name.replace("_", " ")
|
52 |
+
artist_name = artist_name.replace("_", " ")
|
53 |
+
else:
|
54 |
+
song_name, artist_name = "", ""
|
55 |
+
|
56 |
+
col1, col2 = st.columns([2, 1])
|
57 |
+
|
58 |
+
with col1:
|
59 |
+
#with st.expander("🎶 Song and Artist", expanded=True):
|
60 |
+
song_name_input = st.text_input("🎵 Song Name", value=song_name)
|
61 |
+
artist_name_input = st.text_input("🎤 Artist Name", value=artist_name)
|
62 |
+
chord_sheet_input = st.text_area("Chord Sheet", height=300)
|
63 |
+
if st.button("💾 Save", key="save_song"):
|
64 |
+
if song_name_input and artist_name_input:
|
65 |
+
filename = f"{song_name_input} by {artist_name_input}.txt".replace(" ", "_")
|
66 |
+
with open(filename, "w") as file:
|
67 |
+
file.write(chord_sheet_input)
|
68 |
+
st.success("Chord sheet saved.")
|
69 |
+
else:
|
70 |
+
st.error("Both Song Name and Artist Name are required.")
|
71 |
+
with col2:
|
72 |
if selected_file:
|
73 |
+
load_song_file(selected_file)
|
74 |
+
song_info = os.path.splitext(selected_file)[0].replace("_", " ")
|
75 |
+
st.markdown(f"**Selected Song:** {song_info}")
|
76 |
+
st.markdown(f"[📚Wikipedia]({create_search_url_wikipedia(song_info)})")
|
77 |
+
st.markdown(f"[🎥YouTube]({create_search_url_youtube(song_info)})")
|
78 |
+
st.markdown(f"[🎸Chords]({create_search_url_chords(song_info)})")
|
79 |
+
st.markdown(f"[🎶Lyrics]({create_search_url_lyrics(song_info)})")
|
80 |
+
|
81 |
+
st.header("🎼 Available Songs")
|
82 |
+
for file in all_files:
|
83 |
+
song_info = os.path.splitext(file)[0].replace("_", " ")
|
84 |
+
col1, col2, col3, col4, col5 = st.columns([4, 1, 1, 1, 1])
|
85 |
with col1:
|
86 |
+
st.markdown(f"* {song_info}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
with col2:
|
88 |
+
st.markdown(f"[📚Wikipedia]({create_search_url_wikipedia(song_info)})")
|
89 |
+
with col3:
|
90 |
+
st.markdown(f"[🎥YouTube]({create_search_url_youtube(song_info)})")
|
91 |
+
with col4:
|
92 |
+
st.markdown(f"[🎸Chords]({create_search_url_chords(song_info)})")
|
93 |
+
with col5:
|
94 |
+
st.markdown(f"[🎶Lyrics]({create_search_url_lyrics(song_info)})")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
if __name__ == '__main__':
|
97 |
main()
|