Lakpriya Seneviratna commited on
Commit
fbd693e
·
1 Parent(s): 58f3513

chore: Update generate_video route in FastAPI to include access_token and open_id parameters

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -641,8 +641,12 @@ async def tiktok_callback(request: Request):
641
  # Log the exception for debugging purposes
642
  print(f"Exception occurred: {str(e)}")
643
  raise HTTPException(status_code=500, detail="Internal Server Error")
 
644
  @app.get("/generate_video")
645
- def generate_video():
 
 
 
646
  try:
647
  api_key = 'VhLwkCKi3iu5Pf37LXfz-Lp7hTW69EV8uw_hkLAPkiA' # Replace with your Unsplash API key
648
  background_image = fetch_random_nature_image(api_key)
@@ -671,6 +675,10 @@ def generate_video():
671
  # Combine the final video and audio
672
  combine_audio_video(video_filename, combined_audio_file, final_filename + '.mp4')
673
 
 
 
 
 
674
  return {"status": "success", "filename": final_filename + '.mp4'}
675
  else:
676
  return {"status": "failed", "message": "Failed to fetch background image"}
 
641
  # Log the exception for debugging purposes
642
  print(f"Exception occurred: {str(e)}")
643
  raise HTTPException(status_code=500, detail="Internal Server Error")
644
+
645
  @app.get("/generate_video")
646
+ def generate_video(request: Request):
647
+ access_token = request.query_params.get('access_token')
648
+ open_id = request.query_params.get('open_id')
649
+
650
  try:
651
  api_key = 'VhLwkCKi3iu5Pf37LXfz-Lp7hTW69EV8uw_hkLAPkiA' # Replace with your Unsplash API key
652
  background_image = fetch_random_nature_image(api_key)
 
675
  # Combine the final video and audio
676
  combine_audio_video(video_filename, combined_audio_file, final_filename + '.mp4')
677
 
678
+ video_path = os.path.join(output_folder, final_filename + '.mp4')
679
+
680
+ upload_video_to_tiktok(access_token, open_id, video_path)
681
+
682
  return {"status": "success", "filename": final_filename + '.mp4'}
683
  else:
684
  return {"status": "failed", "message": "Failed to fetch background image"}