Phoenixak99 commited on
Commit
68d3b7b
·
verified ·
1 Parent(s): f18d4f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -284,19 +284,27 @@ if st.session_state.get("jwt_token"):
284
  else:
285
  is_free_tier = True # Default to free tier if not logged in
286
 
287
- # Add this debug section before the duration slider
288
  if st.session_state.get("jwt_token"):
289
  auth_headers = get_auth_headers()
290
  subscription_url = "https://songlabai.com/wp-json/custom-api/v1/subscription"
291
- response = requests.get(subscription_url, headers=auth_headers)
292
 
293
- if response.status_code == 200:
294
- data = response.json()
 
 
 
 
 
295
  st.write("Debug Info:")
296
- st.json(data) # This will show the full API response
297
- st.write(f"Is Free Tier: {not data.get('subscription_plan_id') or data.get('subscription_plan_id') == 576}")
 
298
  else:
299
- st.write(f"API Error: {response.status_code}")
 
 
300
 
301
  # Show appropriate duration slider based on subscription tier
302
  if is_free_tier:
@@ -484,7 +492,7 @@ def generate_audio(genre, energy_level, tempo, description, duration):
484
  subscription_data = subscription_response.json()
485
 
486
  # Check for free tier duration restriction
487
- is_free_tier = not subscription_plan_id or subscription_plan_id == 576
488
  if is_free_tier:
489
  if duration > 30:
490
  st.warning("⚠️ Free tier users are limited to 30-second generations.")
 
284
  else:
285
  is_free_tier = True # Default to free tier if not logged in
286
 
287
+ # First, check subscription status if user is logged in
288
  if st.session_state.get("jwt_token"):
289
  auth_headers = get_auth_headers()
290
  subscription_url = "https://songlabai.com/wp-json/custom-api/v1/subscription"
291
+ subscription_response = requests.get(subscription_url, headers=auth_headers)
292
 
293
+ if subscription_response.status_code == 200:
294
+ subscription_data = subscription_response.json()
295
+ # Convert subscription_plan_id to string for comparison
296
+ subscription_plan_id = str(subscription_data.get("subscription_plan_id"))
297
+ is_free_tier = subscription_plan_id == "576" or subscription_data.get("status") == "no_subscription"
298
+
299
+ # Debug info
300
  st.write("Debug Info:")
301
+ st.json(subscription_data)
302
+ st.write(f"Subscription Plan ID: {subscription_plan_id}")
303
+ st.write(f"Is Free Tier: {is_free_tier}")
304
  else:
305
+ is_free_tier = True # Default to free tier if unable to verify
306
+ else:
307
+ is_free_tier = True # Default to free tier if not logged in
308
 
309
  # Show appropriate duration slider based on subscription tier
310
  if is_free_tier:
 
492
  subscription_data = subscription_response.json()
493
 
494
  # Check for free tier duration restriction
495
+ is_free_tier = subscription_plan_id == "576" or subscription_data.get("status") == "no_subscription"
496
  if is_free_tier:
497
  if duration > 30:
498
  st.warning("⚠️ Free tier users are limited to 30-second generations.")