dmanga 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +17 -6
- data/dmanga.gemspec +2 -2
- data/lib/dmanga/mangahost_parser.rb +30 -10
- data/lib/dmanga/site_parser_base.rb +8 -7
- data/lib/dmanga/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2920708055ee2ee6e8bbab751c8b9d8bac78b9eb
|
4
|
+
data.tar.gz: ee8cd018624cd2ce7b693d7fc4a2f60531ba676a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63df1d4b6224b416071bbd97ecd146d83b7898f146016a6f6b42a32cdf3c5768b08530f4166b4822481fac91d24eda3e81937d55877ab09684fe548ca9a43819
|
7
|
+
data.tar.gz: 9e4fb2b772307529db17108c1fd3a88a0bebee3e854db2b4fde0c947a2e06fed4a0d2603a84cf7a842b0e5eca3af112da10215a17b1a6326589e3b3d8fed9d20
|
data/README.md
CHANGED
@@ -19,6 +19,10 @@ e pronto o script fará os downloads do capitulos selecionados.
|
|
19
19
|
|
20
20
|
> `gem update dmanga`
|
21
21
|
|
22
|
+
> E para remover a versão anterior:
|
23
|
+
|
24
|
+
> `gem clean`
|
25
|
+
|
22
26
|
## Instalação
|
23
27
|
|
24
28
|
### Windows
|
@@ -42,6 +46,10 @@ Você pode atualizar o script/programa com:
|
|
42
46
|
|
43
47
|
`gem update dmanga`
|
44
48
|
|
49
|
+
E para remover a versão anterior:
|
50
|
+
|
51
|
+
`gem clean`
|
52
|
+
|
45
53
|
Atualize sempre para obter melhoras (desempenho ou novas funcionalidades) e correções de bugs.
|
46
54
|
|
47
55
|
### Linux (debian/ubuntu)
|
@@ -59,7 +67,11 @@ Pode ser necessário usar o sudo.
|
|
59
67
|
|
60
68
|
Você pode atualizar o script/programa com:
|
61
69
|
|
62
|
-
|
70
|
+
`$ gem update dmanga`
|
71
|
+
|
72
|
+
E para remover a versão anterior:
|
73
|
+
|
74
|
+
`$ gem clean`
|
63
75
|
|
64
76
|
Atualize sempre para obter melhoras (desempenho ou novas funcionalidades) e correções de bugs.
|
65
77
|
|
@@ -83,7 +95,7 @@ Ex2:
|
|
83
95
|
|
84
96
|
Ex3:
|
85
97
|
<!---->
|
86
|
-

|
87
99
|
|
88
100
|
obs: A pasta padrão de destino dos downloads é a pasta Downloads mas
|
89
101
|
você pode dizer ao script a pasta de destino do downloads com a
|
@@ -135,7 +147,7 @@ uma das sequintes opções:
|
|
135
147
|
|
136
148
|
3. Para selecionar capitulos especificos:
|
137
149
|
|
138
|
-
`numeroDoCapitulo,numeroDoCapitulo,numeroDoCapitulo
|
150
|
+
`numeroDoCapitulo,numeroDoCapitulo,numeroDoCapitulo...`
|
139
151
|
|
140
152
|
Ex:
|
141
153
|
|
@@ -166,10 +178,9 @@ Mostra detalhes da execução do programa.
|
|
166
178
|
|
167
179
|
### Exemplos
|
168
180
|
|
169
|
-
`dmanga -d "C:\
|
181
|
+
`dmanga -d "C:\Users\usuario\images\manga e animes" "One piece"`
|
170
182
|
|
171
|
-
No windows, baixe 'One piece' para
|
172
|
-
'C:\window\users\images\manga e animes'
|
183
|
+
No windows, baixe 'One piece' para 'C:\Users\usuario\images\manga e animes'
|
173
184
|
|
174
185
|
`dmanga "One punch man"`
|
175
186
|
|
data/dmanga.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["David Endrew"]
|
10
10
|
spec.email = ["david.edews@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = "
|
13
|
-
spec.description = "
|
12
|
+
spec.summary = "Downloads any manga from mangahost.net"
|
13
|
+
spec.description = "Downloads any manga from mangahost.net. You can search and " +
|
14
14
|
"select any chapter or range of chapters"
|
15
15
|
spec.homepage = "https://github.com/david-endrew/DManga"
|
16
16
|
spec.license = "MIT"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# require 'dmanga/site_parser_base'
|
2
2
|
require 'dmanga/site_parser_base'
|
3
3
|
require 'dmanga/zip_file_generator'
|
4
|
-
|
4
|
+
require 'pry'
|
5
5
|
|
6
6
|
module DManga
|
7
7
|
class MangaHostParser < SiteParserBase
|
@@ -54,10 +54,10 @@ module DManga
|
|
54
54
|
# prompt user to select chapters to download
|
55
55
|
select_chapters
|
56
56
|
|
57
|
-
|
58
|
-
|
57
|
+
# remove simbols that cannot be used in folder's name on windows
|
58
|
+
remove_invalid_simbols(@manga_name)
|
59
59
|
# create manga directory
|
60
|
-
|
60
|
+
remove_invalid_simbols(@manga_name)
|
61
61
|
create_dir(@manga_name)
|
62
62
|
|
63
63
|
# download selected chapters
|
@@ -68,7 +68,8 @@ module DManga
|
|
68
68
|
# binding.pry # DEBUG
|
69
69
|
if resul.empty?
|
70
70
|
page.scan(IMG_LINK_REGEX[1]) do |img|
|
71
|
-
resul << img[0].gsub!(%r{\\}, "")
|
71
|
+
#resul << img[0].gsub!(%r{\\}, "")
|
72
|
+
resul << img[0]
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
@@ -80,14 +81,16 @@ module DManga
|
|
80
81
|
|
81
82
|
#correct créditos img problem
|
82
83
|
correct_image_uri(img)
|
84
|
+
|
85
|
+
img.gsub!(%r{\\}, "")
|
83
86
|
end
|
84
87
|
resul
|
85
88
|
end
|
86
89
|
|
87
90
|
# create chapter directory relative to manga directory
|
88
91
|
chapter_name = "#{chapter[0]}"
|
89
|
-
|
90
|
-
|
92
|
+
# remove simbols that cannot be used in folder's name on windows
|
93
|
+
remove_invalid_simbols chapter_name
|
91
94
|
chapter_dir = "#{@manga_name}/#{chapter_name}"
|
92
95
|
create_dir(chapter_dir)
|
93
96
|
|
@@ -99,17 +102,34 @@ module DManga
|
|
99
102
|
private
|
100
103
|
# Due to problems with open-uri and utf-8
|
101
104
|
# some chapters' name need to be corrected.
|
102
|
-
|
105
|
+
# substitute Cap$amptulo for capitulo.
|
103
106
|
def correct_chapters_name
|
104
107
|
@chapters.each {|chapter| chapter[0].sub!(/[cC]ap.*?tulo/, "capitulo")}
|
105
108
|
end
|
106
109
|
|
110
|
+
UNICODE_TABLE = {
|
111
|
+
"\\u00e1" => "\u00e1",
|
112
|
+
"\\u00e9" => "\u00e9",
|
113
|
+
"\\u00ed" => "\u00ed"
|
114
|
+
#'\\u00c1' => "\u00c1"
|
115
|
+
#'\\u00c1' => "\u00c1"
|
116
|
+
}
|
117
|
+
|
107
118
|
# Due to problems with open-uri and utf-8
|
108
119
|
# some images uris need to be corrected.
|
109
|
-
|
120
|
+
# substitute Cru00e9ditos for Créditos.
|
110
121
|
# one uri at a time
|
111
122
|
def correct_image_uri(img_uri)
|
112
|
-
img_uri
|
123
|
+
#if img_uri =~ /\\u..../i
|
124
|
+
result = img_uri.scan(/\\u..../i) #do |r|
|
125
|
+
#binding.pry
|
126
|
+
result.each do |r|
|
127
|
+
img_uri.sub!(r, UNICODE_TABLE[r.downcase])
|
128
|
+
end
|
129
|
+
#img_uri.gsub!($&, UNICODE_TABLE[$&.downcase])
|
130
|
+
#binding.pry
|
131
|
+
#exit
|
132
|
+
#end
|
113
133
|
#img_uri.sub!(/[cC]r.*?ditos/, "Créditos")
|
114
134
|
end
|
115
135
|
end
|
@@ -3,12 +3,12 @@ require 'dmanga/os'
|
|
3
3
|
require 'ruby-progressbar'
|
4
4
|
require 'open-uri'
|
5
5
|
require 'addressable/uri'
|
6
|
-
#
|
6
|
+
#require 'pry'
|
7
7
|
# require 'formatador'
|
8
8
|
|
9
9
|
module DManga
|
10
10
|
class SiteParserBase
|
11
|
-
USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:
|
11
|
+
USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0"
|
12
12
|
|
13
13
|
attr_accessor :manga_name, :manga_url,
|
14
14
|
:chapters, :verbose
|
@@ -139,11 +139,10 @@ module DManga
|
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
|
-
# download images to
|
142
|
+
# download images to path relative to Downloads directory
|
143
143
|
def imgs_download(chp_path, imgs_urls)
|
144
144
|
imgs_urls.each do |url|
|
145
|
-
original_filename = url.slice(/(?u)(\w|[_-])+\.(png|jpg)/)
|
146
|
-
#original_filename = url.slice(/(\w|[_-])+\.(png|jpg)/)
|
145
|
+
original_filename = url.slice(/(?u)(\w|[_-])+\.(png|jpg)/i)
|
147
146
|
|
148
147
|
img_path = [@options.download_dir,
|
149
148
|
chp_path,
|
@@ -153,7 +152,7 @@ module DManga
|
|
153
152
|
DManga::display_feedback "\n#{encoded_url}"
|
154
153
|
pbar = get_progressbar
|
155
154
|
open(
|
156
|
-
encoded_url,
|
155
|
+
encoded_url, "User-Agent" => USER_AGENT,
|
157
156
|
:progress_proc => lambda {|s| pbar.increment }
|
158
157
|
) do |response|
|
159
158
|
if response.status[1] == "OK"
|
@@ -161,6 +160,8 @@ module DManga
|
|
161
160
|
File.open(img_path, "wb") do |img|
|
162
161
|
img.puts response.read
|
163
162
|
end
|
163
|
+
else
|
164
|
+
puts "Error #{reponse.status}"
|
164
165
|
end
|
165
166
|
end
|
166
167
|
puts
|
@@ -172,7 +173,7 @@ module DManga
|
|
172
173
|
# create a directory relative to downlaod directory
|
173
174
|
def create_dir(relative_path)
|
174
175
|
absolute_path = [@options.download_dir, relative_path].join(File::SEPARATOR)
|
175
|
-
|
176
|
+
DManga::display_feedback "\nCriando diretorio '#{relative_path}' em '#{@options.download_dir}'" if @options.verbose
|
176
177
|
unless Dir.exist? absolute_path
|
177
178
|
Dir.mkdir(absolute_path)
|
178
179
|
puts if @options.verbose ## just a blank line for prettier output
|
data/lib/dmanga/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dmanga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Endrew
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-progressbar
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '1.14'
|
125
|
-
description:
|
125
|
+
description: Downloads any manga from mangahost.net. You can search and select any
|
126
126
|
chapter or range of chapters
|
127
127
|
email:
|
128
128
|
- david.edews@gmail.com
|
@@ -173,5 +173,5 @@ rubyforge_project:
|
|
173
173
|
rubygems_version: 2.6.11
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
|
-
summary:
|
176
|
+
summary: Downloads any manga from mangahost.net
|
177
177
|
test_files: []
|