awacke1 commited on
Commit
f4065b2
β€’
1 Parent(s): bcf03d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -7
app.py CHANGED
@@ -20,6 +20,22 @@ def load_song_file(file_path):
20
  with open(file_path, 'r', encoding='utf-8') as file:
21
  return file.read()
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  def display_chord_sheet_in_two_page_view(chord_sheet):
24
  # CSS for multi-column layout
25
  css_content = """
@@ -52,14 +68,33 @@ def main():
52
  with st.expander("Select Song:", expanded=True):
53
  all_files = [f for f in glob.glob("*.txt") if ' by ' in f]
54
  selected_file = st.selectbox("Choose: ", all_files, key='selected_file')
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
- if selected_file:
57
- song_info = os.path.splitext(selected_file)[0].replace("_", " ")
58
- st.header("🎼 Current Song")
59
- st.markdown("**" + song_info + "**")
60
- chord_sheet = load_song_file(selected_file)
61
- processed_sheet = process_chord_sheet(chord_sheet)
62
- st.markdown(processed_sheet, unsafe_allow_html=True)
 
 
 
 
 
 
63
 
64
  with col3:
65
  if 'selected_file' in st.session_state and st.session_state.selected_file:
 
20
  with open(file_path, 'r', encoding='utf-8') as file:
21
  return file.read()
22
 
23
+ def create_search_url_wikipedia(artist_song):
24
+ base_url = "https://www.wikipedia.org/search-redirect.php?family=wikipedia&language=en&search="
25
+ return base_url + artist_song.replace(' ', '+').replace('–', '%E2%80%93').replace('&', 'and')
26
+
27
+ def create_search_url_youtube(artist_song):
28
+ base_url = "https://www.youtube.com/results?search_query="
29
+ return base_url + artist_song.replace(' ', '+').replace('–', '%E2%80%93').replace('&', 'and')
30
+
31
+ def create_search_url_chords(artist_song):
32
+ base_url = "https://www.ultimate-guitar.com/search.php?search_type=title&value="
33
+ return base_url + artist_song.replace(' ', '+').replace('–', '%E2%80%93').replace('&', 'and')
34
+
35
+ def create_search_url_lyrics(artist_song):
36
+ base_url = "https://www.google.com/search?q="
37
+ return base_url + artist_song.replace(' ', '+').replace('–', '%E2%80%93').replace('&', 'and') + '+lyrics'
38
+
39
  def display_chord_sheet_in_two_page_view(chord_sheet):
40
  # CSS for multi-column layout
41
  css_content = """
 
68
  with st.expander("Select Song:", expanded=True):
69
  all_files = [f for f in glob.glob("*.txt") if ' by ' in f]
70
  selected_file = st.selectbox("Choose: ", all_files, key='selected_file')
71
+ if selected_file:
72
+ song_info = os.path.splitext(selected_file)[0].replace("_", " ")
73
+ st.header("🎼 Current Song")
74
+ st.markdown("**" + song_info + "**")
75
+ chord_sheet = load_song_file(selected_file)
76
+ processed_sheet = process_chord_sheet(chord_sheet)
77
+ st.markdown(processed_sheet, unsafe_allow_html=True)
78
+ table_md = f"""
79
+ | Wikipedia | YouTube | Chords | Lyrics |
80
+ | --------- | ------- | ------ | ------ |
81
+ | [πŸ“š]({create_search_url_wikipedia(song_info)}) | [πŸŽ₯]({create_search_url_youtube(song_info)}) | [🎸]({create_search_url_chords(song_info)}) | [🎢]({create_search_url_lyrics(song_info)}) |
82
+ """
83
+ st.markdown(table_md)
84
 
85
+ st.header("🎼 Available Songs")
86
+ for file in all_files:
87
+ song_info = os.path.splitext(file)[0].replace("_", " ")
88
+ icol1, icol2 = st.columns([1, 3])
89
+ with icol1:
90
+ st.markdown("**" + song_info + "**")
91
+ with icol2:
92
+ table_md = f"""
93
+ | Wikipedia | YouTube | Chords | Lyrics |
94
+ | --------- | ------- | ------ | ------ |
95
+ | [πŸ“š]({create_search_url_wikipedia(song_info)}) | [πŸŽ₯]({create_search_url_youtube(song_info)}) | [🎸]({create_search_url_chords(song_info)}) | [🎢]({create_search_url_lyrics(song_info)}) |
96
+ """
97
+ st.markdown(table_md)
98
 
99
  with col3:
100
  if 'selected_file' in st.session_state and st.session_state.selected_file: