-
-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from mxpv/key-rotation
Support multiple API keys
- Loading branch information
Showing
20 changed files
with
265 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package builder | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/mxpv/podsync/pkg/config" | ||
"github.com/mxpv/podsync/pkg/model" | ||
) | ||
|
||
type Builder interface { | ||
Build(ctx context.Context, cfg *config.Feed) (*model.Feed, error) | ||
} | ||
|
||
func New(ctx context.Context, provider model.Provider, key string) (Builder, error) { | ||
switch provider { | ||
case model.ProviderYoutube: | ||
return NewYouTubeBuilder(key) | ||
case model.ProviderVimeo: | ||
return NewVimeoBuilder(ctx, key) | ||
default: | ||
return nil, errors.Errorf("unsupported provider %q", provider) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package feed | ||
package builder | ||
|
||
import ( | ||
"net/url" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package feed | ||
package builder | ||
|
||
import ( | ||
"net/url" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package feed | ||
package builder | ||
|
||
import ( | ||
"net/http" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package feed | ||
package builder | ||
|
||
import ( | ||
"context" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package feed | ||
package builder | ||
|
||
import ( | ||
"context" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package feed | ||
package builder | ||
|
||
import ( | ||
"context" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package config | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
type Duration struct { | ||
time.Duration | ||
} | ||
|
||
func (d *Duration) UnmarshalText(text []byte) error { | ||
res, err := time.ParseDuration(string(text)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
*d = Duration{res} | ||
return nil | ||
} | ||
|
||
// StringSlice is a toml extension that lets you to specify either a string | ||
// value (a slice with just one element) or a string slice. | ||
type StringSlice []string | ||
|
||
func (s *StringSlice) UnmarshalTOML(decode func(interface{}) error) error { | ||
var single string | ||
if err := decode(&single); err == nil { | ||
*s = []string{single} | ||
return nil | ||
} | ||
|
||
var slice []string | ||
if err := decode(&slice); err == nil { | ||
*s = slice | ||
return nil | ||
} | ||
|
||
return errors.New("failed to decode string (slice) field") | ||
} |
Oops, something went wrong.