mirror of
https://github.com/jimeh/go-midjourney.git
synced 2026-02-19 01:46:41 +00:00
feat(job): add support for _parsed_params job field
This commit is contained in:
37
algorithm_version.go
Normal file
37
algorithm_version.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package midjourney
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type AlgorithmVersion string
|
||||
|
||||
func (av *AlgorithmVersion) MarshalJSON() ([]byte, error) {
|
||||
n, err := strconv.Atoi(string(*av))
|
||||
if err != nil {
|
||||
return json.Marshal(string(*av))
|
||||
}
|
||||
|
||||
return json.Marshal(n)
|
||||
}
|
||||
|
||||
func (av *AlgorithmVersion) UnmarshalJSON(b []byte) error {
|
||||
var n int
|
||||
err := json.Unmarshal(b, &n)
|
||||
if err == nil {
|
||||
*av = AlgorithmVersion(strconv.Itoa(n))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var s string
|
||||
err = json.Unmarshal(b, &s)
|
||||
if err == nil {
|
||||
*av = AlgorithmVersion(s)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
109
job.go
109
job.go
@@ -20,46 +20,40 @@ const (
|
||||
JobStatusCompleted JobStatus = "completed"
|
||||
)
|
||||
|
||||
type Event struct {
|
||||
Height int `json:"height,omitempty"`
|
||||
TextPrompt []string `json:"textPrompt,omitempty"`
|
||||
ImagePrompts []string `json:"imagePrompts,omitempty"`
|
||||
Width int `json:"width,omitempty"`
|
||||
BatchSize int `json:"batchSize,omitempty"`
|
||||
SeedImageURL string `json:"seedImageURL,omitempty"`
|
||||
}
|
||||
|
||||
type Job struct {
|
||||
CurrentStatus JobStatus `json:"current_status,omitempty"`
|
||||
EnqueueTime Time `json:"enqueue_time,omitempty"`
|
||||
Event *Event `json:"event,omitempty"`
|
||||
Flagged bool `json:"flagged,omitempty"`
|
||||
FollowedByUser bool `json:"followed_by_user,omitempty"`
|
||||
GridID string `json:"grid_id,omitempty"`
|
||||
GridNum string `json:"grid_num,omitempty"`
|
||||
GuildID string `json:"guild_id,omitempty"`
|
||||
Hidden bool `json:"hidden,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
ImagePaths []string `json:"image_paths,omitempty"`
|
||||
IsPublished bool `json:"is_published,omitempty"`
|
||||
LikedByUser bool `json:"liked_by_user,omitempty"`
|
||||
LowPriority bool `json:"low_priority,omitempty"`
|
||||
Metered bool `json:"metered,omitempty"`
|
||||
ModHidden bool `json:"mod_hidden,omitempty"`
|
||||
Platform string `json:"platform,omitempty"`
|
||||
PlatformChannel string `json:"platform_channel,omitempty"`
|
||||
PlatformChannelID string `json:"platform_channel_id,omitempty"`
|
||||
PlatformMessageID string `json:"platform_message_id,omitempty"`
|
||||
PlatformThreadID string `json:"platform_thread_id,omitempty"`
|
||||
Prompt string `json:"prompt,omitempty"`
|
||||
RankedByUser bool `json:"ranked_by_user,omitempty"`
|
||||
RankingByUser int `json:"ranking_by_user,omitempty"`
|
||||
Type JobType `json:"type,omitempty"`
|
||||
UserID string `json:"user_id,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
FullCommand string `json:"full_command,omitempty"`
|
||||
ReferenceJobID string `json:"reference_job_id,omitempty"`
|
||||
ReferenceImageNum string `json:"reference_image_num,omitempty"`
|
||||
JobType string `json:"_job_type,omitempty"`
|
||||
Service string `json:"_service,omitempty"`
|
||||
ParsedParams *ParsedJobParams `json:"_parsed_params,omitempty"`
|
||||
CurrentStatus JobStatus `json:"current_status,omitempty"`
|
||||
EnqueueTime Time `json:"enqueue_time,omitempty"`
|
||||
Event *Event `json:"event,omitempty"`
|
||||
Flagged bool `json:"flagged,omitempty"`
|
||||
FollowedByUser bool `json:"followed_by_user,omitempty"`
|
||||
GridID string `json:"grid_id,omitempty"`
|
||||
GridNum string `json:"grid_num,omitempty"`
|
||||
GuildID string `json:"guild_id,omitempty"`
|
||||
Hidden bool `json:"hidden,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
ImagePaths []string `json:"image_paths,omitempty"`
|
||||
IsPublished bool `json:"is_published,omitempty"`
|
||||
LikedByUser bool `json:"liked_by_user,omitempty"`
|
||||
LowPriority bool `json:"low_priority,omitempty"`
|
||||
Metered bool `json:"metered,omitempty"`
|
||||
ModHidden bool `json:"mod_hidden,omitempty"`
|
||||
Platform string `json:"platform,omitempty"`
|
||||
PlatformChannel string `json:"platform_channel,omitempty"`
|
||||
PlatformChannelID string `json:"platform_channel_id,omitempty"`
|
||||
PlatformMessageID string `json:"platform_message_id,omitempty"`
|
||||
PlatformThreadID string `json:"platform_thread_id,omitempty"`
|
||||
Prompt string `json:"prompt,omitempty"`
|
||||
RankedByUser bool `json:"ranked_by_user,omitempty"`
|
||||
RankingByUser int `json:"ranking_by_user,omitempty"`
|
||||
Type JobType `json:"type,omitempty"`
|
||||
UserID string `json:"user_id,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
FullCommand string `json:"full_command,omitempty"`
|
||||
ReferenceJobID string `json:"reference_job_id,omitempty"`
|
||||
ReferenceImageNum string `json:"reference_image_num,omitempty"`
|
||||
}
|
||||
|
||||
func (j *Job) DiscordURL() string {
|
||||
@@ -90,3 +84,40 @@ func (j *Job) ImageFilename() string {
|
||||
|
||||
return fmt.Sprintf("%s_%s.png", s, j.ID)
|
||||
}
|
||||
|
||||
func (j *Job) VideoURL() string {
|
||||
if j.Type != JobTypeGrid {
|
||||
return ""
|
||||
}
|
||||
|
||||
return fmt.Sprintf("https://i.mj.run/%s/video.mp4", j.ID)
|
||||
}
|
||||
|
||||
type Event struct {
|
||||
Height int `json:"height,omitempty"`
|
||||
TextPrompt []string `json:"textPrompt,omitempty"`
|
||||
ImagePrompts []string `json:"imagePrompts,omitempty"`
|
||||
Width int `json:"width,omitempty"`
|
||||
BatchSize int `json:"batchSize,omitempty"`
|
||||
SeedImageURL string `json:"seedImageURL,omitempty"`
|
||||
}
|
||||
|
||||
type ParsedJobParams struct {
|
||||
Anime bool `json:"anime,omitempty"`
|
||||
Aspect string `json:"aspect,omitempty"`
|
||||
Creative bool `json:"creative,omitempty"`
|
||||
Fast bool `json:"fast,omitempty"`
|
||||
HD bool `json:"hd,omitempty"`
|
||||
No []string `json:"no,omitempty"`
|
||||
Style string `json:"style,omitempty"`
|
||||
Stylize int `json:"stylize,omitempty"`
|
||||
Test bool `json:"test,omitempty"`
|
||||
Testp bool `json:"testp,omitempty"`
|
||||
Tile bool `json:"tile,omitempty"`
|
||||
Upanime bool `json:"upanime,omitempty"`
|
||||
Upbeta bool `json:"upbeta,omitempty"`
|
||||
Uplight bool `json:"uplight,omitempty"`
|
||||
Version AlgorithmVersion `json:"version,omitempty"`
|
||||
Vibe bool `json:"vibe,omitempty"`
|
||||
Video bool `json:"video,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user