Skip to content

Commit

Permalink
Swap address logic to use generic strings instead of IPs
Browse files Browse the repository at this point in the history
  • Loading branch information
aetaric committed May 5, 2023
1 parent 1b192dd commit f2faa13
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
7 changes: 3 additions & 4 deletions connections/lidarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package connections

import (
"fmt"
"net"
"strings"

log "github.com/sirupsen/logrus"
Expand All @@ -16,15 +15,15 @@ type Lidarr struct {
server *lidarr.Lidarr
Process bool
ApiKey string
Address net.IPAddr
Address string
Port int
BaseURL string
pathMaps map[string]string
}

func (l *Lidarr) FromConfig(conf *viper.Viper) {
if conf != nil {
l.Address = net.IPAddr{IP: net.ParseIP(conf.GetString("address"))}
l.Address = conf.GetString("address")
l.Process = conf.GetBool("process")
l.ApiKey = conf.GetString("apikey")
l.Port = conf.GetInt("port")
Expand Down Expand Up @@ -88,7 +87,7 @@ func (l *Lidarr) RemoveFile(path string) bool {
func (l *Lidarr) Connect() (bool, string) {
if l.Process {
if l.ApiKey != "" {
l.config = starr.New(l.ApiKey, fmt.Sprintf("http://%s:%v%v", l.Address.IP.String(), l.Port, l.BaseURL), 0)
l.config = starr.New(l.ApiKey, fmt.Sprintf("http://%s:%v%v", l.Address, l.Port, l.BaseURL), 0)
l.server = lidarr.New(l.config)
status, err := l.server.GetSystemStatus()
if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions connections/radarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package connections

import (
"fmt"
"net"
"strings"

log "github.com/sirupsen/logrus"
Expand All @@ -16,15 +15,15 @@ type Radarr struct {
server *radarr.Radarr
Process bool
ApiKey string
Address net.IPAddr
Address string
Port int
BaseURL string
pathMaps map[string]string
}

func (r *Radarr) FromConfig(conf *viper.Viper) {
if conf != nil {
r.Address = net.IPAddr{IP: net.ParseIP(conf.GetString("address"))}
r.Address = conf.GetString("address")
r.Process = conf.GetBool("process")
r.ApiKey = conf.GetString("apikey")
r.Port = conf.GetInt("port")
Expand Down Expand Up @@ -67,7 +66,7 @@ func (r *Radarr) RemoveFile(path string) bool {
func (r *Radarr) Connect() (bool, string) {
if r.Process {
if r.ApiKey != "" {
r.config = starr.New(r.ApiKey, fmt.Sprintf("http://%s:%v%v", r.Address.IP.String(), r.Port, r.BaseURL), 0)
r.config = starr.New(r.ApiKey, fmt.Sprintf("http://%s:%v%v", r.Address, r.Port, r.BaseURL), 0)
r.server = radarr.New(r.config)
status, err := r.server.GetSystemStatus()
if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions connections/sonarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package connections

import (
"fmt"
"net"
"strings"

log "github.com/sirupsen/logrus"
Expand All @@ -16,15 +15,15 @@ type Sonarr struct {
server *sonarr.Sonarr
Process bool
ApiKey string
Address net.IPAddr
Address string
Port int
BaseURL string
pathMaps map[string]string
}

func (s *Sonarr) FromConfig(conf *viper.Viper) {
if conf != nil {
s.Address = net.IPAddr{IP: net.ParseIP(conf.GetString("address"))}
s.Address = conf.GetString("address")
s.Process = conf.GetBool("process")
s.ApiKey = conf.GetString("apikey")
s.Port = conf.GetInt("port")
Expand Down Expand Up @@ -70,7 +69,7 @@ func (s *Sonarr) RemoveFile(path string) bool {
func (s *Sonarr) Connect() (bool, string) {
if s.Process {
if s.ApiKey != "" {
s.config = starr.New(s.ApiKey, fmt.Sprintf("http://%s:%v%v", s.Address.IP.String(), s.Port, s.BaseURL), 0)
s.config = starr.New(s.ApiKey, fmt.Sprintf("http://%s:%v%v", s.Address, s.Port, s.BaseURL), 0)
s.server = sonarr.New(s.config)
status, err := s.server.GetSystemStatus()
if err != nil {
Expand Down

0 comments on commit f2faa13

Please sign in to comment.