♻️ Extract fs parameter for test
This commit is contained in:
1 parent
66f7e0c412
commit
5c0a1c9127
51 files changed
+161
-76
No files matched your search
@@ -19,6 +19,7 @@ go_library(
|
||||
"Arch": "{STABLE_ARCH}",
|
||||
},
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"@com_github_mark3labs_mcp_go//server",
|
||||
"@com_github_savioxavier_termlink//:termlink",
|
||||
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -23,8 +24,8 @@ var authCmd = &cobra.Command{
|
||||
Long: authLong,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
auth.NewY2BService(
|
||||
auth.WithCredential(credential),
|
||||
auth.WithCacheToken(cacheToken),
|
||||
auth.WithCredential(credential, pkg.Fsys),
|
||||
auth.WithCacheToken(cacheToken, pkg.Fsys),
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
+4
-1
@@ -2,7 +2,10 @@ load("@rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "pkg",
|
||||
srcs = ["interface.go"],
|
||||
srcs = [
|
||||
"fs.go",
|
||||
"interface.go",
|
||||
],
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/activity",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,5 +18,5 @@ go_test(
|
||||
name = "activity_test",
|
||||
srcs = ["activity_test.go"],
|
||||
embed = [":activity"],
|
||||
deps = ["//pkg/utils"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -163,8 +164,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *activity) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
load("@rules_go//go:def.bzl", "go_library")
|
||||
load("@rules_go//go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "auth",
|
||||
@@ -16,3 +16,9 @@ go_library(
|
||||
"@org_golang_x_oauth2//google",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "auth_test",
|
||||
srcs = ["service_test.go"],
|
||||
embed = [":auth"],
|
||||
)
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
const (
|
||||
cacheTokenFile = "youtube.token.json"
|
||||
credentialFile = "client_secret.json"
|
||||
manualInputHint = `
|
||||
After completing the authorization flow, enter the authorization code on command line.
|
||||
|
||||
|
||||
+19
-19
@@ -5,9 +5,11 @@ import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
@@ -21,15 +23,7 @@ var (
|
||||
errReadSecret = errors.New("unable to read client secret")
|
||||
)
|
||||
|
||||
const missingClientSecretsHint string = `
|
||||
Please configure OAuth 2.0
|
||||
You need to populate the client_secrets.json file
|
||||
found at: %s
|
||||
with information from the {{ Google Cloud Console }}
|
||||
{{ https://cloud.google.com/console }}
|
||||
For more information about the client_secrets.json file format, please visit:
|
||||
https://developers.google.com/api-client-library/python/guide/aaa_client_secrets
|
||||
`
|
||||
const missingClientSecretsHint string = "Please configure client secrets as described in https://github.com/eat-pray-ai/yutu#prerequisites"
|
||||
|
||||
type svc struct {
|
||||
Cacheable bool `yaml:"cacheable" json:"cacheable"`
|
||||
@@ -62,23 +56,26 @@ func NewY2BService(opts ...Option) Svc {
|
||||
return s
|
||||
}
|
||||
|
||||
func WithCredential(cred string) Option {
|
||||
func WithCredential(cred string, fsys fs.FS) Option {
|
||||
return func(s *svc) {
|
||||
// cred > YUTU_CREDENTIAL
|
||||
envCred, ok := os.LookupEnv("YUTU_CREDENTIAL")
|
||||
if cred == "" && ok {
|
||||
cred = envCred
|
||||
} else if cred == "" {
|
||||
cred = "client_secret.json"
|
||||
cred = credentialFile
|
||||
}
|
||||
|
||||
// 1. cred is a file path
|
||||
// 2. cred is a base64 encoded string
|
||||
// 3. cred is a json string
|
||||
if _, err := os.Stat(cred); err == nil {
|
||||
credBytes, err := os.ReadFile(cred)
|
||||
absCred, _ := filepath.Abs(cred)
|
||||
relCred, _ := filepath.Rel("/", absCred)
|
||||
|
||||
if _, err := fs.Stat(fsys, relCred); err == nil {
|
||||
// credBytes, err := yfs.ReadFile(cred)
|
||||
credBytes, err := fs.ReadFile(fsys, relCred)
|
||||
if err != nil {
|
||||
fmt.Printf(missingClientSecretsHint, cred)
|
||||
fmt.Println(missingClientSecretsHint)
|
||||
log.Fatalln(errors.Join(errReadSecret, err))
|
||||
}
|
||||
s.Credential = string(credBytes)
|
||||
@@ -90,13 +87,13 @@ func WithCredential(cred string) Option {
|
||||
} else if utils.IsJson(cred) {
|
||||
s.Credential = cred
|
||||
} else {
|
||||
fmt.Printf(missingClientSecretsHint, cred)
|
||||
fmt.Println(missingClientSecretsHint)
|
||||
log.Fatalln(errors.Join(errReadSecret, err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func WithCacheToken(token string) Option {
|
||||
func WithCacheToken(token string, fsys fs.FS) Option {
|
||||
return func(s *svc) {
|
||||
// token > YUTU_CACHE_TOKEN
|
||||
envToken, ok := os.LookupEnv("YUTU_CACHE_TOKEN")
|
||||
@@ -109,8 +106,11 @@ func WithCacheToken(token string) Option {
|
||||
// 1. token is a file path
|
||||
// 2. token is a base64 encoded string
|
||||
// 3. token is a json string
|
||||
if _, err := os.Stat(token); err == nil {
|
||||
tokenBytes, err := os.ReadFile(token)
|
||||
absToken, _ := filepath.Abs(token)
|
||||
relToken, _ := filepath.Rel("/", absToken)
|
||||
|
||||
if _, err := fs.Stat(fsys, relToken); err == nil {
|
||||
tokenBytes, err := fs.ReadFile(fsys, relToken)
|
||||
if err != nil {
|
||||
log.Fatalln(errors.Join(errReadToken, err))
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/caption",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,5 +18,5 @@ go_test(
|
||||
name = "caption_test",
|
||||
srcs = ["caption_test.go"],
|
||||
embed = [":caption"],
|
||||
deps = ["//pkg/utils"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -403,8 +404,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *caption) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/channel",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,5 +18,5 @@ go_test(
|
||||
name = "channel_test",
|
||||
srcs = ["channel_test.go"],
|
||||
embed = [":channel"],
|
||||
deps = ["//pkg/utils"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -280,8 +281,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *channel) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/channelBanner",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@org_golang_google_api//youtube/v3:youtube",
|
||||
@@ -16,4 +17,5 @@ go_test(
|
||||
name = "channelBanner_test",
|
||||
srcs = ["channelBanner_test.go"],
|
||||
embed = [":channelBanner"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"google.golang.org/api/youtube/v3"
|
||||
@@ -103,8 +104,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *channelBanner) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/channelSection",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,5 +18,5 @@ go_test(
|
||||
name = "channelSection_test",
|
||||
srcs = ["channelSection_test.go"],
|
||||
embed = [":channelSection"],
|
||||
deps = ["//pkg/utils"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -151,8 +152,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *channelSection) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/comment",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,5 +18,5 @@ go_test(
|
||||
name = "comment_test",
|
||||
srcs = ["comment_test.go"],
|
||||
embed = [":comment"],
|
||||
deps = ["//pkg/utils"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -335,8 +336,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *comment) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/commentThread",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,4 +18,5 @@ go_test(
|
||||
name = "commentThread_test",
|
||||
srcs = ["commentThread_test.go"],
|
||||
embed = [":commentThread"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -236,8 +237,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *commentThread) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package pkg
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"os"
|
||||
)
|
||||
|
||||
var Fsys fs.FS
|
||||
|
||||
func init() {
|
||||
root, err := os.OpenRoot("/")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
Fsys = root.FS()
|
||||
}
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/i18nLanguage",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,4 +18,5 @@ go_test(
|
||||
name = "i18nLanguage_test",
|
||||
srcs = ["i18nLanguage_test.go"],
|
||||
embed = [":i18nLanguage"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -87,8 +88,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *i18nLanguage) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/i18nRegion",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,4 +18,5 @@ go_test(
|
||||
name = "i18nRegion_test",
|
||||
srcs = ["i18nRegion_test.go"],
|
||||
embed = [":i18nRegion"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -87,8 +88,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *i18nRegion) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/member",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,4 +18,5 @@ go_test(
|
||||
name = "member_test",
|
||||
srcs = ["member_test.go"],
|
||||
embed = [":member"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -123,8 +124,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *member) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/membershipsLevel",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,4 +18,5 @@ go_test(
|
||||
name = "membershipsLevel_test",
|
||||
srcs = ["membershipsLevel_test.go"],
|
||||
embed = [":membershipsLevel"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -77,8 +78,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *membershipsLevel) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/playlist",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,5 +18,5 @@ go_test(
|
||||
name = "playlist_test",
|
||||
srcs = ["playlist_test.go"],
|
||||
embed = [":playlist"],
|
||||
deps = ["//pkg/utils"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -283,8 +284,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *playlist) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/playlistImage",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,4 +18,5 @@ go_test(
|
||||
name = "playlistImage_test",
|
||||
srcs = ["playlistImage_test.go"],
|
||||
embed = [":playlistImage"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -290,8 +291,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(pi *playlistImage) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/playlistItem",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,4 +18,5 @@ go_test(
|
||||
name = "playlistItem_test",
|
||||
srcs = ["playlistItem_test.go"],
|
||||
embed = [":playlistItem"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -326,8 +327,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *playlistItem) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/search",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,5 +18,5 @@ go_test(
|
||||
name = "search_test",
|
||||
srcs = ["search_test.go"],
|
||||
embed = [":search"],
|
||||
deps = ["//pkg/utils"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -413,8 +414,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *search) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/subscription",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,5 +18,5 @@ go_test(
|
||||
name = "subscription_test",
|
||||
srcs = ["subscription_test.go"],
|
||||
embed = [":subscription"],
|
||||
deps = ["//pkg/utils"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -269,8 +270,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *subscription) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/superChatEvent",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,4 +18,5 @@ go_test(
|
||||
name = "superChatEvent_test",
|
||||
srcs = ["superChatEvent_test.go"],
|
||||
embed = [":superChatEvent"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -103,8 +104,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *superChatEvent) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/thumbnail",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@org_golang_google_api//youtube/v3:youtube",
|
||||
@@ -16,4 +17,5 @@ go_test(
|
||||
name = "thumbnail_test",
|
||||
srcs = ["thumbnail_test.go"],
|
||||
embed = [":thumbnail"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"google.golang.org/api/youtube/v3"
|
||||
@@ -75,8 +76,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *thumbnail) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/video",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/playlistItem",
|
||||
"//pkg/thumbnail",
|
||||
@@ -19,5 +20,5 @@ go_test(
|
||||
name = "video_test",
|
||||
srcs = ["video_test.go"],
|
||||
embed = [":video"],
|
||||
deps = ["//pkg/utils"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
+3
-2
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"slices"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/playlistItem"
|
||||
"github.com/eat-pray-ai/yutu/pkg/thumbnail"
|
||||
@@ -641,8 +642,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *video) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/videoAbuseReportReason",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,4 +18,5 @@ go_test(
|
||||
name = "videoAbuseReportReason_test",
|
||||
srcs = ["videoAbuseReportReason_test.go"],
|
||||
embed = [":videoAbuseReportReason"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -87,8 +88,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *videoAbuseReportReason) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/videoCategory",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"//pkg/utils",
|
||||
"@com_github_jedib0t_go_pretty_v6//table",
|
||||
@@ -17,4 +18,5 @@ go_test(
|
||||
name = "videoCategory_test",
|
||||
srcs = ["videoCategory_test.go"],
|
||||
embed = [":videoCategory"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"github.com/eat-pray-ai/yutu/pkg/utils"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
@@ -105,8 +106,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *videoCategory) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
importpath = "github.com/eat-pray-ai/yutu/pkg/watermark",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg",
|
||||
"//pkg/auth",
|
||||
"@org_golang_google_api//youtube/v3:youtube",
|
||||
],
|
||||
@@ -15,4 +16,5 @@ go_test(
|
||||
name = "watermark_test",
|
||||
srcs = ["watermark_test.go"],
|
||||
embed = [":watermark"],
|
||||
deps = ["@org_golang_google_api//youtube/v3:youtube"],
|
||||
)
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/eat-pray-ai/yutu/pkg"
|
||||
"github.com/eat-pray-ai/yutu/pkg/auth"
|
||||
"google.golang.org/api/youtube/v3"
|
||||
)
|
||||
@@ -143,8 +144,8 @@ func WithService(svc *youtube.Service) Option {
|
||||
return func(_ *watermark) {
|
||||
if svc == nil {
|
||||
svc = auth.NewY2BService(
|
||||
auth.WithCredential(""),
|
||||
auth.WithCacheToken(""),
|
||||
auth.WithCredential("", pkg.Fsys),
|
||||
auth.WithCacheToken("", pkg.Fsys),
|
||||
).GetService()
|
||||
}
|
||||
service = svc
|
||||
|
||||
Reference in new issue
Block a user