mtoft20 commited on
Commit
2801836
Β·
verified Β·
1 Parent(s): a87e594

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +38 -3
src/streamlit_app.py CHANGED
@@ -293,26 +293,61 @@ def get_similar_content(content, n_recommendations=5):
293
 
294
  # Try finding by show_id
295
  query = f'(show_id,eq,"{show_id}")'
 
 
296
  params = {
297
  "where": query
298
  }
 
 
 
299
 
300
  # Debug: Print the request details
301
  st.write(f"πŸ“‘ Querying table: {table_url.split('/')[-1]}")
302
  st.write(f"πŸ” Query params: {params}")
303
 
304
- # Make the request
305
  try:
306
  response = requests.get(table_url, headers=headers, params=params)
307
-
308
- # Debug: Print response status and content
309
  st.write(f"πŸ“₯ Response status: {response.status_code}")
310
  st.write("πŸ“₯ Request URL:", response.url)
311
 
 
 
 
 
 
 
 
 
 
 
 
312
  # Debug: Print raw response
313
  try:
314
  response_json = response.json()
315
  st.write("Raw response:", response_json)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  except Exception as e:
317
  st.write("Could not parse response as JSON:", response.text)
318
 
 
293
 
294
  # Try finding by show_id
295
  query = f'(show_id,eq,"{show_id}")'
296
+ alt_query = f'(show_id,like,"{show_id}")' # Try alternative query format
297
+
298
  params = {
299
  "where": query
300
  }
301
+ alt_params = {
302
+ "where": alt_query
303
+ }
304
 
305
  # Debug: Print the request details
306
  st.write(f"πŸ“‘ Querying table: {table_url.split('/')[-1]}")
307
  st.write(f"πŸ” Query params: {params}")
308
 
309
+ # Try first query format
310
  try:
311
  response = requests.get(table_url, headers=headers, params=params)
 
 
312
  st.write(f"πŸ“₯ Response status: {response.status_code}")
313
  st.write("πŸ“₯ Request URL:", response.url)
314
 
315
+ # If first query returns no results, try alternative query
316
+ if response.status_code == 200:
317
+ data = response.json()
318
+ if not data.get('list'):
319
+ st.write("πŸ”„ Trying alternative query format...")
320
+ response = requests.get(table_url, headers=headers, params=alt_params)
321
+ st.write(f"πŸ“₯ Alt response status: {response.status_code}")
322
+ st.write("πŸ“₯ Alt request URL:", response.url)
323
+ if response.status_code == 200:
324
+ data = response.json()
325
+
326
  # Debug: Print raw response
327
  try:
328
  response_json = response.json()
329
  st.write("Raw response:", response_json)
330
+
331
+ # Additional debugging
332
+ if response_json.get('list'):
333
+ st.write("βœ… Found entries in response")
334
+ for entry in response_json['list']:
335
+ st.write(f"Entry show_id: {entry.get('show_id')}")
336
+ else:
337
+ st.write("❌ No entries found in response")
338
+
339
+ # Try to get a few random entries to verify data
340
+ sample_params = {
341
+ "limit": 3,
342
+ "shuffle": true
343
+ }
344
+ sample_response = requests.get(table_url, headers=headers, params=sample_params)
345
+ if sample_response.status_code == 200:
346
+ sample_data = sample_response.json()
347
+ st.write("πŸ” Random entries from table:")
348
+ for entry in sample_data.get('list', []):
349
+ st.write(f"- {entry.get('title')} (ID: {entry.get('show_id')})")
350
+
351
  except Exception as e:
352
  st.write("Could not parse response as JSON:", response.text)
353