refactor: imports

This commit is contained in:
l3uddz
2022-04-01 20:42:05 +01:00
parent a73b07a041
commit 19a5e73c19
40 changed files with 91 additions and 53 deletions

3
cache/cache.go vendored
View File

@@ -3,11 +3,12 @@ package cache
import ( import (
"context" "context"
"fmt" "fmt"
"time"
"github.com/dgraph-io/badger/v3" "github.com/dgraph-io/badger/v3"
"github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/logger"
"github.com/lefelys/state" "github.com/lefelys/state"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"time"
) )
type Client struct { type Client struct {

1
cache/delete.go vendored
View File

@@ -2,6 +2,7 @@ package cache
import ( import (
"fmt" "fmt"
"github.com/dgraph-io/badger/v3" "github.com/dgraph-io/badger/v3"
) )

View File

@@ -1,8 +1,9 @@
package cache package cache
import ( import (
"github.com/rs/zerolog"
"testing" "testing"
"github.com/rs/zerolog"
) )
func TestClient_Delete(t *testing.T) { func TestClient_Delete(t *testing.T) {

1
cache/get.go vendored
View File

@@ -2,6 +2,7 @@ package cache
import ( import (
"fmt" "fmt"
"github.com/dgraph-io/badger/v3" "github.com/dgraph-io/badger/v3"
) )

3
cache/get_test.go vendored
View File

@@ -1,10 +1,11 @@
package cache package cache
import ( import (
"github.com/rs/zerolog"
"reflect" "reflect"
"testing" "testing"
"time" "time"
"github.com/rs/zerolog"
) )
func TestClient_Get(t *testing.T) { func TestClient_Get(t *testing.T) {

3
cache/put.go vendored
View File

@@ -2,8 +2,9 @@ package cache
import ( import (
"fmt" "fmt"
"github.com/dgraph-io/badger/v3"
"time" "time"
"github.com/dgraph-io/badger/v3"
) )
func (c *Client) Put(bucket string, key string, val []byte, ttl time.Duration) error { func (c *Client) Put(bucket string, key string, val []byte, ttl time.Duration) error {

3
cache/put_test.go vendored
View File

@@ -1,10 +1,11 @@
package cache package cache
import ( import (
"github.com/rs/zerolog"
"reflect" "reflect"
"testing" "testing"
"time" "time"
"github.com/rs/zerolog"
) )
func TestClient_Put(t *testing.T) { func TestClient_Put(t *testing.T) {

3
cache/test.go vendored
View File

@@ -1,8 +1,9 @@
package cache package cache
import ( import (
"github.com/dgraph-io/badger/v3"
"testing" "testing"
"github.com/dgraph-io/badger/v3"
) )
func newDb(t *testing.T) *badger.DB { func newDb(t *testing.T) *badger.DB {

View File

@@ -3,10 +3,11 @@
package main package main
import ( import (
"github.com/kirsle/configdir"
"golang.org/x/sys/unix"
"os" "os"
"path/filepath" "path/filepath"
"github.com/kirsle/configdir"
"golang.org/x/sys/unix"
) )
func defaultConfigPath() string { func defaultConfigPath() string {

View File

@@ -3,9 +3,10 @@ package main
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/kirsle/configdir"
"os" "os"
"path/filepath" "path/filepath"
"github.com/kirsle/configdir"
) )
func defaultConfigPath() string { func defaultConfigPath() string {

View File

@@ -3,6 +3,12 @@ package main
import ( import (
"context" "context"
"fmt" "fmt"
"io"
"os"
"path/filepath"
"strings"
"time"
"github.com/alecthomas/kong" "github.com/alecthomas/kong"
"github.com/goccy/go-yaml" "github.com/goccy/go-yaml"
"github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr"
@@ -15,11 +21,6 @@ import (
"github.com/natefinch/lumberjack" "github.com/natefinch/lumberjack"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"io"
"os"
"path/filepath"
"strings"
"time"
) )
type config struct { type config struct {

View File

@@ -2,13 +2,14 @@ package pvr
import ( import (
"errors" "errors"
"strings"
"github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr"
"github.com/l3uddz/nabarr/cache" "github.com/l3uddz/nabarr/cache"
"github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/media"
"github.com/l3uddz/nabarr/radarr" "github.com/l3uddz/nabarr/radarr"
"github.com/l3uddz/nabarr/sonarr" "github.com/l3uddz/nabarr/sonarr"
"github.com/lefelys/state" "github.com/lefelys/state"
"strings"
) )
type PVR interface { type PVR interface {

View File

@@ -1,10 +1,11 @@
package main package main
import ( import (
"github.com/rs/zerolog/log"
"os" "os"
"os/signal" "os/signal"
"syscall" "syscall"
"github.com/rs/zerolog/log"
) )
func waitShutdown() { func waitShutdown() {

View File

@@ -3,11 +3,12 @@ package main
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"os"
"github.com/alecthomas/kong" "github.com/alecthomas/kong"
"github.com/blang/semver" "github.com/blang/semver"
"github.com/l3uddz/nabarr/build" "github.com/l3uddz/nabarr/build"
"github.com/rhysd/go-github-selfupdate/selfupdate" "github.com/rhysd/go-github-selfupdate/selfupdate"
"os"
) )
type updateFlag string type updateFlag string

View File

@@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/alecthomas/kong" "github.com/alecthomas/kong"
) )

1
go.sum
View File

@@ -356,7 +356,6 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220401154927-543a649e0bdd h1:zYlwaUHTmxuf6H7hwO2dgwqozQmH7zf4x+/qql4oVWc= golang.org/x/net v0.0.0-20220401154927-543a649e0bdd h1:zYlwaUHTmxuf6H7hwO2dgwqozQmH7zf4x+/qql4oVWc=
golang.org/x/net v0.0.0-20220401154927-543a649e0bdd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220401154927-543a649e0bdd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=

View File

@@ -2,6 +2,7 @@ package media
import ( import (
"fmt" "fmt"
"github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/logger"
"github.com/l3uddz/nabarr/media/omdb" "github.com/l3uddz/nabarr/media/omdb"
"github.com/l3uddz/nabarr/media/trakt" "github.com/l3uddz/nabarr/media/trakt"

View File

@@ -3,9 +3,10 @@ package media
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/l3uddz/nabarr/media/trakt"
"strconv" "strconv"
"time" "time"
"github.com/l3uddz/nabarr/media/trakt"
) )
func (c *Client) GetMovieInfo(item *FeedItem) (*Item, error) { func (c *Client) GetMovieInfo(item *FeedItem) (*Item, error) {

View File

@@ -4,10 +4,11 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/l3uddz/nabarr/util"
"github.com/lucperkins/rek"
"net/url" "net/url"
"strings" "strings"
"github.com/l3uddz/nabarr/util"
"github.com/lucperkins/rek"
) )
var ( var (

View File

@@ -1,12 +1,13 @@
package omdb package omdb
import ( import (
"net/http"
"time"
"github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/logger"
"github.com/l3uddz/nabarr/util" "github.com/l3uddz/nabarr/util"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"go.uber.org/ratelimit" "go.uber.org/ratelimit"
"net/http"
"time"
) )
type Client struct { type Client struct {

View File

@@ -3,8 +3,9 @@ package media
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/l3uddz/nabarr/media/trakt"
"strconv" "strconv"
"github.com/l3uddz/nabarr/media/trakt"
) )
func (c *Client) GetShowInfo(item *FeedItem) (*Item, error) { func (c *Client) GetShowInfo(item *FeedItem) (*Item, error) {

View File

@@ -2,12 +2,13 @@ package media
import ( import (
"encoding/xml" "encoding/xml"
"strings"
"time"
"github.com/l3uddz/nabarr/media/omdb" "github.com/l3uddz/nabarr/media/omdb"
"github.com/l3uddz/nabarr/media/tvdb" "github.com/l3uddz/nabarr/media/tvdb"
"github.com/l3uddz/nabarr/util" "github.com/l3uddz/nabarr/util"
"github.com/pkg/errors" "github.com/pkg/errors"
"strings"
"time"
) )
/* Media Item(s) */ /* Media Item(s) */

View File

@@ -4,9 +4,10 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"net/url"
"github.com/l3uddz/nabarr/util" "github.com/l3uddz/nabarr/util"
"github.com/lucperkins/rek" "github.com/lucperkins/rek"
"net/url"
) )
var ( var (

View File

@@ -1,12 +1,13 @@
package trakt package trakt
import ( import (
"net/http"
"time"
"github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/logger"
"github.com/l3uddz/nabarr/util" "github.com/l3uddz/nabarr/util"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"go.uber.org/ratelimit" "go.uber.org/ratelimit"
"net/http"
"time"
) )
type Client struct { type Client struct {

View File

@@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/l3uddz/nabarr/util" "github.com/l3uddz/nabarr/util"
"github.com/lucperkins/rek" "github.com/lucperkins/rek"
) )

View File

@@ -2,12 +2,13 @@ package tvdb
import ( import (
"fmt" "fmt"
"net/http"
"time"
"github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/logger"
"github.com/l3uddz/nabarr/util" "github.com/l3uddz/nabarr/util"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"go.uber.org/ratelimit" "go.uber.org/ratelimit"
"net/http"
"time"
) )
type Client struct { type Client struct {

View File

@@ -1,9 +1,10 @@
package nabarr package nabarr
import ( import (
"time"
"github.com/antonmedv/expr/vm" "github.com/antonmedv/expr/vm"
"github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/media"
"time"
) )
type ExprProgram struct { type ExprProgram struct {

View File

@@ -4,13 +4,14 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"net/url"
"strconv"
"strings"
"github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr"
"github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/media"
"github.com/l3uddz/nabarr/util" "github.com/l3uddz/nabarr/util"
"github.com/lucperkins/rek" "github.com/lucperkins/rek"
"net/url"
"strconv"
"strings"
) )
var ( var (

View File

@@ -2,6 +2,7 @@ package radarr
import ( import (
"fmt" "fmt"
"github.com/antonmedv/expr" "github.com/antonmedv/expr"
"github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr"
"github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/media"

View File

@@ -3,6 +3,7 @@ package radarr
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr"
"github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/media"
"github.com/lefelys/state" "github.com/lefelys/state"

View File

@@ -2,15 +2,16 @@ package radarr
import ( import (
"fmt" "fmt"
"net/http"
"strings"
"time"
"github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr"
"github.com/l3uddz/nabarr/cache" "github.com/l3uddz/nabarr/cache"
"github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/logger"
"github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/media"
"github.com/l3uddz/nabarr/util" "github.com/l3uddz/nabarr/util"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"net/http"
"strings"
"time"
) )
type Client struct { type Client struct {

View File

@@ -2,10 +2,11 @@ package rss
import ( import (
"fmt" "fmt"
"time"
"github.com/l3uddz/nabarr/cmd/nabarr/pvr" "github.com/l3uddz/nabarr/cmd/nabarr/pvr"
"github.com/l3uddz/nabarr/util" "github.com/l3uddz/nabarr/util"
"github.com/robfig/cron/v3" "github.com/robfig/cron/v3"
"time"
) )
func (c *Client) AddJob(feed feedItem) error { func (c *Client) AddJob(feed feedItem) error {

View File

@@ -3,11 +3,12 @@ package rss
import ( import (
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"sort"
"strings"
"github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/media"
"github.com/l3uddz/nabarr/util" "github.com/l3uddz/nabarr/util"
"github.com/lucperkins/rek" "github.com/lucperkins/rek"
"sort"
"strings"
) )
func (j *rssJob) process() error { func (j *rssJob) process() error {

View File

@@ -1,13 +1,14 @@
package rss package rss
import ( import (
"time"
"github.com/l3uddz/nabarr/cache" "github.com/l3uddz/nabarr/cache"
"github.com/l3uddz/nabarr/cmd/nabarr/pvr" "github.com/l3uddz/nabarr/cmd/nabarr/pvr"
"github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/logger"
"github.com/lefelys/state" "github.com/lefelys/state"
"github.com/robfig/cron/v3" "github.com/robfig/cron/v3"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"time"
) )
type Client struct { type Client struct {

View File

@@ -1,12 +1,13 @@
package rss package rss
import ( import (
"net/http"
"time"
"github.com/l3uddz/nabarr/cache" "github.com/l3uddz/nabarr/cache"
"github.com/l3uddz/nabarr/cmd/nabarr/pvr" "github.com/l3uddz/nabarr/cmd/nabarr/pvr"
"github.com/robfig/cron/v3" "github.com/robfig/cron/v3"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"net/http"
"time"
) )
type feedItem struct { type feedItem struct {

View File

@@ -4,13 +4,14 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"net/url"
"strconv"
"strings"
"github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr"
"github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/media"
"github.com/l3uddz/nabarr/util" "github.com/l3uddz/nabarr/util"
"github.com/lucperkins/rek" "github.com/lucperkins/rek"
"net/url"
"strconv"
"strings"
) )
var ( var (

View File

@@ -2,6 +2,7 @@ package sonarr
import ( import (
"fmt" "fmt"
"github.com/antonmedv/expr" "github.com/antonmedv/expr"
"github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr"
"github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/media"

View File

@@ -3,11 +3,12 @@ package sonarr
import ( import (
"errors" "errors"
"fmt" "fmt"
"strings"
"github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr"
"github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/media"
"github.com/l3uddz/nabarr/util" "github.com/l3uddz/nabarr/util"
"github.com/lefelys/state" "github.com/lefelys/state"
"strings"
) )
func (c *Client) QueueFeedItem(item *media.FeedItem) { func (c *Client) QueueFeedItem(item *media.FeedItem) {

View File

@@ -2,15 +2,16 @@ package sonarr
import ( import (
"fmt" "fmt"
"net/http"
"strings"
"time"
"github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr"
"github.com/l3uddz/nabarr/cache" "github.com/l3uddz/nabarr/cache"
"github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/logger"
"github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/media"
"github.com/l3uddz/nabarr/util" "github.com/l3uddz/nabarr/util"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"net/http"
"strings"
"time"
) )
type Client struct { type Client struct {

View File

@@ -1,12 +1,13 @@
package util package util
import ( import (
"net/http"
"time"
"github.com/hashicorp/go-retryablehttp" "github.com/hashicorp/go-retryablehttp"
"github.com/l3uddz/nabarr/build" "github.com/l3uddz/nabarr/build"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"go.uber.org/ratelimit" "go.uber.org/ratelimit"
"net/http"
"time"
) )
func NewRetryableHttpClient(timeout time.Duration, rl ratelimit.Limiter, log *zerolog.Logger) *http.Client { func NewRetryableHttpClient(timeout time.Duration, rl ratelimit.Limiter, log *zerolog.Logger) *http.Client {