Skip to content

Commit

Permalink
prepare v0.33.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Girbons committed Aug 16, 2022
1 parent ebd6cf4 commit 42a880c
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 81 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
[Changes][v0.33.3]
<a name="v0.33.3"></a>

# [0.33.3 (v0.33.3)](https://github.com/Girbons/comics-downloader/releases/tag/v0.33.3) - 16 Aug 2022

# Fixes

- #110: Restored readcomiconline.
- #113: Fixed -all argument for readallcomics.
- #114: ReadAllcomics fixed file overwrite.
- #115: Download images with the best quality by default.

[Changes][v0.33.2]
<a name="v0.33.2"></a>

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@

Download the latest release:

- [Linux](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader)
- [Mac OSX](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader-osx)
- [Windows](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader.exe)
- [Linux ARM](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader-linux-arm)
- [Linux ARM64](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader-linux-arm64)
- [Linux](https://github.com/Girbons/comics-downloader/releases/download/v0.33.3/comics-downloader)
- [Mac OSX](https://github.com/Girbons/comics-downloader/releases/download/v0.33.3/comics-downloader-osx)
- [Windows](https://github.com/Girbons/comics-downloader/releases/download/v0.33.3/comics-downloader.exe)
- [Linux ARM](https://github.com/Girbons/comics-downloader/releases/download/v0.33.3/comics-downloader-linux-arm)
- [Linux ARM64](https://github.com/Girbons/comics-downloader/releases/download/v0.33.3/comics-downloader-linux-arm64)

Download the latest GUI release:

- [Linux](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader-gui)
- [Mac OSX](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader-gui-osx)
- [Windows](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader-gui-windows.exe)
- [Linux](https://github.com/Girbons/comics-downloader/releases/download/v0.33.3/comics-downloader-gui)
- [Mac OSX](https://github.com/Girbons/comics-downloader/releases/download/v0.33.3/comics-downloader-gui-osx)
- [Windows](https://github.com/Girbons/comics-downloader/releases/download/v0.33.3/comics-downloader-gui-windows.exe)

## Usage

Expand Down
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.2"
const Tag = "v0.33.3"

// IsNewAvailable will fetch the latest project releases
// and will compare the latest release Tag against the current Tag.
Expand Down
21 changes: 11 additions & 10 deletions pkg/detector/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ import (

// SupportedSites are the supported sites.
var SupportedSites = map[string]map[string]bool{
"mangadex.org": {"isDisabled": false},
"mangareader.tv": {"isDisabled": true},
"readallcomics.com": {"isDisabled": false},
"readcomiconline.li": {"isDisabled": false},
"www.comicextra.com": {"isDisabled": false},
"www.mangahere.cc": {"isDisabled": false},
"www.mangatown.com": {"isDisabled": false},
"mangakakalot.com": {"isDisabled": false},
"manganato.com": {"isDisabled": false},
"readmanganato.com": {"isDisabled": false},
"mangadex.org": {"isDisabled": false},
"mangareader.tv": {"isDisabled": true},
"readallcomics.com": {"isDisabled": false},
"readcomiconline.li": {"isDisabled": false},
"readcomicsonline.ru": {"isDisabled": false},
"www.comicextra.com": {"isDisabled": false},
"www.mangahere.cc": {"isDisabled": false},
"www.mangatown.com": {"isDisabled": false},
"mangakakalot.com": {"isDisabled": false},
"manganato.com": {"isDisabled": false},
"readmanganato.com": {"isDisabled": false},
}

// DetectComic will look for the url source to check if a source is supported.
Expand Down
67 changes: 36 additions & 31 deletions pkg/sites/readallcomics.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,55 +48,60 @@ func (r *Readallcomics) retrieveImageLinks(comic *core.Comic) ([]string, error)
return links, err
}

func (r *Readallcomics) isSingleIssue(url string) bool {
response, _ := soup.Get(url)

doc := soup.HTMLParse(response)
chapters := doc.Find("select", "id", "selectbox").FindAll("option")

return len(chapters) == 1
}
// Retrieve issues links from main comic page or from comic issue.
func (r *Readallcomics) getIssues(url string) ([]string, error) {
var links []string

func (r *Readallcomics) retrieveLastIssue(url string) (string, error) {
response, err := soup.Get(url)
if err != nil {
return nil, err
}

// html tag to be extracted.
tagToExtract := "a"
// html tag value to be extracted.
tagValueToExtract := "href"
// retrieve links from main comic page.
doc := soup.HTMLParse(response)
chapters := doc.Find("select", "id", "selectbox").FindAll("option")
// apply default strategy to get issues link
chapters := doc.Find("ul", "class", "list-story")

if chapters.Error != nil {
// retrieve links from comic page.
chapters = doc.Find("select", "id", "selectbox")
tagToExtract = "option"
tagValueToExtract = "value"
}

for _, chapter := range chapters.FindAll(tagToExtract) {
issueUrl := chapter.Attrs()[tagValueToExtract]
if util.IsURLValid(issueUrl) {
links = append(links, issueUrl)
}
}

return chapters[0].Attrs()["value"], err
return links, nil
}

// RetrieveIssueLinks retrieves the links to all the issue.
func (r *Readallcomics) RetrieveIssueLinks() ([]string, error) {
url := r.options.URL

if r.options.Last {
lastIssue, err := r.retrieveLastIssue(url)
return []string{lastIssue}, err
}

if r.options.All && r.isSingleIssue(url) {
return []string{url}, nil
}
chapters, err := r.getIssues(url)

response, err := soup.Get(url)
if err != nil {
return nil, err
}

doc := soup.HTMLParse(response)
chapters := doc.Find("select", "id", "selectbox").FindAll("option")

var links []string
if r.options.Last {
return []string{chapters[len(chapters)-1]}, nil
}

for _, chapter := range chapters {
url := chapter.Attrs()["value"]
if util.IsURLValid(url) {
links = append(links, url)
}
if r.options.All && len(chapters) == 1 {
return []string{chapters[0]}, err
}

return links, err
return chapters, err
}

// GetInfo extracts the comic info from the given URL.
Expand All @@ -108,7 +113,7 @@ func (r *Readallcomics) GetInfo(url string) (string, string) {
splittedTitle := strings.Split(title, " ")

name := strings.Join(splittedTitle[:len(splittedTitle)-2], " ")
issueNumber := splittedTitle[len(splittedTitle)-2] // get the issue number
issueNumber := splittedTitle[len(splittedTitle)-1] // get the issue number
return name, issueNumber
}

Expand Down
16 changes: 3 additions & 13 deletions pkg/util/image.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package util

import (
"bytes"
"errors"
"image"
"image/gif"
Expand All @@ -14,16 +13,6 @@ import (
// IMAGEREGEX to extract the image html tag
const IMAGEREGEX = `<img[^>]+src="([^">]+)"`

// ConvertToJPG converts an image to jpeg
func ConvertToJPG(img image.Image, imgData *bytes.Buffer) error {
err := jpeg.Encode(imgData, img, nil)
if err != nil {
return err
}

return nil
}

// ImageType return the image type
func ImageType(mimeStr string) (tp string) {
switch mimeStr {
Expand Down Expand Up @@ -58,9 +47,10 @@ func SaveImage(w io.Writer, content io.Reader, format string) error {
case "gif":
return gif.Encode(w, img, nil)
case "jpg", "jpeg":
return jpeg.Encode(w, img, nil)
return jpeg.Encode(w, img, &jpeg.Options{Quality: 100})
case "png":
return png.Encode(w, img)
pngEncoder := png.Encoder{CompressionLevel: png.BestCompression}
return pngEncoder.Encode(w, img)
default:
return errors.New("format not found")
}
Expand Down
18 changes: 0 additions & 18 deletions pkg/util/image_test.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
package util

import (
"bytes"
"image/png"
"net/http"
"testing"

"github.com/stretchr/testify/assert"
)

func TestConvertImage(t *testing.T) {
imgURL := "http://via.placeholder.com/150"

resp, err := http.Get(imgURL)
assert.Nil(t, err)

defer resp.Body.Close()

img, _ := png.Decode(resp.Body)
imgData := new(bytes.Buffer)
err = ConvertToJPG(img, imgData)

assert.Nil(t, err)
}

func TestImageType(t *testing.T) {
assert.Equal(t, ImageType("image/jpg"), "jpg")
assert.Equal(t, ImageType("image/jpeg"), "jpg")
Expand Down

0 comments on commit 42a880c

Please sign in to comment.