Spaces:
Sleeping
Sleeping
Commit
•
afa1625
1
Parent(s):
ca40b30
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
from songscope import *
|
|
|
4 |
# !python -m pip install --upgrade pip
|
5 |
|
6 |
# main header
|
@@ -11,10 +12,12 @@ st.write("Welcome to SongScope. This is a web app that lets you download lyrics
|
|
11 |
st.write("Enter an artist name, and you can even select up to 5 songs to retrieve their data. If you don't specify any songs,\ndata on all songs by the artist will be retrieved.")
|
12 |
|
13 |
# delay times
|
14 |
-
# delay_min = float(st.text_input("Minimum delay per iteration"))
|
15 |
-
# delay_max = float(st.text_input("Maximum delay per iteration"))
|
16 |
-
delay_min = st.number_input(label = "Minimum delay per iteration
|
17 |
-
|
|
|
|
|
18 |
# delay_min = 15
|
19 |
# delay_max = 30
|
20 |
# sysBP = st.number_input(label=“systolic blood pressure”,step=1.,format="%.2f")
|
@@ -28,19 +31,20 @@ song_4 = st.text_input("Enter 4th song title here")
|
|
28 |
song_5 = st.text_input("Enter 5th song title here")
|
29 |
|
30 |
# data is found
|
31 |
-
|
32 |
-
if not
|
33 |
-
st.write("
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
# artist_df.to_csv(f"{artist_name.lower()}_data.csv")
|
41 |
|
42 |
# user downloads found data here
|
43 |
-
|
|
|
44 |
# st.download_button('Download Data', DATA_TO_CSV) # Defaults to 'text/plain'
|
45 |
|
46 |
# with open(f'{artist_name.lower()}_data.csv') as f:
|
@@ -50,12 +54,11 @@ csv_dl_button = st.download_button('Download Data', artist_df, 'text/csv')
|
|
50 |
# fun facts
|
51 |
fun_fax = []
|
52 |
with open("fun_fax.txt", "r", encoding = "utf-8") as f:
|
53 |
-
for
|
54 |
-
|
55 |
-
fun_fax.append(word)
|
56 |
f.close() # closes connection to file
|
57 |
|
58 |
-
if
|
59 |
st.write("Your data should be downloaded. If not, please reload the page and try again.")
|
60 |
|
61 |
st.write(fun_fax[random.randint(0, len(fun_fax) - 1)])
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
from songscope import *
|
4 |
+
import random
|
5 |
# !python -m pip install --upgrade pip
|
6 |
|
7 |
# main header
|
|
|
12 |
st.write("Enter an artist name, and you can even select up to 5 songs to retrieve their data. If you don't specify any songs,\ndata on all songs by the artist will be retrieved.")
|
13 |
|
14 |
# delay times
|
15 |
+
# delay_min = float(st.text_input("Minimum delay per iteration. We recommend a value of at least 10 seconds per song, otherwise you may be banned from azlyrics.com for scraping."))
|
16 |
+
# delay_max = float(st.text_input("Maximum delay per iteration. We recommend a value of at least 10 seconds per song, otherwise you may be banned from azlyrics.com for scraping."))
|
17 |
+
delay_min = st.number_input(label = "Minimum delay per iteration. We recommend a value of at least 10 seconds per song, otherwise you may be banned from azlyrics.com for scraping.",
|
18 |
+
step = 1., format = "%.2f")
|
19 |
+
delay_max = st.number_input(label = "Maximum delay per iteration. We recommend a value of at least 10 seconds per song, otherwise you may be banned from azlyrics.com for scraping.",
|
20 |
+
step = 1., format = "%.2f")
|
21 |
# delay_min = 15
|
22 |
# delay_max = 30
|
23 |
# sysBP = st.number_input(label=“systolic blood pressure”,step=1.,format="%.2f")
|
|
|
31 |
song_5 = st.text_input("Enter 5th song title here")
|
32 |
|
33 |
# data is found
|
34 |
+
find_button = st.button('Find Data')
|
35 |
+
if not find_button: # button to make everything run
|
36 |
+
st.write("Once you've entered the above data, click the 'Find Data' button, above, to begin.")
|
37 |
+
else:
|
38 |
+
artist_df = get_all_data(artist_name = artist_name,
|
39 |
+
song_titles = song_1 + song_2 + song_3 + song_4 + song_5,
|
40 |
+
delay = (delay_min, delay_max), # random float value between (delay_min, delay_max) seconds
|
41 |
+
print_progress = True)
|
42 |
|
43 |
# artist_df.to_csv(f"{artist_name.lower()}_data.csv")
|
44 |
|
45 |
# user downloads found data here
|
46 |
+
if find_button:
|
47 |
+
dl_button = st.download_button('Download Data', artist_df, f"{artist_name.lower()}_data.csv")
|
48 |
# st.download_button('Download Data', DATA_TO_CSV) # Defaults to 'text/plain'
|
49 |
|
50 |
# with open(f'{artist_name.lower()}_data.csv') as f:
|
|
|
54 |
# fun facts
|
55 |
fun_fax = []
|
56 |
with open("fun_fax.txt", "r", encoding = "utf-8") as f:
|
57 |
+
for fact in f.read().split("\n"):
|
58 |
+
fun_fax.append(fact)
|
|
|
59 |
f.close() # closes connection to file
|
60 |
|
61 |
+
if dl_button:
|
62 |
st.write("Your data should be downloaded. If not, please reload the page and try again.")
|
63 |
|
64 |
st.write(fun_fax[random.randint(0, len(fun_fax) - 1)])
|