ismdrobiul489 commited on
Commit
0f86d28
·
1 Parent(s): 8114dd9

Fix: get_video_path always returns Path (matching video_creator pattern)

Browse files
modules/story_reels/router.py CHANGED
@@ -3,7 +3,7 @@ Story Reels Router - API Endpoints
3
  Consistent with Video Creator API pattern
4
  """
5
  from fastapi import APIRouter, HTTPException
6
- from fastapi.responses import FileResponse, RedirectResponse
7
  import logging
8
 
9
  from .schemas import (
@@ -86,14 +86,17 @@ async def get_story_status(video_id: str):
86
  }
87
  )
88
  async def download_story_reel(video_id: str):
89
- """Download/stream a story reel - redirects to /videos static"""
90
  video_path = story_creator.get_video_path(video_id)
91
 
92
- if not video_path or not video_path.exists():
93
  raise HTTPException(status_code=404, detail="Video not found")
94
 
95
- # Redirect to /videos static mount for better streaming support
96
- return RedirectResponse(url=f"/videos/{video_id}.mp4", status_code=302)
 
 
 
97
 
98
 
99
  @router.get("/story-reels",
 
3
  Consistent with Video Creator API pattern
4
  """
5
  from fastapi import APIRouter, HTTPException
6
+ from fastapi.responses import FileResponse
7
  import logging
8
 
9
  from .schemas import (
 
86
  }
87
  )
88
  async def download_story_reel(video_id: str):
89
+ """Download/stream a story reel"""
90
  video_path = story_creator.get_video_path(video_id)
91
 
92
+ if not video_path.exists():
93
  raise HTTPException(status_code=404, detail="Video not found")
94
 
95
+ return FileResponse(
96
+ video_path,
97
+ media_type="video/mp4",
98
+ filename=f"story_{video_id}.mp4"
99
+ )
100
 
101
 
102
  @router.get("/story-reels",
modules/story_reels/services/story_creator.py CHANGED
@@ -116,12 +116,8 @@ class StoryCreator:
116
  }
117
 
118
  def get_video_path(self, job_id: str) -> Path:
119
- """Get video file path for download"""
120
- video_path = self.config.videos_dir_path / f"{job_id}.mp4"
121
- logger.info(f"Looking for video at: {video_path}, exists: {video_path.exists()}")
122
- if video_path.exists():
123
- return video_path
124
- return None
125
 
126
  def get_preview(self, job_id: str, scene_id: int) -> Dict:
127
  """Get scene preview"""
 
116
  }
117
 
118
  def get_video_path(self, job_id: str) -> Path:
119
+ """Get video file path (always returns Path, caller checks exists)"""
120
+ return self.config.videos_dir_path / f"{job_id}.mp4"
 
 
 
 
121
 
122
  def get_preview(self, job_id: str, scene_id: int) -> Dict:
123
  """Get scene preview"""