mtoft20 commited on
Commit
bd9bff8
·
verified ·
1 Parent(s): 804da6a

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +15 -3
src/streamlit_app.py CHANGED
@@ -131,10 +131,15 @@ def filter_content(content_list, filters):
131
 
132
  # Rating filter
133
  if filters['ratings']:
134
- if content.get('rating') not in filters['ratings']:
 
 
135
  matches_all_filters = False
136
  continue
137
-
 
 
 
138
  # Release year filter
139
  try:
140
  release_year = int(content.get('release_year', 0))
@@ -354,7 +359,14 @@ def main():
354
  st.stop()
355
 
356
  # Extract unique values for filters
357
- all_ratings = sorted(list(set([c.get('rating') for c in all_content if c.get('rating')])))
 
 
 
 
 
 
 
358
  all_genres = sorted(list(set(
359
  genre.strip()
360
  for c in all_content
 
131
 
132
  # Rating filter
133
  if filters['ratings']:
134
+ rating = content.get('rating', '').strip()
135
+ # Only compare if rating is a valid string and not a duration
136
+ if not rating or not isinstance(rating, str) or rating.endswith('min'):
137
  matches_all_filters = False
138
  continue
139
+ if rating not in filters['ratings']:
140
+ matches_all_filters = False
141
+ continue
142
+
143
  # Release year filter
144
  try:
145
  release_year = int(content.get('release_year', 0))
 
359
  st.stop()
360
 
361
  # Extract unique values for filters
362
+ all_ratings = sorted(list(set(
363
+ c.get('rating') for c in all_content
364
+ if c and isinstance(c, dict)
365
+ and c.get('rating')
366
+ and isinstance(c.get('rating'), str)
367
+ and not c.get('rating').endswith('min') # Exclude duration values
368
+ and c.get('rating').strip() # Exclude empty strings
369
+ )))
370
  all_genres = sorted(list(set(
371
  genre.strip()
372
  for c in all_content