Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b1db1264
authored
Oct 09, 2025
by
feitianbubu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add sora video retrieve task
parent
1d1759aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
36 deletions
+33
-36
controller/task_video.go
+5
-0
relay/channel/task/sora/adaptor.go
+28
-36
No files found.
controller/task_video.go
View file @
b1db1264
...
...
@@ -47,6 +47,11 @@ func updateVideoTaskAll(ctx context.Context, platform constant.TaskPlatform, cha
if
adaptor
==
nil
{
return
fmt
.
Errorf
(
"video adaptor not found"
)
}
info
:=
&
relaycommon
.
RelayInfo
{}
info
.
ChannelMeta
=
&
relaycommon
.
ChannelMeta
{
ChannelBaseUrl
:
cacheGetChannel
.
GetBaseURL
(),
}
adaptor
.
Init
(
info
)
for
_
,
taskId
:=
range
taskIds
{
if
err
:=
updateVideoSingleTask
(
ctx
,
adaptor
,
cacheGetChannel
,
taskId
,
taskM
);
err
!=
nil
{
logger
.
LogError
(
ctx
,
fmt
.
Sprintf
(
"Failed to update video task %s: %s"
,
taskId
,
err
.
Error
()))
...
...
relay/channel/task/sora/adaptor.go
View file @
b1db1264
...
...
@@ -36,23 +36,21 @@ type responsePayload struct {
}
type
responseTask
struct
{
ID
string
`json:"id"`
Model
string
`json:"model"`
Status
string
`json:"status"`
Content
struct
{
VideoURL
string
`json:"video_url"`
}
`json:"content"`
Seed
int
`json:"seed"`
Resolution
string
`json:"resolution"`
Duration
int
`json:"duration"`
AspectRatio
string
`json:"aspect_ratio"`
Usage
struct
{
PromptTokens
int
`json:"prompt_tokens"`
CompletionTokens
int
`json:"completion_tokens"`
TotalTokens
int
`json:"total_tokens"`
}
`json:"usage"`
CreatedAt
int64
`json:"created_at"`
UpdatedAt
int64
`json:"updated_at"`
ID
string
`json:"id"`
Object
string
`json:"object"`
Model
string
`json:"model"`
Status
string
`json:"status"`
Progress
int
`json:"progress"`
CreatedAt
int64
`json:"created_at"`
CompletedAt
int64
`json:"completed_at,omitempty"`
ExpiresAt
int64
`json:"expires_at,omitempty"`
Seconds
string
`json:"seconds,omitempty"`
Size
string
`json:"size,omitempty"`
RemixedFromVideoID
string
`json:"remixed_from_video_id,omitempty"`
Error
*
struct
{
Message
string
`json:"message"`
Code
string
`json:"code"`
}
`json:"error,omitempty"`
}
// ============================
...
...
@@ -131,15 +129,13 @@ func (a *TaskAdaptor) FetchTask(baseUrl, key string, body map[string]any) (*http
return
nil
,
fmt
.
Errorf
(
"invalid task_id"
)
}
uri
:=
fmt
.
Sprintf
(
"%s/v1/videos/
generations/
%s"
,
baseUrl
,
taskID
)
uri
:=
fmt
.
Sprintf
(
"%s/v1/videos/%s"
,
baseUrl
,
taskID
)
req
,
err
:=
http
.
NewRequest
(
http
.
MethodGet
,
uri
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
req
.
Header
.
Set
(
"Accept"
,
"application/json"
)
req
.
Header
.
Set
(
"Content-Type"
,
"application/json"
)
req
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
key
)
return
service
.
GetHttpClient
()
.
Do
(
req
)
...
...
@@ -163,29 +159,25 @@ func (a *TaskAdaptor) ParseTaskResult(respBody []byte) (*relaycommon.TaskInfo, e
Code
:
0
,
}
// Map Sora status to internal status
switch
resTask
.
Status
{
case
"
pending"
,
"queued
"
:
case
"
queued"
,
"pending
"
:
taskResult
.
Status
=
model
.
TaskStatusQueued
taskResult
.
Progress
=
"10%"
case
"processing"
,
"running"
:
case
"processing"
,
"in_progress"
:
taskResult
.
Status
=
model
.
TaskStatusInProgress
taskResult
.
Progress
=
"50%"
case
"succeeded"
,
"completed"
:
case
"completed"
:
taskResult
.
Status
=
model
.
TaskStatusSuccess
taskResult
.
Progress
=
"100%"
taskResult
.
Url
=
resTask
.
Content
.
VideoURL
// Parse usage information for billing
taskResult
.
CompletionTokens
=
resTask
.
Usage
.
CompletionTokens
taskResult
.
TotalTokens
=
resTask
.
Usage
.
TotalTokens
taskResult
.
Url
=
fmt
.
Sprintf
(
"%s/v1/videos/%s/content"
,
a
.
baseURL
,
resTask
.
ID
)
case
"failed"
,
"cancelled"
:
taskResult
.
Status
=
model
.
TaskStatusFailure
taskResult
.
Progress
=
"100%"
taskResult
.
Reason
=
"task failed"
if
resTask
.
Error
!=
nil
{
taskResult
.
Reason
=
resTask
.
Error
.
Message
}
else
{
taskResult
.
Reason
=
"task failed"
}
default
:
// Unknown status, treat as processing
taskResult
.
Status
=
model
.
TaskStatusInProgress
taskResult
.
Progress
=
"30%"
}
if
resTask
.
Progress
>
0
&&
resTask
.
Progress
<
100
{
taskResult
.
Progress
=
fmt
.
Sprintf
(
"%d%%"
,
resTask
.
Progress
)
}
return
&
taskResult
,
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment