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
c297f42c
authored
Nov 13, 2025
by
feitianbubu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: get hailuo video url
parent
b242d4c7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
21 deletions
+68
-21
controller/task_video.go
+1
-0
model/task.go
+11
-0
relay/channel/task/hailuo/adaptor.go
+40
-20
relay/channel/task/hailuo/models.go
+16
-1
No files found.
controller/task_video.go
View file @
c297f42c
...
@@ -52,6 +52,7 @@ func updateVideoTaskAll(ctx context.Context, platform constant.TaskPlatform, cha
...
@@ -52,6 +52,7 @@ func updateVideoTaskAll(ctx context.Context, platform constant.TaskPlatform, cha
info
.
ChannelMeta
=
&
relaycommon
.
ChannelMeta
{
info
.
ChannelMeta
=
&
relaycommon
.
ChannelMeta
{
ChannelBaseUrl
:
cacheGetChannel
.
GetBaseURL
(),
ChannelBaseUrl
:
cacheGetChannel
.
GetBaseURL
(),
}
}
info
.
ApiKey
=
cacheGetChannel
.
Key
adaptor
.
Init
(
info
)
adaptor
.
Init
(
info
)
for
_
,
taskId
:=
range
taskIds
{
for
_
,
taskId
:=
range
taskIds
{
if
err
:=
updateVideoSingleTask
(
ctx
,
adaptor
,
cacheGetChannel
,
taskId
,
taskM
);
err
!=
nil
{
if
err
:=
updateVideoSingleTask
(
ctx
,
adaptor
,
cacheGetChannel
,
taskId
,
taskM
);
err
!=
nil
{
...
...
model/task.go
View file @
c297f42c
...
@@ -429,3 +429,14 @@ func TaskCountAllUserTask(userId int, queryParams SyncTaskQueryParams) int64 {
...
@@ -429,3 +429,14 @@ func TaskCountAllUserTask(userId int, queryParams SyncTaskQueryParams) int64 {
_
=
query
.
Count
(
&
total
)
.
Error
_
=
query
.
Count
(
&
total
)
.
Error
return
total
return
total
}
}
func
(
t
*
Task
)
ToOpenAIVideo
()
*
dto
.
OpenAIVideo
{
openAIVideo
:=
dto
.
NewOpenAIVideo
()
openAIVideo
.
ID
=
t
.
TaskID
openAIVideo
.
Status
=
t
.
Status
.
ToVideoStatus
()
openAIVideo
.
Model
=
t
.
Properties
.
OriginModelName
openAIVideo
.
SetProgressStr
(
t
.
Progress
)
openAIVideo
.
CreatedAt
=
t
.
CreatedAt
openAIVideo
.
CompletedAt
=
t
.
UpdatedAt
openAIVideo
.
SetMetadata
(
"url"
,
t
.
FailReason
)
return
openAIVideo
}
relay/channel/task/hailuo/adaptor.go
View file @
c297f42c
...
@@ -12,7 +12,6 @@ import (
...
@@ -12,7 +12,6 @@ import (
"github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/model"
"github.com/QuantumNous/new-api/model"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"github.com/pkg/errors"
...
@@ -259,11 +258,7 @@ func (a *TaskAdaptor) ParseTaskResult(respBody []byte) (*relaycommon.TaskInfo, e
...
@@ -259,11 +258,7 @@ func (a *TaskAdaptor) ParseTaskResult(respBody []byte) (*relaycommon.TaskInfo, e
case
TaskStatusSuccess
:
case
TaskStatusSuccess
:
taskResult
.
Status
=
model
.
TaskStatusSuccess
taskResult
.
Status
=
model
.
TaskStatusSuccess
taskResult
.
Progress
=
"100%"
taskResult
.
Progress
=
"100%"
if
resTask
.
VideoURL
!=
""
{
taskResult
.
Url
=
a
.
buildVideoURL
(
resTask
.
TaskID
,
resTask
.
FileID
)
taskResult
.
Url
=
resTask
.
VideoURL
}
else
if
resTask
.
FileID
!=
""
{
taskResult
.
Url
=
fmt
.
Sprintf
(
"https://api.minimaxi.com/v1/files/download?file_id=%s"
,
resTask
.
FileID
)
}
case
TaskStatusFailed
:
case
TaskStatusFailed
:
taskResult
.
Status
=
model
.
TaskStatusFailure
taskResult
.
Status
=
model
.
TaskStatusFailure
taskResult
.
Progress
=
"100%"
taskResult
.
Progress
=
"100%"
...
@@ -284,20 +279,7 @@ func (a *TaskAdaptor) ConvertToOpenAIVideo(originTask *model.Task) ([]byte, erro
...
@@ -284,20 +279,7 @@ func (a *TaskAdaptor) ConvertToOpenAIVideo(originTask *model.Task) ([]byte, erro
return
nil
,
errors
.
Wrap
(
err
,
"unmarshal hailuo task data failed"
)
return
nil
,
errors
.
Wrap
(
err
,
"unmarshal hailuo task data failed"
)
}
}
openAIVideo
:=
dto
.
NewOpenAIVideo
()
openAIVideo
:=
originTask
.
ToOpenAIVideo
()
openAIVideo
.
ID
=
originTask
.
TaskID
openAIVideo
.
Status
=
originTask
.
Status
.
ToVideoStatus
()
openAIVideo
.
SetProgressStr
(
originTask
.
Progress
)
openAIVideo
.
CreatedAt
=
originTask
.
CreatedAt
openAIVideo
.
CompletedAt
=
originTask
.
UpdatedAt
if
hailuoResp
.
VideoURL
!=
""
{
openAIVideo
.
SetMetadata
(
"url"
,
hailuoResp
.
VideoURL
)
}
else
if
hailuoResp
.
FileID
!=
""
{
openAIVideo
.
SetMetadata
(
"file_id"
,
hailuoResp
.
FileID
)
openAIVideo
.
SetMetadata
(
"url"
,
fmt
.
Sprintf
(
"https://api.minimaxi.com/v1/files/download?file_id=%s"
,
hailuoResp
.
FileID
))
}
if
hailuoResp
.
BaseResp
.
StatusCode
!=
StatusSuccess
{
if
hailuoResp
.
BaseResp
.
StatusCode
!=
StatusSuccess
{
openAIVideo
.
Error
=
&
dto
.
OpenAIVideoError
{
openAIVideo
.
Error
=
&
dto
.
OpenAIVideoError
{
Message
:
hailuoResp
.
BaseResp
.
StatusMsg
,
Message
:
hailuoResp
.
BaseResp
.
StatusMsg
,
...
@@ -313,6 +295,44 @@ func (a *TaskAdaptor) ConvertToOpenAIVideo(originTask *model.Task) ([]byte, erro
...
@@ -313,6 +295,44 @@ func (a *TaskAdaptor) ConvertToOpenAIVideo(originTask *model.Task) ([]byte, erro
return
jsonData
,
nil
return
jsonData
,
nil
}
}
func
(
a
*
TaskAdaptor
)
buildVideoURL
(
_
,
fileID
string
)
string
{
if
a
.
apiKey
==
""
||
a
.
baseURL
==
""
{
return
""
}
url
:=
fmt
.
Sprintf
(
"%s/v1/files/retrieve?file_id=%s"
,
a
.
baseURL
,
fileID
)
req
,
err
:=
http
.
NewRequest
(
http
.
MethodGet
,
url
,
nil
)
if
err
!=
nil
{
return
""
}
req
.
Header
.
Set
(
"Accept"
,
"application/json"
)
req
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
a
.
apiKey
)
resp
,
err
:=
service
.
GetHttpClient
()
.
Do
(
req
)
if
err
!=
nil
{
return
""
}
defer
resp
.
Body
.
Close
()
responseBody
,
err
:=
io
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
return
""
}
var
retrieveResp
RetrieveFileResponse
if
err
:=
json
.
Unmarshal
(
responseBody
,
&
retrieveResp
);
err
!=
nil
{
return
""
}
if
retrieveResp
.
BaseResp
.
StatusCode
!=
StatusSuccess
{
return
""
}
return
retrieveResp
.
File
.
DownloadURL
}
func
contains
(
slice
[]
string
,
item
string
)
bool
{
func
contains
(
slice
[]
string
,
item
string
)
bool
{
for
_
,
s
:=
range
slice
{
for
_
,
s
:=
range
slice
{
if
s
==
item
{
if
s
==
item
{
...
...
relay/channel/task/hailuo/models.go
View file @
c297f42c
...
@@ -29,7 +29,8 @@ type QueryTaskResponse struct {
...
@@ -29,7 +29,8 @@ type QueryTaskResponse struct {
TaskID
string
`json:"task_id"`
TaskID
string
`json:"task_id"`
Status
string
`json:"status"`
Status
string
`json:"status"`
FileID
string
`json:"file_id,omitempty"`
FileID
string
`json:"file_id,omitempty"`
VideoURL
string
`json:"video_url,omitempty"`
VideoWidth
int
`json:"video_width,omitempty"`
VideoHeight
int
`json:"video_height,omitempty"`
BaseResp
BaseResp
`json:"base_resp"`
BaseResp
BaseResp
`json:"base_resp"`
}
}
...
@@ -56,6 +57,20 @@ type ModelConfig struct {
...
@@ -56,6 +57,20 @@ type ModelConfig struct {
HasFastPretreatment
bool
HasFastPretreatment
bool
}
}
type
RetrieveFileResponse
struct
{
File
FileObject
`json:"file"`
BaseResp
BaseResp
`json:"base_resp"`
}
type
FileObject
struct
{
FileID
int64
`json:"file_id"`
Bytes
int64
`json:"bytes"`
CreatedAt
int64
`json:"created_at"`
Filename
string
`json:"filename"`
Purpose
string
`json:"purpose"`
DownloadURL
string
`json:"download_url"`
}
func
GetModelConfig
(
model
string
)
ModelConfig
{
func
GetModelConfig
(
model
string
)
ModelConfig
{
configs
:=
map
[
string
]
ModelConfig
{
configs
:=
map
[
string
]
ModelConfig
{
"MiniMax-Hailuo-2.3"
:
{
"MiniMax-Hailuo-2.3"
:
{
...
...
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