lenawilli commited on
Commit
04a80dc
·
verified ·
1 Parent(s): cf7f179

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +48 -11
src/streamlit_app.py CHANGED
@@ -302,27 +302,64 @@ elif page:
302
  elif search_query:
303
  st.title(f"Search Results for '{search_query}'")
304
  filtered = movie_df[movie_df["clean_title"].str.contains(search_query, case=False, na=False)]
305
-
306
  if filtered.empty:
307
  st.warning("No movies found.")
308
  else:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  for _, movie in filtered.iterrows():
310
- expander_html_id = f"expander_{movie['movieId']}"
311
- with st.expander(f"{movie['clean_title']}", expanded=False):
312
- st.markdown(f"<style>#{expander_html_id} {{ background-color: #2a2a2a; border-left: 4px solid #b32d2e; padding: 10px; }}</style>", unsafe_allow_html=True)
313
- col1, col2 = st.columns([1, 3])
 
 
 
 
 
 
 
 
 
 
 
 
314
  with col1:
315
- poster_url, _ = get_tmdb_data(movie["clean_title"], movie["year"])
316
  if poster_url and "placeholder.com" not in poster_url:
317
  st.image(poster_url, width=100)
318
  else:
319
  st.markdown("""
320
- <div style='width:100px;border:2px dashed gray;height:150px;display:flex;align-items:center;justify-content:center;color:gray;font-size:12px;'>No picture<br>available</div>
 
 
321
  """, unsafe_allow_html=True)
322
- with col2:
323
- st.markdown(f"**Genres:** {movie['genres']}")
324
- st.markdown(f"**Year:** {movie['year']}")
325
- st.markdown(f"[🔍 Details](/?movie_id={movie['movieId']})", unsafe_allow_html=True)
326
  else:
327
  st.title("Welcome to Movie Recommender")
328
 
 
302
  elif search_query:
303
  st.title(f"Search Results for '{search_query}'")
304
  filtered = movie_df[movie_df["clean_title"].str.contains(search_query, case=False, na=False)]
305
+
306
  if filtered.empty:
307
  st.warning("No movies found.")
308
  else:
309
+ st.markdown("""
310
+ <style>
311
+ .movie-box {
312
+ background-color: #1a1a1a;
313
+ padding: 15px;
314
+ border-radius: 10px;
315
+ margin-bottom: 15px;
316
+ transition: all 0.3s ease-in-out;
317
+ }
318
+ .movie-box:hover {
319
+ background-color: #262626;
320
+ }
321
+ .movie-box.expanded {
322
+ border-left: 6px solid #b32d2e;
323
+ background-color: #2a2a2a;
324
+ }
325
+ .movie-title {
326
+ font-size: 18px;
327
+ font-weight: bold;
328
+ color: #e63946;
329
+ }
330
+ .movie-details {
331
+ margin-top: 10px;
332
+ }
333
+ </style>
334
+ """, unsafe_allow_html=True)
335
+
336
  for _, movie in filtered.iterrows():
337
+ with st.expander(f"🎬 {movie['clean_title']}", expanded=False):
338
+ container = st.container()
339
+ with container:
340
+ st.markdown(f"""
341
+ <div class="movie-box expanded">
342
+ <div class="movie-details">
343
+ <p><strong>Genres:</strong> {movie['genres']}</p>
344
+ <p><strong>Year:</strong> {movie['year']}</p>
345
+ <a href="/?movie_id={movie['movieId']}" style="color:#b32d2e;">🔍 Details</a>
346
+ </div>
347
+ </div>
348
+ """, unsafe_allow_html=True)
349
+ # Show image even when collapsed
350
+ poster_url, _ = get_tmdb_data(movie["clean_title"], movie["year"])
351
+ with st.container():
352
+ col1, col2 = st.columns([1, 4])
353
  with col1:
 
354
  if poster_url and "placeholder.com" not in poster_url:
355
  st.image(poster_url, width=100)
356
  else:
357
  st.markdown("""
358
+ <div style='width:100px;border:2px dashed gray;height:150px;display:flex;align-items:center;justify-content:center;color:gray;'>
359
+ No Image
360
+ </div>
361
  """, unsafe_allow_html=True)
362
+
 
 
 
363
  else:
364
  st.title("Welcome to Movie Recommender")
365