lenawilli commited on
Commit
0ff20cf
verified
1 Parent(s): ff2d8e7

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +9 -4
src/streamlit_app.py CHANGED
@@ -282,7 +282,7 @@ elif page:
282
  movie_pool = st.session_state.rating_mode_state["movie_pool"]
283
  index = st.session_state.rating_mode_state["index"]
284
 
285
- if not movie_pool:
286
  st.info("Please start a rating session.")
287
  st.stop()
288
 
@@ -568,12 +568,16 @@ else:
568
 
569
  for _, movie in recommended_df.iterrows():
570
  poster_url, _ = get_tmdb_data(movie["clean_title"], movie["year"])
 
 
 
 
 
 
571
  st.markdown(f"""
572
  <div style="margin-bottom:1em;padding:1em;border:1px solid #333;border-radius:10px;background:#1a1a1a;">
573
  <div style="display:flex;gap:20px;">
574
- <div>
575
- <img src="{poster_url}" width="100" style="border-radius:5px;" />
576
- </div>
577
  <div>
578
  <a href='/?movie_id={movie["movieId"]}' style="font-size:18px;color:#e63946;font-weight:bold;">{movie['clean_title']}</a><br>
579
  <span style="color:#ccc;">{movie['genres']} 路 {movie['year']}</span><br>
@@ -582,6 +586,7 @@ else:
582
  </div>
583
  </div>
584
  """, unsafe_allow_html=True)
 
585
  else:
586
  st.info("Rate a few movies to get recommendations.")
587
 
 
282
  movie_pool = st.session_state.rating_mode_state["movie_pool"]
283
  index = st.session_state.rating_mode_state["index"]
284
 
285
+ if movie_pool.empty:
286
  st.info("Please start a rating session.")
287
  st.stop()
288
 
 
568
 
569
  for _, movie in recommended_df.iterrows():
570
  poster_url, _ = get_tmdb_data(movie["clean_title"], movie["year"])
571
+ poster_html = (
572
+ f"<img src='{poster_url}' width='100' style='border-radius:5px;' />"
573
+ if poster_url and "placeholder.com" not in poster_url
574
+ else "<div style='width:100px;height:150px;border:2px dashed gray;display:flex;align-items:center;justify-content:center;color:gray;font-size:12px;'>No<br>Image</div>"
575
+ )
576
+
577
  st.markdown(f"""
578
  <div style="margin-bottom:1em;padding:1em;border:1px solid #333;border-radius:10px;background:#1a1a1a;">
579
  <div style="display:flex;gap:20px;">
580
+ <div>{poster_html}</div>
 
 
581
  <div>
582
  <a href='/?movie_id={movie["movieId"]}' style="font-size:18px;color:#e63946;font-weight:bold;">{movie['clean_title']}</a><br>
583
  <span style="color:#ccc;">{movie['genres']} 路 {movie['year']}</span><br>
 
586
  </div>
587
  </div>
588
  """, unsafe_allow_html=True)
589
+
590
  else:
591
  st.info("Rate a few movies to get recommendations.")
592