-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70cd534
commit 782af30
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package subtitle | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"connectrpc.com/connect" | ||
subtitle_proto "github.com/nandesh-dev/subtle/generated/proto/subtitle" | ||
"github.com/nandesh-dev/subtle/pkgs/db" | ||
"google.golang.org/protobuf/types/known/durationpb" | ||
) | ||
|
||
func (s ServiceHandler) GetSegment(ctx context.Context, req *connect.Request[subtitle_proto.GetSegmentRequest]) (*connect.Response[subtitle_proto.GetSegmentResponse], error) { | ||
var segmentEntry db.Segment | ||
|
||
if err := db.DB().Where(&db.Segment{ID: int(req.Msg.Id)}). | ||
First(&segmentEntry).Error; err != nil { | ||
return nil, fmt.Errorf("Error getting video entry: %v", err) | ||
} | ||
|
||
res := subtitle_proto.GetSegmentResponse{ | ||
Start: durationpb.New(segmentEntry.StartTime), | ||
End: durationpb.New(segmentEntry.EndTime), | ||
Original: &subtitle_proto.OriginalSegment{}, | ||
New: &subtitle_proto.NewSegment{ | ||
Text: segmentEntry.Text, | ||
}, | ||
} | ||
|
||
if segmentEntry.OriginalText == "" { | ||
res.Original.Image = segmentEntry.OriginalImage | ||
} else { | ||
res.Original.Text = &segmentEntry.OriginalText | ||
} | ||
|
||
return connect.NewResponse(&res), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters