From cf7acd04ca3073eb8cc3cc413d145adc0fa3a3b2 Mon Sep 17 00:00:00 2001 From: Jacek Kuzniarski Date: Tue, 3 Jan 2023 12:02:35 +0100 Subject: [PATCH] draft/multiple-urls-per-site (#122) --- go.mod | 2 +- pkg/sites/loader.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0344214..62d4d02 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Girbons/comics-downloader -go 1.17 +go 1.18 require ( fyne.io/fyne v1.4.3 diff --git a/pkg/sites/loader.go b/pkg/sites/loader.go index 485519b..22bd933 100644 --- a/pkg/sites/loader.go +++ b/pkg/sites/loader.go @@ -10,6 +10,7 @@ import ( "github.com/Girbons/comics-downloader/pkg/config" "github.com/Girbons/comics-downloader/pkg/core" "github.com/Girbons/comics-downloader/pkg/util" + "golang.org/x/exp/slices" ) func initializeCollection(issues []string, options *config.Options, base BaseSite) ([]*core.Comic, error) { @@ -86,6 +87,8 @@ func notInIssuesRange(issueNumber string, start, end float64) bool { // LoadComicFromSource will return an `comic` instance initialized based on the source func LoadComicFromSource(options *config.Options) ([]*core.Comic, error) { + // this probably needs to land in the comicextra.go + const supportedComicExtra := []string{"ww1.comciextra.com", "www.comicextra.com"} var ( base BaseSite issues []string @@ -93,10 +96,10 @@ func LoadComicFromSource(options *config.Options) ([]*core.Comic, error) { err error ) - switch options.Source { + switch sourceUrl := options.Source; sourceUrl { case "readcomiconline.li": base = NewReadComiconline(options) - case "www.comicextra.com": + case supportedComicExtra.contains(soureUrl): base = NewComicextra(options) case "mangareader.tv": base = NewMangareader(options)