Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +34 -36
src/streamlit_app.py
CHANGED
|
@@ -22,15 +22,13 @@ if "movies" not in st.session_state:
|
|
| 22 |
st.session_state.skipped = 0
|
| 23 |
st.session_state.max_questions = 5
|
| 24 |
st.session_state.finished = False
|
|
|
|
| 25 |
|
| 26 |
st.markdown("""
|
| 27 |
<style>
|
| 28 |
-
body {
|
| 29 |
-
background-color: #0d1b2a;
|
| 30 |
-
color: white;
|
| 31 |
-
}
|
| 32 |
-
.stSlider > div {
|
| 33 |
-
background-color: #1b263b;
|
| 34 |
}
|
| 35 |
</style>
|
| 36 |
""", unsafe_allow_html=True)
|
|
@@ -43,42 +41,42 @@ if not st.session_state.movies:
|
|
| 43 |
random.shuffle(movie_titles)
|
| 44 |
st.session_state.movies = movie_titles
|
| 45 |
|
| 46 |
-
if
|
| 47 |
with st.container():
|
| 48 |
st.subheader("How many movies do you want to rate?")
|
| 49 |
st.session_state.max_questions = st.slider("Select number of movies", 1, 15, 5)
|
| 50 |
if st.button("Start Rating"):
|
| 51 |
st.session_state.queue = st.session_state.movies.copy()
|
| 52 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
else:
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
st.write("Based on your preferences, we suggest:")
|
| 57 |
-
remaining = [m for m in st.session_state.movies if m not in [r["movie"] for r in st.session_state.rated]]
|
| 58 |
-
recommendations = random.sample(remaining, min(10, len(remaining)))
|
| 59 |
-
for i, movie in enumerate(recommendations, 1):
|
| 60 |
-
score = round(random.uniform(75, 100), 1)
|
| 61 |
-
st.markdown(f"**#{i}. {movie}** β Likelihood: `{score}%`")
|
| 62 |
-
else:
|
| 63 |
-
movie = st.session_state.queue[st.session_state.index]
|
| 64 |
-
card_number = len(st.session_state.rated) + 1
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
| 22 |
st.session_state.skipped = 0
|
| 23 |
st.session_state.max_questions = 5
|
| 24 |
st.session_state.finished = False
|
| 25 |
+
st.session_state.show_slider = True
|
| 26 |
|
| 27 |
st.markdown("""
|
| 28 |
<style>
|
| 29 |
+
html, body, [class*="css"] {
|
| 30 |
+
background-color: #0d1b2a !important;
|
| 31 |
+
color: white !important;
|
|
|
|
|
|
|
|
|
|
| 32 |
}
|
| 33 |
</style>
|
| 34 |
""", unsafe_allow_html=True)
|
|
|
|
| 41 |
random.shuffle(movie_titles)
|
| 42 |
st.session_state.movies = movie_titles
|
| 43 |
|
| 44 |
+
if st.session_state.show_slider:
|
| 45 |
with st.container():
|
| 46 |
st.subheader("How many movies do you want to rate?")
|
| 47 |
st.session_state.max_questions = st.slider("Select number of movies", 1, 15, 5)
|
| 48 |
if st.button("Start Rating"):
|
| 49 |
st.session_state.queue = st.session_state.movies.copy()
|
| 50 |
+
st.session_state.show_slider = False
|
| 51 |
+
st.rerun()
|
| 52 |
+
elif st.session_state.finished or st.session_state.index >= len(st.session_state.queue):
|
| 53 |
+
st.subheader("πΏ Top 10 Recommendations")
|
| 54 |
+
st.write("Based on your preferences, we suggest:")
|
| 55 |
+
remaining = [m for m in st.session_state.movies if m not in [r["movie"] for r in st.session_state.rated]]
|
| 56 |
+
recommendations = random.sample(remaining, min(10, len(remaining)))
|
| 57 |
+
for i, movie in enumerate(recommendations, 1):
|
| 58 |
+
score = round(random.uniform(75, 100), 1)
|
| 59 |
+
st.markdown(f"**#{i}. {movie}** β Likelihood: `{score}%`")
|
| 60 |
else:
|
| 61 |
+
movie = st.session_state.queue[st.session_state.index]
|
| 62 |
+
card_number = len(st.session_state.rated) + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
st.markdown(f"### ποΈ Movie #{card_number} of {st.session_state.max_questions}")
|
| 65 |
+
st.markdown(f"## **{movie}**")
|
| 66 |
|
| 67 |
+
col1, col2, col3 = st.columns([1, 1, 1])
|
| 68 |
+
with col1:
|
| 69 |
+
if st.button("π Like"):
|
| 70 |
+
st.session_state.rated.append({"movie": movie, "rating": "like"})
|
| 71 |
+
st.session_state.index += 1
|
| 72 |
+
with col2:
|
| 73 |
+
if st.button("π Dislike"):
|
| 74 |
+
st.session_state.rated.append({"movie": movie, "rating": "dislike"})
|
| 75 |
+
st.session_state.index += 1
|
| 76 |
+
with col3:
|
| 77 |
+
if st.button("β Didn't Watch"):
|
| 78 |
+
st.session_state.index += 1
|
| 79 |
|
| 80 |
+
if len(st.session_state.rated) >= st.session_state.max_questions:
|
| 81 |
+
st.session_state.finished = True
|
| 82 |
+
st.rerun()
|