mtoft20 commited on
Commit
2178636
·
verified ·
1 Parent(s): 2d44ed4

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +29 -7
src/streamlit_app.py CHANGED
@@ -94,14 +94,18 @@ def filter_content(content_list, filters):
94
  filtered = []
95
 
96
  for content in content_list:
 
 
 
97
  # Type filter
98
  if filters['content_type'] and content.get('type') != filters['content_type']:
99
  continue
100
 
101
  # Genre filter - check if ALL selected genres are in the content's genres
102
  if filters['genres']:
103
- content_genres = [g.strip() for g in content.get('listed_in', '').split(',')]
104
- if not all(genre in content_genres for genre in filters['genres']):
 
105
  continue
106
 
107
  # Rating filter
@@ -127,12 +131,16 @@ def filter_content(content_list, filters):
127
  continue
128
 
129
  # Director filter (optional)
130
- if filters['director'] and filters['director'].lower() not in (content.get('director', '') or '').lower():
131
- continue
 
 
132
 
133
  # Cast filter (optional)
134
- if filters['cast'] and filters['cast'].lower() not in (content.get('cast', '') or '').lower():
135
- continue
 
 
136
 
137
  filtered.append(content)
138
 
@@ -354,6 +362,20 @@ def main():
354
  st.subheader(f"📋 Found {filtered_count:,} Title{'s' if filtered_count != 1 else ''}")
355
 
356
  if st.session_state.filtered_content:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
  # Show first 10 items
358
  for i, content in enumerate(st.session_state.filtered_content[:10]):
359
  with st.expander(f"{content.get('title', 'N/A')} ({content.get('release_year', 'N/A')})"):
@@ -366,7 +388,7 @@ def main():
366
  st.write(f"**⏱️ Duration:** {content.get('duration', 'N/A')}")
367
 
368
  with detail_col2:
369
- st.write(f"**🎬 Genre:** {content.get('listed_in', 'N/A')}")
370
  cast = content.get('cast')
371
  cast_display = cast[:100] + "..." if cast and len(cast) > 100 else cast if cast else "N/A"
372
  st.write(f"**👥 Cast:** {cast_display}")
 
94
  filtered = []
95
 
96
  for content in content_list:
97
+ # For debugging
98
+ title = content.get('title', 'N/A')
99
+
100
  # Type filter
101
  if filters['content_type'] and content.get('type') != filters['content_type']:
102
  continue
103
 
104
  # Genre filter - check if ALL selected genres are in the content's genres
105
  if filters['genres']:
106
+ content_genres = [g.strip().lower() for g in content.get('listed_in', '').split(',')]
107
+ selected_genres = [g.strip().lower() for g in filters['genres']]
108
+ if not all(genre in content_genres for genre in selected_genres):
109
  continue
110
 
111
  # Rating filter
 
131
  continue
132
 
133
  # Director filter (optional)
134
+ if filters['director']:
135
+ director = (content.get('director', '') or '').lower()
136
+ if filters['director'].lower() not in director:
137
+ continue
138
 
139
  # Cast filter (optional)
140
+ if filters['cast']:
141
+ cast = (content.get('cast', '') or '').lower()
142
+ if filters['cast'].lower() not in cast:
143
+ continue
144
 
145
  filtered.append(content)
146
 
 
362
  st.subheader(f"📋 Found {filtered_count:,} Title{'s' if filtered_count != 1 else ''}")
363
 
364
  if st.session_state.filtered_content:
365
+ # Debug information
366
+ st.write("**Active Filters:**")
367
+ if filters['content_type']:
368
+ st.write(f"- Content Type: {filters['content_type']}")
369
+ if filters['genres']:
370
+ st.write(f"- Genres: {', '.join(filters['genres'])}")
371
+ if filters['ratings']:
372
+ st.write(f"- Ratings: {', '.join(filters['ratings'])}")
373
+ if filters['director']:
374
+ st.write(f"- Director: {filters['director']}")
375
+ if filters['cast']:
376
+ st.write(f"- Cast: {filters['cast']}")
377
+ st.write("---")
378
+
379
  # Show first 10 items
380
  for i, content in enumerate(st.session_state.filtered_content[:10]):
381
  with st.expander(f"{content.get('title', 'N/A')} ({content.get('release_year', 'N/A')})"):
 
388
  st.write(f"**⏱️ Duration:** {content.get('duration', 'N/A')}")
389
 
390
  with detail_col2:
391
+ st.write(f"**🎬 Genres:** {content.get('listed_in', 'N/A')}")
392
  cast = content.get('cast')
393
  cast_display = cast[:100] + "..." if cast and len(cast) > 100 else cast if cast else "N/A"
394
  st.write(f"**👥 Cast:** {cast_display}")