Fix plugin go examples (#2396)

This commit is contained in:
bnkai
2022-03-24 02:03:32 +02:00
committed by GitHub
parent 0cd9a0a474
commit 627c1e9c60
3 changed files with 10 additions and 7 deletions

View File

@@ -29,8 +29,8 @@ type TagDestroyInput struct {
type FindScenesResultType struct { type FindScenesResultType struct {
Count graphql.Int Count graphql.Int
DurationSeconds graphql.Float DurationSeconds graphql.Float `graphql:"duration" json:"duration"`
FilesizeBytes graphql.Int FilesizeBytes graphql.Float `graphql:"filesize" json:"filesize"`
Scenes []Scene Scenes []Scene
} }

View File

@@ -4,6 +4,7 @@
package main package main
import ( import (
"context"
"encoding/json" "encoding/json"
"io" "io"
"os" "os"
@@ -54,14 +55,14 @@ func main() {
func Run(input common.PluginInput, output *common.PluginOutput) error { func Run(input common.PluginInput, output *common.PluginOutput) error {
modeArg := input.Args.String("mode") modeArg := input.Args.String("mode")
ctx := context.TODO()
var err error var err error
if modeArg == "" || modeArg == "add" { if modeArg == "" || modeArg == "add" {
client := util.NewClient(input.ServerConnection) client := util.NewClient(input.ServerConnection)
err = exampleCommon.AddTag(client) err = exampleCommon.AddTag(ctx, client)
} else if modeArg == "remove" { } else if modeArg == "remove" {
client := util.NewClient(input.ServerConnection) client := util.NewClient(input.ServerConnection)
err = exampleCommon.RemoveTag(client) err = exampleCommon.RemoveTag(ctx, client)
} else if modeArg == "long" { } else if modeArg == "long" {
err = doLongTask() err = doLongTask()
} else if modeArg == "indef" { } else if modeArg == "indef" {

View File

@@ -4,6 +4,7 @@
package main package main
import ( import (
"context"
"time" "time"
exampleCommon "github.com/stashapp/stash/pkg/plugin/examples/common" exampleCommon "github.com/stashapp/stash/pkg/plugin/examples/common"
@@ -37,14 +38,15 @@ func (a *api) Stop(input struct{}, output *bool) error {
// acts accordingly. // acts accordingly.
func (a *api) Run(input common.PluginInput, output *common.PluginOutput) error { func (a *api) Run(input common.PluginInput, output *common.PluginOutput) error {
modeArg := input.Args.String("mode") modeArg := input.Args.String("mode")
ctx := context.TODO()
var err error var err error
if modeArg == "" || modeArg == "add" { if modeArg == "" || modeArg == "add" {
client := util.NewClient(input.ServerConnection) client := util.NewClient(input.ServerConnection)
err = exampleCommon.AddTag(client) err = exampleCommon.AddTag(ctx, client)
} else if modeArg == "remove" { } else if modeArg == "remove" {
client := util.NewClient(input.ServerConnection) client := util.NewClient(input.ServerConnection)
err = exampleCommon.RemoveTag(client) err = exampleCommon.RemoveTag(ctx, client)
} else if modeArg == "long" { } else if modeArg == "long" {
err = a.doLongTask() err = a.doLongTask()
} else if modeArg == "indef" { } else if modeArg == "indef" {