Skip to content

Commit

Permalink
added and fixed comments to exported functions, removed useless else …
Browse files Browse the repository at this point in the history
…blocks
  • Loading branch information
Girbons committed Apr 10, 2019
1 parent 3a3abc5 commit 370845e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions cmd/app/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func init() {
log.SetLevel(log.InfoLevel)
}

// Run will run the downloader app
func Run(link, format, country string) {
conf := new(config.ComicConfig)
if err := conf.LoadConfig(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type ComicConfig struct {
DefaultOutputFormat string `mapstructure:"default_output_format"`
}

// LoadConfig, read the `config` file and unmarshal to struct
// LoadConfig read the `config` file and unmarshal to struct
func (c *ComicConfig) LoadConfig() error {
if err := viper.ReadInConfig(); err != nil {
return err
Expand Down
16 changes: 9 additions & 7 deletions pkg/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ func (comic *Comic) makeEPUB() error {

if err = e.Write(comic.generateFileName(dir)); err != nil {
return err
} else {
log.Info(fmt.Sprintf("%s %s", strings.ToUpper(comic.Format), DEFAULT_MESSAGE))
}

log.Info(fmt.Sprintf("%s %s", strings.ToUpper(comic.Format), DEFAULT_MESSAGE))

return err
}

Expand Down Expand Up @@ -300,15 +300,17 @@ func (comic *Comic) makeCBRZ() error {
// then we can change the extension to .cbr or .cbz
zipArchiveName := fmt.Sprintf("%s/%s.zip", dir, comic.IssueNumber)
newName := fmt.Sprintf("%s/%s.%s", dir, comic.IssueNumber, comic.Format)

if err = archive.Archive(filesToAdd, zipArchiveName); err != nil {
return err
} else {
if err := os.Rename(zipArchiveName, newName); err != nil {
return err
}
log.Info(fmt.Sprintf("%s %s", strings.ToUpper(comic.Format), DEFAULT_MESSAGE))
}

if err := os.Rename(zipArchiveName, newName); err != nil {
return err
}

log.Info(fmt.Sprintf("%s %s", strings.ToUpper(comic.Format), DEFAULT_MESSAGE))

return err
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/sites/mangahere/mangahere.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ func retrieveImageLinks(comic *core.Comic) ([]string, error) {
return imgLinks, err
}

// SetupMangaHere will initialize the comic based
// on mangahere.cc
// Initialize loads links and metadata from mangahere
func Initialize(comic *core.Comic) error {
comic.Name = comic.SplitURL()[4]
comic.IssueNumber = comic.SplitURL()[5]
Expand Down
3 changes: 1 addition & 2 deletions pkg/sites/mangareader/mangareader.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ func retrieveImageLinks(comic *core.Comic) ([]string, error) {
return links, err
}

// Initialize the comic based
// www.mangareader.net
// Initialize loads links and metadata from mangareader
func Initialize(comic *core.Comic) error {
comic.Name = comic.SplitURL()[3]
comic.IssueNumber = comic.SplitURL()[4]
Expand Down
1 change: 1 addition & 0 deletions pkg/sites/mangarock/mangarock.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func findChapterName(chapterID string, chapters []*mangarock.Chapter) (string, b
return "", false
}

// Initialize loads links and metadata from mangarock
func Initialize(comic *core.Comic) error {
series := comic.SplitURL()[4]
chapterID := comic.SplitURL()[6]
Expand Down
3 changes: 1 addition & 2 deletions pkg/sites/mangatown/mangatown.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ func retrieveImageLinks(comic *core.Comic) ([]string, error) {

}

// SetupMangaTown will initialize the comic based
// on mangatown.com
// Initialize loads links and metadata from mangatown
func Initialize(comic *core.Comic) error {
comic.Name = comic.SplitURL()[4]
comic.IssueNumber = comic.SplitURL()[6]
Expand Down
10 changes: 5 additions & 5 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
log "github.com/sirupsen/logrus"
)

// Regex to extract the image html tag
// IMAGEREGEX to extract the image html tag
const IMAGEREGEX = `<img[^>]+src="([^">]+)"`

// URLSource will retrieve the url hostname.
Expand All @@ -28,7 +28,7 @@ func URLSource(u string) (string, error) {
return parsedUrl.Hostname(), nil
}

// IsUrlValid will exclude those url containing `.gif` and `logo`.
// IsURLValid will exclude those url containing `.gif` and `logo`.
func IsURLValid(value string) bool {
check := value != "" && !strings.Contains(value, ".gif") && !strings.Contains(value, "logo") && !strings.Contains(value, "mobilebanner")

Expand All @@ -39,7 +39,7 @@ func IsURLValid(value string) bool {
return check
}

// ValueInSlice will check if a value is already in a slice.
// IsValueInSlice will check if a value is already in a slice.
func IsValueInSlice(valueToCheck string, values []string) bool {
for _, v := range values {
if v == valueToCheck {
Expand All @@ -49,7 +49,7 @@ func IsValueInSlice(valueToCheck string, values []string) bool {
return false
}

// Converts an image of any type to a PNG with 8-bit color depth
// ConvertTo8BitPNG converts an image of any type to a PNG with 8-bit color depth
func ConvertTo8BitPNG(img image.Image, imgData *bytes.Buffer) error {
b := img.Bounds()
imgSet := image.NewRGBA(b)
Expand Down Expand Up @@ -102,7 +102,7 @@ func PathSetup(source, name string) (string, error) {
return dir, err
}

// FindMaxValueInSlice
// FindMaxValueInSlice return the max value
func FindMaxValueInSlice(values []int) int {
max := 0
for _, currentValue := range values {
Expand Down

0 comments on commit 370845e

Please sign in to comment.