Skip to content

Commit

Permalink
Removed check in http client
Browse files Browse the repository at this point in the history
  • Loading branch information
Girbons committed Apr 26, 2022
1 parent 22bbde0 commit 3d188cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

// Tag specifies the current release tag.
// It needs to be manually updated.
const Tag = "v0.33.0"
const Tag = "v0.33.1-alpha"

// IsNewAvailable will fetch the latest project releases
// and will compare the latest release Tag against the current Tag.
Expand Down
7 changes: 1 addition & 6 deletions pkg/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package http

import (
"net/http"
"strings"
)

// ComicClient is the custom client.
Expand All @@ -20,11 +19,7 @@ func NewComicClient() *ComicClient {
// PrepareRequest setup a `GET` request with customs headers.
func (c *ComicClient) PrepareRequest(link string) (*http.Request, error) {
req, err := http.NewRequest("GET", link, nil)

if strings.Contains(link, "mangakakalot") {
// avoid that MangaKakalot forbids the request.
req.Header.Add("Referer", link)
}
req.Header.Add("Referer", link)

return req, err
}
Expand Down
15 changes: 8 additions & 7 deletions pkg/sites/manganato_test.go
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
package sites

import (
"github.com/Girbons/comics-downloader/pkg/core"
"testing"

"github.com/Girbons/comics-downloader/pkg/core"

"github.com/Girbons/comics-downloader/internal/logger"
"github.com/Girbons/comics-downloader/pkg/config"
"github.com/stretchr/testify/assert"
)

func TestManganatoGetInfo(t *testing.T) {
opt := &config.Options{
URL: "https://readmanganato.com/manga-ny955333",
URL: "https://manganato.com/manga-ny955333",
All: false,
Last: false,
Debug: false,
Logger: logger.NewLogger(false, make(chan string)),
}
mg := NewManganato(opt)
// readmanganato.com
name, issueNumber := mg.GetInfo("https://readmanganato.com/manga-ny955333/chapter-36")
name, issueNumber := mg.GetInfo("https://manganato.com/manga-ny955333/chapter-36")
assert.Equal(t, "To The Past", name)
assert.Equal(t, "36", issueNumber)

// manganato.com
opt.URL = "https://manganato.com/manga-gd983838"
name, issueNumber = mg.GetInfo("https://readmanganato.com/manga-gd983838/chapter-76")
name, issueNumber = mg.GetInfo("https://manganato.com/manga-gd983838/chapter-76")
assert.Equal(t, "Voice And Written Words", name)
assert.Equal(t, "76", issueNumber)
}

func TestManganatoSetup(t *testing.T) {
opt := &config.Options{
URL: "https://readmanganato.com/manga-ny955333",
URL: "https://manganato.com/manga-ny955333",
All: false,
Last: false,
Debug: false,
Logger: logger.NewLogger(false, make(chan string)),
}
mk := NewManganato(opt)
comic := new(core.Comic)
comic.URLSource = "https://readmanganato.com/manga-ny955333/chapter-36"
comic.URLSource = "https://manganato.com/manga-ny955333/chapter-36"

err := mk.Initialize(comic)

Expand All @@ -50,7 +51,7 @@ func TestManganatoSetup(t *testing.T) {

func TestManganatoRetrieveIssueLinks(t *testing.T) {
opt := &config.Options{
URL: "https://readmanganato.com/manga-ny955333",
URL: "https://manganato.com/manga-ny955333",
All: false,
Last: false,
Debug: false,
Expand Down

0 comments on commit 3d188cd

Please sign in to comment.