refactor: separate httpclient packages for regular and FlareSolverr sources
- Add internal/httpclient/flare package for Cloudflare-protected sites - Update 7 bases (madara, zmanga, mangaworld, mangathemesia, mangareader, libgroup, liliana) to use flare client - Remove unused internal/config/source.go
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"goyomi/internal/httpclient"
|
||||
"goyomi/internal/httpclient/flare"
|
||||
"goyomi/internal/source"
|
||||
"goyomi/sources/base/util"
|
||||
)
|
||||
@@ -18,17 +18,17 @@ import (
|
||||
const defaultAPIDomain = "https://api.lib.social"
|
||||
|
||||
type Config struct {
|
||||
Name string
|
||||
BaseURL string
|
||||
Lang string
|
||||
SiteID int
|
||||
APIDomain string // defaults to "https://api.lib.social"
|
||||
Name string
|
||||
BaseURL string
|
||||
Lang string
|
||||
SiteID int
|
||||
APIDomain string // defaults to "https://api.lib.social"
|
||||
BearerToken string // optional; set after WebView acquisition
|
||||
}
|
||||
|
||||
type Source struct {
|
||||
cfg Config
|
||||
client *httpclient.Client
|
||||
client *flare.Client
|
||||
id int64
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ func New(cfg Config) *Source {
|
||||
if cfg.APIDomain == "" {
|
||||
cfg.APIDomain = defaultAPIDomain
|
||||
}
|
||||
c := httpclient.NewClient(httpclient.WithRateLimit(1, 1))
|
||||
opts := []flare.Option{flare.WithRateLimit(1, 1)}
|
||||
c := flare.NewClient(opts...)
|
||||
return &Source{cfg: cfg, client: c, id: source.GenerateSourceID(cfg.Name, cfg.Lang)}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
|
||||
"goyomi/internal/httpclient"
|
||||
"goyomi/internal/httpclient/flare"
|
||||
"goyomi/internal/source"
|
||||
"goyomi/sources/base/util"
|
||||
)
|
||||
@@ -24,12 +24,14 @@ type Config struct {
|
||||
|
||||
type Source struct {
|
||||
cfg Config
|
||||
client *httpclient.Client
|
||||
client *flare.Client
|
||||
id int64
|
||||
}
|
||||
|
||||
func New(cfg Config) *Source {
|
||||
c := httpclient.NewClient(httpclient.WithRateLimit(1, 2))
|
||||
opts := []flare.Option{flare.WithRateLimit(1, 2)}
|
||||
c := flare.NewClient(opts...)
|
||||
return &Source{cfg: cfg, client: c, id: source.GenerateSourceID(cfg.Name, cfg.Lang)}
|
||||
return &Source{cfg: cfg, client: c, id: source.GenerateSourceID(cfg.Name, cfg.Lang)}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,16 +13,16 @@ import (
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
|
||||
"goyomi/internal/httpclient"
|
||||
"goyomi/internal/httpclient/flare"
|
||||
"goyomi/internal/source"
|
||||
"goyomi/sources/base/util"
|
||||
)
|
||||
|
||||
// Config holds per-source configuration and overridable CSS selectors.
|
||||
type Config struct {
|
||||
Name string
|
||||
BaseURL string
|
||||
Lang string
|
||||
Name string
|
||||
BaseURL string
|
||||
Lang string
|
||||
|
||||
// MangaSubString is the URL path segment for manga listings (default "manga").
|
||||
MangaSubString string
|
||||
@@ -98,13 +98,14 @@ func (c *Config) setDefaults() {
|
||||
// Source implements source.CatalogueSource for Madara-based sites.
|
||||
type Source struct {
|
||||
cfg Config
|
||||
client *httpclient.Client
|
||||
client *flare.Client
|
||||
id int64
|
||||
}
|
||||
|
||||
func New(cfg Config) *Source {
|
||||
cfg.setDefaults()
|
||||
c := httpclient.NewClient(httpclient.WithRateLimit(1, 2))
|
||||
opts := []flare.Option{flare.WithRateLimit(1, 2)}
|
||||
c := flare.NewClient(opts...)
|
||||
return &Source{
|
||||
cfg: cfg,
|
||||
client: c,
|
||||
|
||||
@@ -10,22 +10,22 @@ import (
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
|
||||
"goyomi/internal/httpclient"
|
||||
"goyomi/internal/httpclient/flare"
|
||||
"goyomi/internal/source"
|
||||
"goyomi/sources/base/util"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Name string
|
||||
BaseURL string
|
||||
Lang string
|
||||
TypeParam string // "comic", "manga", "manhwa", etc.
|
||||
ChapterListID string // ID of chapter list container, default "en-chapters"
|
||||
Name string
|
||||
BaseURL string
|
||||
Lang string
|
||||
TypeParam string // "comic", "manga", "manhwa", etc.
|
||||
ChapterListID string // ID of chapter list container, default "en-chapters"
|
||||
}
|
||||
|
||||
type Source struct {
|
||||
cfg Config
|
||||
client *httpclient.Client
|
||||
client *flare.Client
|
||||
id int64
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ func New(cfg Config) *Source {
|
||||
if cfg.ChapterListID == "" {
|
||||
cfg.ChapterListID = "en-chapters"
|
||||
}
|
||||
c := httpclient.NewClient(httpclient.WithRateLimit(1, 2))
|
||||
opts := []flare.Option{flare.WithRateLimit(1, 2)}
|
||||
c := flare.NewClient(opts...)
|
||||
return &Source{cfg: cfg, client: c, id: source.GenerateSourceID(cfg.Name, cfg.Lang)}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
|
||||
"goyomi/internal/httpclient"
|
||||
"goyomi/internal/httpclient/flare"
|
||||
"goyomi/internal/source"
|
||||
"goyomi/sources/base/util"
|
||||
)
|
||||
@@ -73,13 +73,14 @@ func (c *Config) setDefaults() {
|
||||
// Source implements source.CatalogueSource for MangaThemesia sites.
|
||||
type Source struct {
|
||||
cfg Config
|
||||
client *httpclient.Client
|
||||
client *flare.Client
|
||||
id int64
|
||||
}
|
||||
|
||||
func New(cfg Config) *Source {
|
||||
cfg.setDefaults()
|
||||
c := httpclient.NewClient(httpclient.WithRateLimit(1, 2))
|
||||
opts := []flare.Option{flare.WithRateLimit(1, 2)}
|
||||
c := flare.NewClient(opts...)
|
||||
return &Source{
|
||||
cfg: cfg,
|
||||
client: c,
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
|
||||
"goyomi/internal/httpclient"
|
||||
"goyomi/internal/httpclient/flare"
|
||||
"goyomi/internal/source"
|
||||
"goyomi/sources/base/util"
|
||||
)
|
||||
@@ -23,12 +23,13 @@ type Config struct {
|
||||
|
||||
type Source struct {
|
||||
cfg Config
|
||||
client *httpclient.Client
|
||||
client *flare.Client
|
||||
id int64
|
||||
}
|
||||
|
||||
func New(cfg Config) *Source {
|
||||
c := httpclient.NewClient(httpclient.WithRateLimit(1, 2))
|
||||
opts := []flare.Option{flare.WithRateLimit(1, 2)}
|
||||
c := flare.NewClient(opts...)
|
||||
return &Source{cfg: cfg, client: c, id: source.GenerateSourceID(cfg.Name, cfg.Lang)}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
|
||||
"goyomi/internal/httpclient"
|
||||
"goyomi/internal/httpclient/flare"
|
||||
"goyomi/internal/source"
|
||||
"goyomi/sources/base/util"
|
||||
)
|
||||
@@ -23,12 +23,13 @@ type Config struct {
|
||||
|
||||
type Source struct {
|
||||
cfg Config
|
||||
client *httpclient.Client
|
||||
client *flare.Client
|
||||
id int64
|
||||
}
|
||||
|
||||
func New(cfg Config) *Source {
|
||||
c := httpclient.NewClient(httpclient.WithRateLimit(1, 2))
|
||||
opts := []flare.Option{flare.WithRateLimit(1, 2)}
|
||||
c := flare.NewClient(opts...)
|
||||
return &Source{cfg: cfg, client: c, id: source.GenerateSourceID(cfg.Name, cfg.Lang)}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user