mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
Decouple config package
This commit is contained in:
@@ -3,14 +3,14 @@ package builder
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/mxpv/podsync/pkg/feed"
|
||||
"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)
|
||||
Build(ctx context.Context, cfg *feed.Config) (*model.Feed, error)
|
||||
}
|
||||
|
||||
func New(ctx context.Context, provider model.Provider, key string) (Builder, error) {
|
||||
|
||||
@@ -5,10 +5,10 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/mxpv/podsync/pkg/feed"
|
||||
"github.com/pkg/errors"
|
||||
soundcloudapi "github.com/zackradisic/soundcloud-api"
|
||||
|
||||
"github.com/mxpv/podsync/pkg/config"
|
||||
"github.com/mxpv/podsync/pkg/model"
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ type SoundCloudBuilder struct {
|
||||
client *soundcloudapi.API
|
||||
}
|
||||
|
||||
func (s *SoundCloudBuilder) Build(_ctx context.Context, cfg *config.Feed) (*model.Feed, error) {
|
||||
func (s *SoundCloudBuilder) Build(_ctx context.Context, cfg *feed.Config) (*model.Feed, error) {
|
||||
info, err := ParseURL(cfg.URL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -3,10 +3,9 @@ package builder
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mxpv/podsync/pkg/feed"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mxpv/podsync/pkg/config"
|
||||
)
|
||||
|
||||
func TestSC_BUILDFEED(t *testing.T) {
|
||||
@@ -20,7 +19,7 @@ func TestSC_BUILDFEED(t *testing.T) {
|
||||
|
||||
for _, addr := range urls {
|
||||
t.Run(addr, func(t *testing.T) {
|
||||
feed, err := builder.Build(testCtx, &config.Feed{URL: addr})
|
||||
feed, err := builder.Build(testCtx, &feed.Config{URL: addr})
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.NotEmpty(t, feed.Title)
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/mxpv/podsync/pkg/feed"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/silentsokolov/go-vimeo/vimeo"
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
"github.com/mxpv/podsync/pkg/config"
|
||||
"github.com/mxpv/podsync/pkg/model"
|
||||
)
|
||||
|
||||
@@ -158,7 +158,7 @@ func (v *VimeoBuilder) queryVideos(getVideos getVideosFunc, feed *model.Feed) er
|
||||
}
|
||||
}
|
||||
|
||||
func (v *VimeoBuilder) Build(ctx context.Context, cfg *config.Feed) (*model.Feed, error) {
|
||||
func (v *VimeoBuilder) Build(ctx context.Context, cfg *feed.Config) (*model.Feed, error) {
|
||||
info, err := ParseURL(cfg.URL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/BrianHicks/finch/duration"
|
||||
"github.com/mxpv/podsync/pkg/feed"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/api/youtube/v3"
|
||||
|
||||
"github.com/mxpv/podsync/pkg/config"
|
||||
"github.com/mxpv/podsync/pkg/model"
|
||||
)
|
||||
|
||||
@@ -384,7 +384,7 @@ func (yt *YouTubeBuilder) queryItems(ctx context.Context, feed *model.Feed) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
func (yt *YouTubeBuilder) Build(ctx context.Context, cfg *config.Feed) (*model.Feed, error) {
|
||||
func (yt *YouTubeBuilder) Build(ctx context.Context, cfg *feed.Config) (*model.Feed, error) {
|
||||
info, err := ParseURL(cfg.URL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -5,10 +5,10 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/mxpv/podsync/pkg/feed"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mxpv/podsync/pkg/config"
|
||||
"github.com/mxpv/podsync/pkg/model"
|
||||
)
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestYT_BuildFeed(t *testing.T) {
|
||||
|
||||
for _, addr := range urls {
|
||||
t.Run(addr, func(t *testing.T) {
|
||||
feed, err := builder.Build(testCtx, &config.Feed{URL: addr})
|
||||
feed, err := builder.Build(testCtx, &feed.Config{URL: addr})
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.NotEmpty(t, feed.Title)
|
||||
|
||||
Reference in New Issue
Block a user