From 5c0a1c9127103823fcbaeedc21ee2cfd2f41adef Mon Sep 17 00:00:00 2001 From: OpenWaygate <27287694+OpenWaygate@users.noreply.github.com> Date: Tue, 2 Sep 2025 00:36:41 +0800 Subject: [PATCH] :recycle: Extract fs parameter for test --- cmd/BUILD.bazel | 1 + cmd/auth.go | 5 ++- pkg/BUILD.bazel | 5 ++- pkg/activity/BUILD.bazel | 3 +- pkg/activity/activity.go | 5 ++- pkg/auth/BUILD.bazel | 8 +++- pkg/auth/auth.go | 1 + pkg/auth/service.go | 38 +++++++++---------- pkg/caption/BUILD.bazel | 3 +- pkg/caption/caption.go | 5 ++- pkg/channel/BUILD.bazel | 3 +- pkg/channel/channel.go | 5 ++- pkg/channelBanner/BUILD.bazel | 2 + pkg/channelBanner/channelBanner.go | 5 ++- pkg/channelSection/BUILD.bazel | 3 +- pkg/channelSection/channelSection.go | 5 ++- pkg/comment/BUILD.bazel | 3 +- pkg/comment/comment.go | 5 ++- pkg/commentThread/BUILD.bazel | 2 + pkg/commentThread/commentThread.go | 5 ++- pkg/fs.go | 16 ++++++++ pkg/i18nLanguage/BUILD.bazel | 2 + pkg/i18nLanguage/i18nLanguage.go | 5 ++- pkg/i18nRegion/BUILD.bazel | 2 + pkg/i18nRegion/i18nRegion.go | 5 ++- pkg/member/BUILD.bazel | 2 + pkg/member/member.go | 5 ++- pkg/membershipsLevel/BUILD.bazel | 2 + pkg/membershipsLevel/membershipsLevel.go | 5 ++- pkg/playlist/BUILD.bazel | 3 +- pkg/playlist/playlist.go | 5 ++- pkg/playlistImage/BUILD.bazel | 2 + pkg/playlistImage/playlistImage.go | 5 ++- pkg/playlistItem/BUILD.bazel | 2 + pkg/playlistItem/playlistItem.go | 5 ++- pkg/search/BUILD.bazel | 3 +- pkg/search/search.go | 5 ++- pkg/subscription/BUILD.bazel | 3 +- pkg/subscription/subscription.go | 5 ++- pkg/superChatEvent/BUILD.bazel | 2 + pkg/superChatEvent/superChatEvent.go | 5 ++- pkg/thumbnail/BUILD.bazel | 2 + pkg/thumbnail/thumbnail.go | 5 ++- pkg/video/BUILD.bazel | 3 +- pkg/video/video.go | 5 ++- pkg/videoAbuseReportReason/BUILD.bazel | 2 + .../videoAbuseReportReason.go | 5 ++- pkg/videoCategory/BUILD.bazel | 2 + pkg/videoCategory/videoCategory.go | 5 ++- pkg/watermark/BUILD.bazel | 2 + pkg/watermark/watermark.go | 5 ++- 51 files changed, 161 insertions(+), 76 deletions(-) create mode 100644 pkg/fs.go diff --git a/cmd/BUILD.bazel b/cmd/BUILD.bazel index 66d31fa..08b8010 100644 --- a/cmd/BUILD.bazel +++ b/cmd/BUILD.bazel @@ -19,6 +19,7 @@ go_library( "Arch": "{STABLE_ARCH}", }, deps = [ + "//pkg", "//pkg/auth", "@com_github_mark3labs_mcp_go//server", "@com_github_savioxavier_termlink//:termlink", diff --git a/cmd/auth.go b/cmd/auth.go index c57e682..eabee3c 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -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), ) }, } diff --git a/pkg/BUILD.bazel b/pkg/BUILD.bazel index aeab027..7fa7962 100644 --- a/pkg/BUILD.bazel +++ b/pkg/BUILD.bazel @@ -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"], ) diff --git a/pkg/activity/BUILD.bazel b/pkg/activity/BUILD.bazel index c2988c9..5a64ceb 100644 --- a/pkg/activity/BUILD.bazel +++ b/pkg/activity/BUILD.bazel @@ -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"], ) diff --git a/pkg/activity/activity.go b/pkg/activity/activity.go index ab024f5..63fec78 100644 --- a/pkg/activity/activity.go +++ b/pkg/activity/activity.go @@ -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 diff --git a/pkg/auth/BUILD.bazel b/pkg/auth/BUILD.bazel index df71a72..15d4d22 100644 --- a/pkg/auth/BUILD.bazel +++ b/pkg/auth/BUILD.bazel @@ -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"], +) diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index 2bd1be6..732a828 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -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. diff --git a/pkg/auth/service.go b/pkg/auth/service.go index 6cf0549..36cc599 100644 --- a/pkg/auth/service.go +++ b/pkg/auth/service.go @@ -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)) } diff --git a/pkg/caption/BUILD.bazel b/pkg/caption/BUILD.bazel index 7ea58e8..d9f78ee 100644 --- a/pkg/caption/BUILD.bazel +++ b/pkg/caption/BUILD.bazel @@ -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"], ) diff --git a/pkg/caption/caption.go b/pkg/caption/caption.go index 3662aab..9214403 100644 --- a/pkg/caption/caption.go +++ b/pkg/caption/caption.go @@ -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 diff --git a/pkg/channel/BUILD.bazel b/pkg/channel/BUILD.bazel index f6e5145..ea49c8a 100644 --- a/pkg/channel/BUILD.bazel +++ b/pkg/channel/BUILD.bazel @@ -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"], ) diff --git a/pkg/channel/channel.go b/pkg/channel/channel.go index 41ae7d0..cf20bf0 100644 --- a/pkg/channel/channel.go +++ b/pkg/channel/channel.go @@ -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 diff --git a/pkg/channelBanner/BUILD.bazel b/pkg/channelBanner/BUILD.bazel index 028a61b..9c035dc 100644 --- a/pkg/channelBanner/BUILD.bazel +++ b/pkg/channelBanner/BUILD.bazel @@ -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"], ) diff --git a/pkg/channelBanner/channelBanner.go b/pkg/channelBanner/channelBanner.go index ec5f10a..aeca477 100644 --- a/pkg/channelBanner/channelBanner.go +++ b/pkg/channelBanner/channelBanner.go @@ -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 diff --git a/pkg/channelSection/BUILD.bazel b/pkg/channelSection/BUILD.bazel index 44c4ba7..548d6f2 100644 --- a/pkg/channelSection/BUILD.bazel +++ b/pkg/channelSection/BUILD.bazel @@ -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"], ) diff --git a/pkg/channelSection/channelSection.go b/pkg/channelSection/channelSection.go index 0d0a1ad..b053bea 100644 --- a/pkg/channelSection/channelSection.go +++ b/pkg/channelSection/channelSection.go @@ -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 diff --git a/pkg/comment/BUILD.bazel b/pkg/comment/BUILD.bazel index 123bf49..d50ce98 100644 --- a/pkg/comment/BUILD.bazel +++ b/pkg/comment/BUILD.bazel @@ -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"], ) diff --git a/pkg/comment/comment.go b/pkg/comment/comment.go index 0a140cc..d3ccfce 100644 --- a/pkg/comment/comment.go +++ b/pkg/comment/comment.go @@ -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 diff --git a/pkg/commentThread/BUILD.bazel b/pkg/commentThread/BUILD.bazel index 83cd963..9c9cb19 100644 --- a/pkg/commentThread/BUILD.bazel +++ b/pkg/commentThread/BUILD.bazel @@ -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"], ) diff --git a/pkg/commentThread/commentThread.go b/pkg/commentThread/commentThread.go index 4d95936..92a0ef7 100644 --- a/pkg/commentThread/commentThread.go +++ b/pkg/commentThread/commentThread.go @@ -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 diff --git a/pkg/fs.go b/pkg/fs.go new file mode 100644 index 0000000..b29edfb --- /dev/null +++ b/pkg/fs.go @@ -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() +} diff --git a/pkg/i18nLanguage/BUILD.bazel b/pkg/i18nLanguage/BUILD.bazel index 9741307..fb29117 100644 --- a/pkg/i18nLanguage/BUILD.bazel +++ b/pkg/i18nLanguage/BUILD.bazel @@ -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"], ) diff --git a/pkg/i18nLanguage/i18nLanguage.go b/pkg/i18nLanguage/i18nLanguage.go index e8b1dcb..c9e704b 100644 --- a/pkg/i18nLanguage/i18nLanguage.go +++ b/pkg/i18nLanguage/i18nLanguage.go @@ -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 diff --git a/pkg/i18nRegion/BUILD.bazel b/pkg/i18nRegion/BUILD.bazel index 76dec9a..d78bd42 100644 --- a/pkg/i18nRegion/BUILD.bazel +++ b/pkg/i18nRegion/BUILD.bazel @@ -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"], ) diff --git a/pkg/i18nRegion/i18nRegion.go b/pkg/i18nRegion/i18nRegion.go index 71ec6c2..417d1a9 100644 --- a/pkg/i18nRegion/i18nRegion.go +++ b/pkg/i18nRegion/i18nRegion.go @@ -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 diff --git a/pkg/member/BUILD.bazel b/pkg/member/BUILD.bazel index 7e77837..1e4fd35 100644 --- a/pkg/member/BUILD.bazel +++ b/pkg/member/BUILD.bazel @@ -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"], ) diff --git a/pkg/member/member.go b/pkg/member/member.go index b7a4315..c403a58 100644 --- a/pkg/member/member.go +++ b/pkg/member/member.go @@ -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 diff --git a/pkg/membershipsLevel/BUILD.bazel b/pkg/membershipsLevel/BUILD.bazel index 0d00108..d4586cf 100644 --- a/pkg/membershipsLevel/BUILD.bazel +++ b/pkg/membershipsLevel/BUILD.bazel @@ -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"], ) diff --git a/pkg/membershipsLevel/membershipsLevel.go b/pkg/membershipsLevel/membershipsLevel.go index 0419094..3aef975 100644 --- a/pkg/membershipsLevel/membershipsLevel.go +++ b/pkg/membershipsLevel/membershipsLevel.go @@ -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 diff --git a/pkg/playlist/BUILD.bazel b/pkg/playlist/BUILD.bazel index c0aaa19..a39de83 100644 --- a/pkg/playlist/BUILD.bazel +++ b/pkg/playlist/BUILD.bazel @@ -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"], ) diff --git a/pkg/playlist/playlist.go b/pkg/playlist/playlist.go index 2b71f12..6fd05e6 100644 --- a/pkg/playlist/playlist.go +++ b/pkg/playlist/playlist.go @@ -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 diff --git a/pkg/playlistImage/BUILD.bazel b/pkg/playlistImage/BUILD.bazel index 91ad926..df85be8 100644 --- a/pkg/playlistImage/BUILD.bazel +++ b/pkg/playlistImage/BUILD.bazel @@ -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"], ) diff --git a/pkg/playlistImage/playlistImage.go b/pkg/playlistImage/playlistImage.go index 03fd2f0..2d3c119 100644 --- a/pkg/playlistImage/playlistImage.go +++ b/pkg/playlistImage/playlistImage.go @@ -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 diff --git a/pkg/playlistItem/BUILD.bazel b/pkg/playlistItem/BUILD.bazel index b381be2..c7d47db 100644 --- a/pkg/playlistItem/BUILD.bazel +++ b/pkg/playlistItem/BUILD.bazel @@ -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"], ) diff --git a/pkg/playlistItem/playlistItem.go b/pkg/playlistItem/playlistItem.go index 30d9005..6c8edf7 100644 --- a/pkg/playlistItem/playlistItem.go +++ b/pkg/playlistItem/playlistItem.go @@ -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 diff --git a/pkg/search/BUILD.bazel b/pkg/search/BUILD.bazel index d0a7e9c..e3baa1b 100644 --- a/pkg/search/BUILD.bazel +++ b/pkg/search/BUILD.bazel @@ -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"], ) diff --git a/pkg/search/search.go b/pkg/search/search.go index b3d9225..1f1b5d3 100644 --- a/pkg/search/search.go +++ b/pkg/search/search.go @@ -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 diff --git a/pkg/subscription/BUILD.bazel b/pkg/subscription/BUILD.bazel index a64ea55..5524ac1 100644 --- a/pkg/subscription/BUILD.bazel +++ b/pkg/subscription/BUILD.bazel @@ -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"], ) diff --git a/pkg/subscription/subscription.go b/pkg/subscription/subscription.go index 26b8cea..7bf9ac5 100644 --- a/pkg/subscription/subscription.go +++ b/pkg/subscription/subscription.go @@ -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 diff --git a/pkg/superChatEvent/BUILD.bazel b/pkg/superChatEvent/BUILD.bazel index 50a8187..1bb2d89 100644 --- a/pkg/superChatEvent/BUILD.bazel +++ b/pkg/superChatEvent/BUILD.bazel @@ -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"], ) diff --git a/pkg/superChatEvent/superChatEvent.go b/pkg/superChatEvent/superChatEvent.go index 7efc5ca..3c66699 100644 --- a/pkg/superChatEvent/superChatEvent.go +++ b/pkg/superChatEvent/superChatEvent.go @@ -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 diff --git a/pkg/thumbnail/BUILD.bazel b/pkg/thumbnail/BUILD.bazel index 164dc81..2324a0b 100644 --- a/pkg/thumbnail/BUILD.bazel +++ b/pkg/thumbnail/BUILD.bazel @@ -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"], ) diff --git a/pkg/thumbnail/thumbnail.go b/pkg/thumbnail/thumbnail.go index e67ba39..9906a2b 100644 --- a/pkg/thumbnail/thumbnail.go +++ b/pkg/thumbnail/thumbnail.go @@ -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 diff --git a/pkg/video/BUILD.bazel b/pkg/video/BUILD.bazel index a5100aa..81661d3 100644 --- a/pkg/video/BUILD.bazel +++ b/pkg/video/BUILD.bazel @@ -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"], ) diff --git a/pkg/video/video.go b/pkg/video/video.go index 197638d..bfb713e 100644 --- a/pkg/video/video.go +++ b/pkg/video/video.go @@ -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 diff --git a/pkg/videoAbuseReportReason/BUILD.bazel b/pkg/videoAbuseReportReason/BUILD.bazel index 6fd0533..1e73500 100644 --- a/pkg/videoAbuseReportReason/BUILD.bazel +++ b/pkg/videoAbuseReportReason/BUILD.bazel @@ -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"], ) diff --git a/pkg/videoAbuseReportReason/videoAbuseReportReason.go b/pkg/videoAbuseReportReason/videoAbuseReportReason.go index afd451c..70990e5 100644 --- a/pkg/videoAbuseReportReason/videoAbuseReportReason.go +++ b/pkg/videoAbuseReportReason/videoAbuseReportReason.go @@ -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 diff --git a/pkg/videoCategory/BUILD.bazel b/pkg/videoCategory/BUILD.bazel index 7365e99..1c2890c 100644 --- a/pkg/videoCategory/BUILD.bazel +++ b/pkg/videoCategory/BUILD.bazel @@ -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"], ) diff --git a/pkg/videoCategory/videoCategory.go b/pkg/videoCategory/videoCategory.go index 6b51fdc..8883332 100644 --- a/pkg/videoCategory/videoCategory.go +++ b/pkg/videoCategory/videoCategory.go @@ -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 diff --git a/pkg/watermark/BUILD.bazel b/pkg/watermark/BUILD.bazel index da86dc0..5991fd9 100644 --- a/pkg/watermark/BUILD.bazel +++ b/pkg/watermark/BUILD.bazel @@ -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"], ) diff --git a/pkg/watermark/watermark.go b/pkg/watermark/watermark.go index aac6c3e..17733f7 100644 --- a/pkg/watermark/watermark.go +++ b/pkg/watermark/watermark.go @@ -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