✨ Allow read env when init youtube service

This commit is contained in:
OpenWaygate committed 2024-11-26 01:18:13 +08:00
1 parent 44bb314023
commit 445b1fa079
20 files changed
+146 -102

No files matched your search

+7 -5
View File
@@ -144,11 +144,13 @@ func WithRegionCode(regionCode string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(a *activity) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *activity) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -376,11 +376,13 @@ func WithTlang(tlang string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(c *caption) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *caption) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -246,11 +246,13 @@ func WithTitle(title string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(c *channel) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *channel) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -91,11 +91,13 @@ func WithOnBehalfOfContentOwnerChannel(onBehalfOfContentOwnerChannel string) Opt
}
func WithService(svc *youtube.Service) Option {
return func(cb *channelBanner) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *channelBanner) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -134,11 +134,13 @@ func WithOnBehalfOfContentOwner(onBehalfOfContentOwner string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(cs *channelSection) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *channelSection) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+10 -6
View File
@@ -212,7 +212,9 @@ func (c *comment) SetModerationStatus(output string) {
utils.PrintYAML(c)
case "silent":
default:
fmt.Printf("Comment moderation status set to %s: %s\n", c.ModerationStatus, c.IDs)
fmt.Printf(
"Comment moderation status set to %s: %s\n", c.ModerationStatus, c.IDs,
)
}
}
@@ -304,11 +306,13 @@ func WithViewerRating(viewerRating string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(c *comment) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *comment) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+10 -6
View File
@@ -106,7 +106,9 @@ func (c *commentThread) List(parts []string, output string) {
default:
fmt.Println("ID\tTopLevelCommentID")
for _, commentThread := range commentThreads {
fmt.Printf("%s\t%s\n", commentThread.Id, commentThread.Snippet.TopLevelComment.Id)
fmt.Printf(
"%s\t%s\n", commentThread.Id, commentThread.Snippet.TopLevelComment.Id,
)
}
}
}
@@ -212,11 +214,13 @@ func WithVideoId(videoId string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(c *commentThread) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *commentThread) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -75,11 +75,13 @@ func WithHl(hl string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(i *i18nLanguage) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *i18nLanguage) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -75,11 +75,13 @@ func WithHl(hl string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(i *i18nRegion) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *i18nRegion) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -107,11 +107,13 @@ func WithMode(mode string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(m *member) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *member) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -63,11 +63,13 @@ func (m *membershipsLevel) List(parts []string, output string) {
}
func WithService(svc *youtube.Service) Option {
return func(m *membershipsLevel) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *membershipsLevel) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -258,11 +258,13 @@ func WithOnBehalfOfContentOwnerChannel(channel string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(p *playlist) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *playlist) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -284,11 +284,13 @@ func WithOnBehalfOfContentOwner(onBehalfOfContentOwner string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(p *playlistItem) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *playlistItem) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -387,11 +387,13 @@ func WithVideoType(videoType string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(s *search) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *search) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -239,11 +239,13 @@ func WithTitle(title string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(s *subscription) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *subscription) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -71,11 +71,13 @@ func WithFile(file string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(t *thumbnail) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *thumbnail) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -571,11 +571,13 @@ func WithSecondaryReasonId(secondaryReasonId string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(v *video) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *video) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
@@ -73,11 +73,13 @@ func WithHL(hl string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(vc *videoAbuseReportReason) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *videoAbuseReportReason) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -94,11 +94,13 @@ func WithRegionCode(regionCode string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(vc *videoCategory) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *videoCategory) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}
+7 -5
View File
@@ -140,11 +140,13 @@ func WithOnBehalfOfContentOwner(onBehalfOfContentOwner string) Option {
}
func WithService(svc *youtube.Service) Option {
return func(w *watermark) {
if svc != nil {
service = svc
} else {
service = auth.NewY2BService()
return func(_ *watermark) {
if svc == nil {
svc = auth.NewY2BService(
auth.WithCredential(""),
auth.WithCacheToken(""),
)
}
service = svc
}
}