From c7122a72a0094ff0ec17547447d6ecf5d00bceeb Mon Sep 17 00:00:00 2001 From: Alessandro De Angelis Date: Fri, 10 Jan 2020 15:52:26 +0100 Subject: [PATCH] Removed mangarock and disabled comicextra --- README.md | 2 - cmd/app/downloader.go | 9 ++- go.mod | 17 ++--- go.sum | 70 +++++++++----------- internal/version/version.go | 2 +- pkg/core/core.go | 36 +--------- pkg/core/core_test.go | 83 ----------------------- pkg/detector/detector.go | 16 ++++- pkg/detector/detector_test.go | 21 ++---- pkg/sites/base.go | 6 +- pkg/sites/comicextra_test.go | 86 ++++++++++++------------ pkg/sites/loader.go | 4 -- pkg/sites/loader_test.go | 44 ++++--------- pkg/sites/mangadex_test.go | 2 +- pkg/sites/mangarock.go | 121 ---------------------------------- pkg/sites/mangarock_test.go | 60 ----------------- 16 files changed, 128 insertions(+), 451 deletions(-) delete mode 100644 pkg/sites/mangarock.go delete mode 100644 pkg/sites/mangarock_test.go diff --git a/README.md b/README.md index 10b95f3f..c4b9683b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ ## Supported Sites - https://www.comicextra.com/ -- https://mangarock.com/ - https://www.mangareader.net/ - https://www.mangatown.com/ - https://mangadex.cc/ @@ -71,7 +70,6 @@ You can invoke the `--help`: | Source | all | country| last | |-----------------------------|--------|--------|--------| |http://www.comicextra.com/ |✓|✗|✓| -|https://mangarock.com/ |✓|✓|✓| |https://www.mangareader.net/ |✓|✗|✓| |http://www.mangatown.com/ |✓|✗|✓| |https://mangadex.cc/ |✓|✓|✓| diff --git a/cmd/app/downloader.go b/cmd/app/downloader.go index ea8c55d9..85d39f6f 100644 --- a/cmd/app/downloader.go +++ b/cmd/app/downloader.go @@ -49,7 +49,7 @@ func download(link, format, country string, all, last, bindLogsToChannel, images for _, u := range strings.Split(link, ",") { if u != "" { // check if the link is supported - source, check := detector.DetectComic(u) + source, check, isDisabled := detector.DetectComic(u) if !check { msg := "This site is not supported :(" log.WithFields(log.Fields{"site": u}).Error(msg) @@ -57,6 +57,13 @@ func download(link, format, country string, all, last, bindLogsToChannel, images continue } + if isDisabled { + msg := "Site currently disabled, please check https://github.com/Girbons/comics-downloader/issues/" + log.WithFields(log.Fields{"site": u}).Warning(msg) + sendToChannel(bindLogsToChannel, msg) + continue + } + msg := "Downloading..." log.WithFields(log.Fields{"url": u}).Info(msg) sendToChannel(bindLogsToChannel, msg) diff --git a/go.mod b/go.mod index a5e2e4f9..071491d6 100644 --- a/go.mod +++ b/go.mod @@ -1,24 +1,21 @@ module github.com/Girbons/comics-downloader -go 1.12 +go 1.13 require ( - fyne.io/fyne v1.1.1 - github.com/Girbons/mangarock v0.0.0-20190725180316-ca97fc422a34 + fyne.io/fyne v1.2.1 github.com/anaskhan96/soup v1.1.1 github.com/bake/mangadex v0.0.0-20191208094511-1b8be9f2df20 - github.com/bake/mri v0.0.0-20190425192657-438a0b611ec0 github.com/bmaupin/go-epub v0.5.3 github.com/dsnet/compress v0.0.1 // indirect - github.com/frankban/quicktest v1.4.1 // indirect github.com/golang/snappy v0.0.1 // indirect - github.com/jung-kurt/gofpdf v1.10.0 + github.com/jung-kurt/gofpdf v1.16.2 github.com/mholt/archiver v3.1.1+incompatible github.com/nwaples/rardecode v1.0.0 // indirect - github.com/pierrec/lz4 v2.2.6+incompatible // indirect - github.com/schollz/progressbar/v2 v2.13.2 + github.com/pierrec/lz4 v2.4.0+incompatible // indirect + github.com/schollz/progressbar/v2 v2.15.0 github.com/sirupsen/logrus v1.4.2 - github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709 + github.com/stretchr/testify v1.4.0 github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect - golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 // indirect + golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect ) diff --git a/go.sum b/go.sum index a7fef49c..c9b6df06 100644 --- a/go.sum +++ b/go.sum @@ -1,19 +1,12 @@ -fyne.io/fyne v1.1.1 h1:vmeT7lqdho+Upt/PWuDInj8xAkNAaZC/rbtr3goJczY= -fyne.io/fyne v1.1.1/go.mod h1:mz0CvQX1ACEjiDGpSH3D8Qf9yHq8dfYA039kG7p8ZhQ= -github.com/Girbons/mangarock v0.0.0-20190725180316-ca97fc422a34 h1:xA3kIurxuPIBtdLe8OCmsVTsxx+yDAYPKIYhOhLzE74= -github.com/Girbons/mangarock v0.0.0-20190725180316-ca97fc422a34/go.mod h1:4JwFTbX7V1Cm/RtPspR8JAoOYGcdMBNoKtku4m6B85c= +fyne.io/fyne v1.2.1 h1:0hicR1E+hZGwZUwN5LheR5SoPr/ror8fGzQR2qJcZkA= +fyne.io/fyne v1.2.1/go.mod h1:Ab+3DIB/FVteW0y4DXfmZv4N3JdnCBh2lHkINI02BOU= github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9/go.mod h1:7uhhqiBaR4CpN0k9rMjOtjpcfGd6DG2m04zQxKnWQ0I= github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/anaskhan96/soup v1.1.1 h1:Duux/0htS2Va7XLJ9qIakCSey790hg9OFRm2FwlMTy0= github.com/anaskhan96/soup v1.1.1/go.mod h1:pT5vs4HXDwA5y4KQCsKvnkpQd3D+joP7IqpiGskfWW0= -github.com/bake/httpcache v0.0.0-20190425194625-775d0adac809 h1:+WthOY6+9RdivM1SPr5KRregzgSYmu++u0uphYgmoyk= github.com/bake/httpcache v0.0.0-20190425194625-775d0adac809/go.mod h1:4NG8FC+Gt0aSRAFe+GcCsKUGCL63u0doQyQBQffWX90= -github.com/bake/mangadex v0.0.0-20190918122836-0261a89dc30d h1:WpnqIe+TLGBW+cHHm2SA8lwlCtIMYhWNl2H+Z0peTJM= -github.com/bake/mangadex v0.0.0-20190918122836-0261a89dc30d/go.mod h1:0EIa3RFRprO7Ey+7O0TveUY6epgxsabT82R3bkUjkzU= github.com/bake/mangadex v0.0.0-20191208094511-1b8be9f2df20 h1:QrnRIo2F6hK6LvPstkj4m0NFs+DRtUbgKfYqys42ec4= github.com/bake/mangadex v0.0.0-20191208094511-1b8be9f2df20/go.mod h1:0EIa3RFRprO7Ey+7O0TveUY6epgxsabT82R3bkUjkzU= -github.com/bake/mri v0.0.0-20190425192657-438a0b611ec0 h1:KwTV21ZriTZIZBdFU2g0HfPq8XYEkaMKJRS9oCbBwYY= -github.com/bake/mri v0.0.0-20190425192657-438a0b611ec0/go.mod h1:8fakjROSAHC99lr4SIARs4xZa0pPXcWTRT4TBaqfRHI= github.com/bmaupin/go-epub v0.5.3 h1:HBOJS2KqsRGGcEzM470/9l5q2l9JwAUxQabEgPMrW90= github.com/bmaupin/go-epub v0.5.3/go.mod h1:4RBr0Zo03mRGOyGAcc25eLOqIPCkMbfz+tINVmH6clQ= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= @@ -23,10 +16,10 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q= github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo= github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= -github.com/frankban/quicktest v1.4.1 h1:Wv2VwvNn73pAdFIVUQRXYDFp31lXKbqblIXo/Q5GPSg= -github.com/frankban/quicktest v1.4.1/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= -github.com/go-gl/gl v0.0.0-20181026044259-55b76b7df9d2 h1:78Hza2KHn2PX1jdydQnffaU2A/xM0g3Nx1xmMdep9Gk= -github.com/go-gl/gl v0.0.0-20181026044259-55b76b7df9d2/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluNRiMjZHalQZrVrvTbPh+qw= +github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk= github.com/go-gl/glfw v0.0.0-20181213070059-819e8ce5125f h1:7MsFMbSn8Lcw0blK4+NEOf8DuHoOBDhJsHz04yh13pM= github.com/go-gl/glfw v0.0.0-20181213070059-819e8ce5125f/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/gofrs/uuid v3.1.0+incompatible h1:q2rtkjaKT4YEr6E1kamy0Ha4RtepWlQBedyHx0uzKwA= @@ -35,24 +28,16 @@ github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff h1:W71vTCKoxtdXgnm1E github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff/go.mod h1:wfqRWLHRBsRgkp5dmbG56SA0DmVtwrF5N3oPdI8t+Aw= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/jackmordaunt/icns v0.0.0-20181231085925-4f16af745526/go.mod h1:UQkeMHVoNcyXYq9otUupF7/h/2tmHlhrS2zw7ZVvUqc= github.com/josephspurrier/goversioninfo v0.0.0-20190124120936-8611f5a5ff3f/go.mod h1:eJTEwMjXb7kZ633hO3Ln9mBUCOjX2+FlTljvpl9SYdE= github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/jung-kurt/gofpdf v1.10.0 h1:gjZ/7NVPpYKbeCD0KdIZOEzxgkEtqRGoXWbyyGMX8fI= -github.com/jung-kurt/gofpdf v1.10.0/go.mod h1:s/VXv+TdctEOx2wCEguezYaR7f0OwUAd6H9VGfRkcSs= +github.com/jung-kurt/gofpdf v1.16.2 h1:jgbatWHfRlPYiK85qgevsZTHviWXKwB1TTiKdz5PtRc= +github.com/jung-kurt/gofpdf v1.16.2/go.mod h1:1hl7y57EsiPAkLbOwzpzqgx1A30nQCk/YmFV8S2vmK0= github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mholt/archiver v3.1.1+incompatible h1:1dCVxuqs0dJseYEhi5pl7MYPH9zDa1wBi7mF09cbNkU= github.com/mholt/archiver v3.1.1+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= @@ -60,47 +45,54 @@ github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/nwaples/rardecode v1.0.0 h1:r7vGuS5akxOnR4JQSkko62RJ1ReCMXxQRPtxsiFMBOs= github.com/nwaples/rardecode v1.0.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= -github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/phpdave11/gofpdi v1.0.7/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= -github.com/pierrec/lz4 v2.2.6+incompatible h1:6aCX4/YZ9v8q69hTyiR7dNLnTA3fgtKHVVW5BCd5Znw= -github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrec/lz4 v2.4.0+incompatible h1:06usnXXDNcPvCHDkmPpkidf4jTc52UKld7UPfqKatY4= +github.com/pierrec/lz4 v2.4.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= -github.com/schollz/progressbar/v2 v2.13.2 h1:3L9bP5KQOGEnFP8P5V8dz+U0yo5I29iY5Oa9s9EAwn0= -github.com/schollz/progressbar/v2 v2.13.2/go.mod h1:6YZjqdthH6SCZKv2rqGryrxPtfmRB/DWZxSMfCXPyD8= +github.com/schollz/progressbar v1.0.0 h1:gbyFReLHDkZo8mxy/dLWMr+Mpb1MokGJ1FqCiqacjZM= +github.com/schollz/progressbar/v2 v2.15.0 h1:dVzHQ8fHRmtPjD3K10jT3Qgn/+H+92jhPrhmxIJfDz8= +github.com/schollz/progressbar/v2 v2.15.0/go.mod h1:UdPq3prGkfQ7MOzZKlDRpYKcFqEMczbD7YmbPgpzKMI= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/srwiley/oksvg v0.0.0-20190105194046-ccbc7673cdf3 h1:8REQ/vZZIZFaZedUSHd7TVkK0CF4heqGtmyz30gCxm8= -github.com/srwiley/oksvg v0.0.0-20190105194046-ccbc7673cdf3/go.mod h1:afMbS0qvv1m5tfENCwnOdZGOF8RGR/FsZ7bvBxQGZG4= +github.com/srwiley/oksvg v0.0.0-20190829233741-58e08c8fe40e h1:LJUrNHytcMXWKxnULIHPe5SCb1jDpO9o672VB1x2EuQ= +github.com/srwiley/oksvg v0.0.0-20190829233741-58e08c8fe40e/go.mod h1:afMbS0qvv1m5tfENCwnOdZGOF8RGR/FsZ7bvBxQGZG4= github.com/srwiley/rasterx v0.0.0-20181219215540-696f7edb7a7e h1:FFotfUvew9Eg02LYRl8YybAnm0HCwjjfY5JlOI1oB00= github.com/srwiley/rasterx v0.0.0-20181219215540-696f7edb7a7e/go.mod h1:mvWM0+15UqyrFKqdRjY6LuAVJR0HOVhJlEgZ5JWtSWU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709 h1:Ko2LQMrRU+Oy/+EDBwX7eZ2jp3C47eDBB8EIhKTun+I= github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/ulikunitz/xz v0.5.6 h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8= github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/image v0.0.0-20181116024801-cd38e8056d9b/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= -golang.org/x/image v0.0.0-20190507092727-e4e5bf290fec h1:arXJwtMuk5vqI1NHX0UTnNw977rYk5Sl4jQqHj+hun4= -golang.org/x/image v0.0.0-20190507092727-e4e5bf290fec/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a h1:gHevYm0pO4QUbwy8Dmdr01R5r1BuKtfYqRqF0h/Cbh0= +golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb h1:fgwFCsaw9buMuxNd6+DQfAuSFqbNiQZpcgJQAgJsK6k= +golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/version/version.go b/internal/version/version.go index fb83818f..88e57dc9 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -2,4 +2,4 @@ package version // Tag specifies the current release tag. // It needs to be manually updated. -const Tag = "v0.19.1" +const Tag = "v0.20.0" diff --git a/pkg/core/core.go b/pkg/core/core.go index ad35e4b1..884c43e6 100644 --- a/pkg/core/core.go +++ b/pkg/core/core.go @@ -3,14 +3,12 @@ package core import ( "bytes" "fmt" - "io" "io/ioutil" "net/http" "os" "strings" "github.com/Girbons/comics-downloader/pkg/util" - "github.com/bake/mri" epub "github.com/bmaupin/go-epub" "github.com/jung-kurt/gofpdf" "github.com/mholt/archiver" @@ -41,37 +39,6 @@ type Comic struct { ImagesFormat string } -// RetrieveImageFromResponse will return the image byte and its type -func (comic *Comic) retrieveImageFromResponse(response *http.Response) (io.Reader, string, error) { - var ( - content io.Reader - tp string - err error - ) - - switch comic.Source { - case "mangarock.com": - // mangarock image needs to be decoded first - img, decErr := mri.Decode(response.Body) - if decErr != nil { - return content, tp, decErr - } - - imgData := new(bytes.Buffer) - if err := util.ConvertToJPG(img, imgData); err != nil { - return content, tp, err - } - - content = imgData - tp = "jpg" - default: - content = response.Body - tp = util.ImageType(response.Header["Content-Type"][0]) - } - - return content, tp, err -} - // makeEPUB create the epub file func (comic *Comic) makeEPUB(outputFolder string) error { var err error @@ -279,7 +246,6 @@ func (comic *Comic) DownloadImages(outputFolder string) (string, error) { defer rsp.Body.Close() // retrieve the image from the response - content, _, err := comic.retrieveImageFromResponse(rsp) if err != nil { return dir, err } @@ -290,7 +256,7 @@ func (comic *Comic) DownloadImages(outputFolder string) (string, error) { } defer imgFile.Close() - err = util.SaveImage(imgFile, content, format) + err = util.SaveImage(imgFile, rsp.Body, format) if err != nil { return dir, err } diff --git a/pkg/core/core_test.go b/pkg/core/core_test.go index b1eeb2b5..0299f955 100644 --- a/pkg/core/core_test.go +++ b/pkg/core/core_test.go @@ -7,7 +7,6 @@ import ( "path/filepath" "testing" - "github.com/Girbons/mangarock" "github.com/stretchr/testify/assert" ) @@ -70,88 +69,6 @@ func TestMakeComicEPUB(t *testing.T) { assert.True(t, exists(dir)) } -func TestMakeComicEPUBMangarock(t *testing.T) { - options := map[string]string{"country": "italy"} - client := mangarock.NewClientWithOptions(options) - result, _ := client.Pages("mrs-chapter-100051049") - - comic := new(Comic) - - comic.Name = "Boruto" - comic.Format = "epub" - comic.IssueNumber = "chapter-13" - comic.Source = "mangarock.com" - comic.ImagesFormat = "png" - comic.Links = result.Data - - err := comic.MakeComic(filepath.Dir(os.Args[0])) - assert.Nil(t, err) - - dir, _ := filepath.Abs(fmt.Sprintf("%s/%s/%s/%s/%s/", filepath.Dir(os.Args[0]), "comics", "mangarock.com", "Boruto", "Boruto-chapter-13.epub")) - assert.True(t, exists(dir)) -} - -func TestMakeComicCBZMangarock(t *testing.T) { - options := map[string]string{"country": "italy"} - client := mangarock.NewClientWithOptions(options) - result, _ := client.Pages("mrs-chapter-100051049") - - comic := new(Comic) - comic.Name = "Boruto" - comic.Format = "cbz" - comic.IssueNumber = "chapter-13" - comic.Source = "mangarock.com" - comic.ImagesFormat = "png" - comic.Links = result.Data - - err := comic.MakeComic(filepath.Dir(os.Args[0])) - assert.Nil(t, err) - - dir, _ := filepath.Abs(fmt.Sprintf("%s/%s/%s/%s/%s/", filepath.Dir(os.Args[0]), "comics", "mangarock.com", "Boruto", "Boruto-chapter-13.cbz")) - assert.True(t, exists(dir)) -} - -func TestMakeComicCBRMangarock(t *testing.T) { - options := map[string]string{"country": "italy"} - client := mangarock.NewClientWithOptions(options) - result, _ := client.Pages("mrs-chapter-100051049") - - comic := new(Comic) - comic.Name = "Boruto" - comic.Format = "cbr" - comic.IssueNumber = "chapter-13" - comic.Source = "mangarock.com" - comic.ImagesFormat = "png" - comic.Links = result.Data - - err := comic.MakeComic(filepath.Dir(os.Args[0])) - assert.Nil(t, err) - - dir, _ := filepath.Abs(fmt.Sprintf("%s/%s/%s/%s/%s/", filepath.Dir(os.Args[0]), "comics", "mangarock.com", "Boruto", "Boruto-chapter-13.cbr")) - assert.True(t, exists(dir)) -} - -func TestMakeComicPDFMangarock(t *testing.T) { - options := map[string]string{"country": "italy"} - client := mangarock.NewClientWithOptions(options) - result, _ := client.Pages("mrs-chapter-100051049") - - comic := new(Comic) - - comic.Name = "Boruto" - comic.Format = "pdf" - comic.IssueNumber = "chapter-13" - comic.Source = "mangarock.com" - comic.ImagesFormat = "jpg" - comic.Links = result.Data - - err := comic.MakeComic(filepath.Dir(os.Args[0])) - assert.Nil(t, err) - - dir, _ := filepath.Abs(fmt.Sprintf("%s/%s/%s/%s/%s/", filepath.Dir(os.Args[0]), "comics", "mangarock.com", "Boruto", "Boruto-chapter-13.pdf")) - assert.True(t, exists(dir)) -} - func TestDownloadImagesPNGFormat(t *testing.T) { comic := new(Comic) diff --git a/pkg/detector/detector.go b/pkg/detector/detector.go index 8f948532..235cea98 100644 --- a/pkg/detector/detector.go +++ b/pkg/detector/detector.go @@ -7,7 +7,11 @@ import ( ) // DetectComic will look for the url source to check if a source is supported. -func DetectComic(url string) (string, bool) { +func DetectComic(url string) (string, bool, bool) { + isSupported := false + isDisabled := false + source := "" + source, err := util.URLSource(url) if err != nil { @@ -16,9 +20,15 @@ func DetectComic(url string) (string, bool) { for _, site := range sites.SupportedSites { if source == site { - return source, true + isSupported = true + } + } + + for _, site := range sites.DisabledSites { + if source == site { + isDisabled = true } } - return "", false + return source, isSupported, isDisabled } diff --git a/pkg/detector/detector_test.go b/pkg/detector/detector_test.go index 90ca94aa..69399a33 100644 --- a/pkg/detector/detector_test.go +++ b/pkg/detector/detector_test.go @@ -7,29 +7,16 @@ import ( ) func TestDetectComicExtra(t *testing.T) { - source, check := DetectComic("http://www.comicextra.com/daredevil-2016/chapter-600/full") + source, check, isDisabled := DetectComic("http://www.comicextra.com/daredevil-2015/chapter-600/full") assert.True(t, check) + assert.True(t, isDisabled) assert.Equal(t, "www.comicextra.com", source) } -//func TestDetectMangaHere(t *testing.T) { -//source, check := DetectComic("http://www.mangahere.cc/manga/shingeki_no_kyojin_before_the_fall/c048/") - -//assert.False(t, check) -//assert.Equal(t, "www.mangahere.cc", source) -//} - -func TestDetectMangaRock(t *testing.T) { - source, check := DetectComic("https://mangarock.com/manga/mrs-serie-35593/chapter/mrs-chapter-100051049") - - assert.True(t, check) - assert.Equal(t, "mangarock.com", source) -} - func TestUnsupportedSource(t *testing.T) { - source, check := DetectComic("http://example.com") + _, check, isDisabled := DetectComic("http://example.com") assert.False(t, check) - assert.Equal(t, "", source) + assert.False(t, isDisabled) } diff --git a/pkg/sites/base.go b/pkg/sites/base.go index 5e611885..1e1fefba 100644 --- a/pkg/sites/base.go +++ b/pkg/sites/base.go @@ -5,13 +5,17 @@ import "github.com/Girbons/comics-downloader/pkg/core" // SupportedSites are the supported sites. var SupportedSites = []string{ "www.comicextra.com", - "mangarock.com", "www.mangareader.net", "www.mangatown.com", "www.mangahere.cc", "mangadex.cc", } +// DisabledSites are the sites that are currently disabled. +var DisabledSites = []string{ + "www.comicextra.com", +} + // BaseSite specifies an implementation of a Site which allows you // to retrieve a manga/comic basics info and imges links type BaseSite interface { diff --git a/pkg/sites/comicextra_test.go b/pkg/sites/comicextra_test.go index 09ab2153..be9093ae 100644 --- a/pkg/sites/comicextra_test.go +++ b/pkg/sites/comicextra_test.go @@ -1,59 +1,59 @@ package sites -import ( - "testing" +//import ( +//"testing" - "github.com/Girbons/comics-downloader/pkg/core" - "github.com/stretchr/testify/assert" -) +//"github.com/Girbons/comics-downloader/pkg/core" +//"github.com/stretchr/testify/assert" +//) -func TestComicExtraSetup(t *testing.T) { - comic := new(core.Comic) - comic.URLSource = "https://www.comicextra.com/batman-2016/chapter-58/full" +//func TestComicExtraSetup(t *testing.T) { +//comic := new(core.Comic) +//comic.URLSource = "https://www.comicextra.com/batman-2016/chapter-58/full" - comicextra := new(Comicextra) - err := comicextra.Initialize(comic) +//comicextra := new(Comicextra) +//err := comicextra.Initialize(comic) - assert.Nil(t, err) - assert.Equal(t, 24, len(comic.Links)) -} +//assert.Nil(t, err) +//assert.Equal(t, 24, len(comic.Links)) +//} -func TestComicExtraGetInfo(t *testing.T) { - comicextra := new(Comicextra) - name, issueNumber := comicextra.GetInfo("https://www.comicextra.com/batman-2016/chapter-58/full") +//func TestComicExtraGetInfo(t *testing.T) { +//comicextra := new(Comicextra) +//name, issueNumber := comicextra.GetInfo("https://www.comicextra.com/batman-2016/chapter-58/full") - assert.Equal(t, "batman-2016", name) - assert.Equal(t, "chapter-58", issueNumber) -} +//assert.Equal(t, "batman-2016", name) +//assert.Equal(t, "chapter-58", issueNumber) +//} -func TestComicextraRetrieveIssueLinks(t *testing.T) { - comicextra := new(Comicextra) - issues, err := comicextra.RetrieveIssueLinks("https://www.comicextra.com/comic/100-bullets", false, false) +//func TestComicextraRetrieveIssueLinks(t *testing.T) { +//comicextra := new(Comicextra) +//issues, err := comicextra.RetrieveIssueLinks("https://www.comicextra.com/comic/100-bullets", false, false) - assert.Nil(t, err) - assert.Equal(t, 100, len(issues)) -} +//assert.Nil(t, err) +//assert.Equal(t, 100, len(issues)) +//} -func TestComicextraRetrieveIssueLinksLastChapter(t *testing.T) { - comicextra := new(Comicextra) - issues, err := comicextra.RetrieveIssueLinks("https://www.comicextra.com/comic/100-bullets", false, true) +//func TestComicextraRetrieveIssueLinksLastChapter(t *testing.T) { +//comicextra := new(Comicextra) +//issues, err := comicextra.RetrieveIssueLinks("https://www.comicextra.com/comic/100-bullets", false, true) - assert.Nil(t, err) - assert.Equal(t, 1, len(issues)) -} +//assert.Nil(t, err) +//assert.Equal(t, 1, len(issues)) +//} -func TestComicExtraRetrieveLastIssueLink(t *testing.T) { - comicextra := new(Comicextra) - issue, err := comicextra.retrieveLastIssue("https://www.comicextra.com/comic/100-bullets") +//func TestComicExtraRetrieveLastIssueLink(t *testing.T) { +//comicextra := new(Comicextra) +//issue, err := comicextra.retrieveLastIssue("https://www.comicextra.com/comic/100-bullets") - assert.Nil(t, err) - assert.Equal(t, "https://www.comicextra.com/100-bullets/chapter-100", issue) -} +//assert.Nil(t, err) +//assert.Equal(t, "https://www.comicextra.com/100-bullets/chapter-100", issue) +//} -func TestComicExtraRetrieveLastIssueLinkNotDetail(t *testing.T) { - comicextra := new(Comicextra) - issue, err := comicextra.retrieveLastIssue("https://www.comicextra.com/comic/100-bullets") +//func TestComicExtraRetrieveLastIssueLinkNotDetail(t *testing.T) { +//comicextra := new(Comicextra) +//issue, err := comicextra.retrieveLastIssue("https://www.comicextra.com/comic/100-bullets") - assert.Nil(t, err) - assert.Equal(t, "https://www.comicextra.com/100-bullets/chapter-100", issue) -} +//assert.Nil(t, err) +//assert.Equal(t, "https://www.comicextra.com/100-bullets/chapter-100", issue) +//} diff --git a/pkg/sites/loader.go b/pkg/sites/loader.go index 3215455f..e2b576c7 100644 --- a/pkg/sites/loader.go +++ b/pkg/sites/loader.go @@ -50,13 +50,9 @@ func LoadComicFromSource(source, url, country, format, imagesFormat string, all, var issues []string var err error - options := map[string]string{"country": country} - switch source { case "www.comicextra.com": siteSource = &Comicextra{} - case "mangarock.com": - siteSource = NewMangarock(options) case "www.mangareader.net": siteSource = &Mangareader{} case "www.mangatown.com": diff --git a/pkg/sites/loader_test.go b/pkg/sites/loader_test.go index 2b429876..7d9bcca9 100644 --- a/pkg/sites/loader_test.go +++ b/pkg/sites/loader_test.go @@ -26,23 +26,6 @@ func TestSiteLoaderMangatown(t *testing.T) { assert.Equal(t, 20, len(comic.Links)) } -func TestSiteLoaderMangarock(t *testing.T) { - url := "https://mangarock.com/manga/mrs-serie-35593/chapter/mrs-chapter-100051049" - outputFolder := filepath.Dir(os.Args[0]) - collection, err := LoadComicFromSource("mangarock.com", url, "italy", "pdf", "png", false, false, false, outputFolder) - - assert.Nil(t, err) - assert.Equal(t, len(collection), 1) - - comic := collection[0] - - assert.Equal(t, "mangarock.com", comic.Source) - assert.Equal(t, url, comic.URLSource) - assert.Equal(t, "Boruto Naruto Next Generations", comic.Name) - assert.Equal(t, "Vol 4 Chapter 14 Teamwork", comic.IssueNumber) - assert.Equal(t, 49, len(comic.Links)) -} - func TestSiteLoaderMangareader(t *testing.T) { url := "https://www.mangareader.net/naruto/700" outputFolder := filepath.Dir(os.Args[0]) @@ -60,22 +43,23 @@ func TestSiteLoaderMangareader(t *testing.T) { assert.Equal(t, 23, len(comic.Links)) } -func TestSiteLoaderComicExtra(t *testing.T) { - url := "https://www.comicextra.com/daredevil-2016/chapter-600/full" - outputFolder := filepath.Dir(os.Args[0]) - collection, err := LoadComicFromSource("www.comicextra.com", url, "", "pdf", "png", false, false, false, outputFolder) +// DISABLED --> https://github.com/Girbons/comics-downloader/issues/47 +//func TestSiteLoaderComicExtra(t *testing.T) { +//url := "https://www.comicextra.com/daredevil-2016/chapter-600/full" +//outputFolder := filepath.Dir(os.Args[0]) +//collection, err := LoadComicFromSource("www.comicextra.com", url, "", "pdf", "png", false, false, false, outputFolder) - assert.Nil(t, err) - assert.Equal(t, len(collection), 1) +//assert.Nil(t, err) +//assert.Equal(t, len(collection), 1) - comic := collection[0] +//comic := collection[0] - assert.Equal(t, "www.comicextra.com", comic.Source) - assert.Equal(t, url, comic.URLSource) - assert.Equal(t, "daredevil-2016", comic.Name) - assert.Equal(t, "chapter-600", comic.IssueNumber) - assert.Equal(t, 43, len(comic.Links)) -} +//assert.Equal(t, "www.comicextra.com", comic.Source) +//assert.Equal(t, url, comic.URLSource) +//assert.Equal(t, "daredevil-2016", comic.Name) +//assert.Equal(t, "chapter-600", comic.IssueNumber) +//assert.Equal(t, 43, len(comic.Links)) +//} func TestLoaderUnknownSource(t *testing.T) { url := "http://example.com" diff --git a/pkg/sites/mangadex_test.go b/pkg/sites/mangadex_test.go index 555282f1..dc4e8bbb 100644 --- a/pkg/sites/mangadex_test.go +++ b/pkg/sites/mangadex_test.go @@ -46,7 +46,7 @@ func TestMangadexRetrieveIssueLinksLastChapter(t *testing.T) { urls, err := md.RetrieveIssueLinks("https://mangadex.cc/title/5/naruto/", false, true) assert.Nil(t, err) assert.Len(t, urls, 1) - assert.Equal(t, "https://mangadex.cc/chapter/670438", urls[0]) + assert.Equal(t, "https://mangadex.cc/chapter670438", urls[0]) } func TestMangadexUnsupportedURL(t *testing.T) { diff --git a/pkg/sites/mangarock.go b/pkg/sites/mangarock.go deleted file mode 100644 index d362a87e..00000000 --- a/pkg/sites/mangarock.go +++ /dev/null @@ -1,121 +0,0 @@ -package sites - -import ( - "strings" - - "github.com/Girbons/comics-downloader/pkg/core" - "github.com/Girbons/comics-downloader/pkg/util" - "github.com/Girbons/mangarock" - log "github.com/sirupsen/logrus" -) - -type Mangarock struct { - Client *mangarock.Client -} - -func NewMangarock(options map[string]string) *Mangarock { - return &Mangarock{ - Client: mangarock.NewClientWithOptions(options), - } -} - -func (m *Mangarock) findChapterName(chapterID string, chapters []*mangarock.Chapter) (string, bool) { - for _, chapter := range chapters { - if chapter.OID == chapterID { - return chapter.Name, true - } - } - return "", false -} - -func (m *Mangarock) isSingleIssue(url string) bool { - return len(util.TrimAndSplitURL(url)) >= 6 -} - -func (m *Mangarock) retrieveLastIssue(url string) (string, error) { - url = strings.Join(util.TrimAndSplitURL(url)[:5], "/") - series := util.TrimAndSplitURL(url)[4] - - info, infoErr := m.Client.Info(series) - - if infoErr != nil { - return "", infoErr - } - - lastChapter := info.Data.Chapters[len(info.Data.Chapters)-1] - chapterUrl := url + "/chapter/" + lastChapter.OID - - return chapterUrl, nil -} - -// RetrieveIssueLinks gets a slice of urls for all issues in a comic -func (m *Mangarock) RetrieveIssueLinks(url string, all, last bool) ([]string, error) { - if last { - url, err := m.retrieveLastIssue(url) - return []string{url}, err - } - - if all && m.isSingleIssue(url) { - url = strings.Join(util.TrimAndSplitURL(url)[:5], "/") - } else if m.isSingleIssue(url) { - return []string{url}, nil - } - - var links []string - - series := util.TrimAndSplitURL(url)[4] - // get info about the manga - info, infoErr := m.Client.Info(series) - if infoErr != nil { - log.Error(infoErr) - } - - for _, chapter := range info.Data.Chapters { - chapterUrl := url + "/chapter/" + chapter.OID - if util.IsURLValid(chapterUrl) { - links = append(links, chapterUrl) - } - } - - return links, nil -} - -func (m *Mangarock) GetInfo(url string) (string, string) { - parts := util.TrimAndSplitURL(url) - series := parts[4] - chapterID := parts[6] - - info, err := m.Client.Info(series) - - if err != nil { - return "", "" - } - - chapter, found := m.findChapterName(chapterID, info.Data.Chapters) - if !found { - log.Warning("Chapter not found") - chapter = chapterID - } - - return info.Data.Name, chapter -} - -// Initialize loads links and metadata from mangarock -func (m *Mangarock) Initialize(comic *core.Comic) error { - // get info about the manga - parts := util.TrimAndSplitURL(comic.URLSource) - series := parts[4] - chapterID := parts[6] - // retrieve pages - info, err := m.Client.Info(series) - if err != nil { - return err - } - - pages, pagesErr := m.Client.Pages(chapterID) - - comic.Author = info.Data.Author - comic.Links = pages.Data - - return pagesErr -} diff --git a/pkg/sites/mangarock_test.go b/pkg/sites/mangarock_test.go deleted file mode 100644 index 74762f51..00000000 --- a/pkg/sites/mangarock_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package sites - -import ( - "testing" - - "github.com/Girbons/comics-downloader/pkg/core" - "github.com/stretchr/testify/assert" -) - -func TestMangarockGetInfo(t *testing.T) { - options := map[string]string{"country": "italy"} - mr := NewMangarock(options) - - name, issueNumber := mr.GetInfo("https://mangarock.com/manga/mrs-serie-35593/chapter/mrs-chapter-100051049") - assert.Equal(t, "Boruto: Naruto Next Generations", name) - assert.Equal(t, "Vol.4 Chapter 14: Teamwork...!!", issueNumber) -} - -func TestMangarockSetup(t *testing.T) { - options := map[string]string{"country": "italy"} - mr := NewMangarock(options) - comic := new(core.Comic) - - comic.URLSource = "https://mangarock.com/manga/mrs-serie-35593/chapter/mrs-chapter-100051049" - - err := mr.Initialize(comic) - - assert.Nil(t, err) - assert.Equal(t, 49, len(comic.Links)) -} - -func TestMangarockRetrieveIssueLinks(t *testing.T) { - options := map[string]string{"country": "italy"} - mr := NewMangarock(options) - - issues, err := mr.RetrieveIssueLinks("https://mangarock.com/manga/mrs-serie-173467", false, false) - - assert.Nil(t, err) - assert.Equal(t, 700, len(issues)) -} - -func TestMangarockRetrieveIssueLinksLastChapter(t *testing.T) { - options := map[string]string{"country": "italy"} - mr := NewMangarock(options) - - issues, err := mr.RetrieveIssueLinks("https://mangarock.com/manga/mrs-serie-173467", false, true) - - assert.Nil(t, err) - assert.Equal(t, 1, len(issues)) -} - -func TestMangarockRetrieveLastIssueLink(t *testing.T) { - options := map[string]string{"country": "italy"} - mr := NewMangarock(options) - - issue, err := mr.retrieveLastIssue("https://mangarock.com/manga/mrs-serie-173467") - - assert.Nil(t, err) - assert.Equal(t, "https://mangarock.com/manga/mrs-serie-173467/chapter/mrs-chapter-174165", issue) -}