dmanga 0.1.0 → 0.1.1
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 +3 -3
- data/dmanga.gemspec +1 -0
- data/exe/dmanga +1 -1
- data/lib/dmanga.rb +1 -0
- data/lib/dmanga/mangahost_parser.rb +9 -1
- data/lib/dmanga/site_parser_base.rb +10 -0
- data/lib/dmanga/version.rb +1 -1
- data/lib/dmanga/zip_file_generator.rb +49 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24588c8799ce6c0eb55a6f88c275c7465b7715b7
|
4
|
+
data.tar.gz: a7f2fc77d3078dbcd223be75f53ef7c5b9c48216
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ec8775d1cec6eb892ad8ff19bc9c531df025a9738f54c53459713dfb4de1b37521915db1db53120836c6d78dc6811914b93a952f84c422e85ba61f6192f22df
|
7
|
+
data.tar.gz: 7a7a383da35a56f9048a22c673332cbb45b1b5e309d0bea4837f46c48be09c8bf364a760c951b17e46c01273c65478876a5732d909fcba250962343254bbcdde
|
data/README.md
CHANGED
@@ -57,7 +57,7 @@ ruby 2.4.1 ou superior.
|
|
57
57
|
|
58
58
|
## Uso
|
59
59
|
|
60
|
-
`dmanga [
|
60
|
+
`dmanga [opções] <nome do manga>`
|
61
61
|
|
62
62
|
obs: o script/programa é executado no prompt.
|
63
63
|
|
@@ -138,7 +138,7 @@ Mostra o numero da versao do programa e sai.
|
|
138
138
|
|
139
139
|
`-d <pasta de download>, --directory <pasta de download>`
|
140
140
|
|
141
|
-
|
141
|
+
Define a pasta de destino do downlaod.
|
142
142
|
|
143
143
|
`-h , --help`
|
144
144
|
|
@@ -150,7 +150,7 @@ Mostra detalhes da execução do programa.
|
|
150
150
|
|
151
151
|
### Exemplos
|
152
152
|
|
153
|
-
`dmanga -d "
|
153
|
+
`dmanga -d "C:\window\users\images\manga e animes" "One piece"`
|
154
154
|
|
155
155
|
No windows, baixe 'One piece' para
|
156
156
|
'c:\window\users\images\manga e animes'
|
data/dmanga.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
34
|
spec.add_runtime_dependency "ruby-progressbar","~> 1.8"
|
35
|
+
spec.add_runtime_dependency "rubyzip","~> 1.2"
|
35
36
|
spec.add_runtime_dependency "formatador", "~> 0.2"
|
36
37
|
spec.add_development_dependency "minitest","~> 5.10"
|
37
38
|
spec.add_development_dependency "webmock", "~> 3.0"
|
data/exe/dmanga
CHANGED
@@ -10,7 +10,7 @@ begin
|
|
10
10
|
|
11
11
|
mangahost = DManga::MangaHostParser.new(ARGV)
|
12
12
|
mangahost.download
|
13
|
-
DManga::
|
13
|
+
DManga::display_feedback "\nTodos os download concluidos"
|
14
14
|
|
15
15
|
rescue URI::InvalidURIError => uri_error
|
16
16
|
DManga::display_error("Nome do manga não deve conter acentos, cecedilha ou simbolos",
|
data/lib/dmanga.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# require 'dmanga/site_parser_base'
|
2
2
|
require 'dmanga/site_parser_base'
|
3
|
+
require 'dmanga/zip_file_generator'
|
4
|
+
|
3
5
|
module DManga
|
4
6
|
class MangaHostParser < SiteParserBase
|
5
7
|
|
@@ -51,7 +53,10 @@ module DManga
|
|
51
53
|
# prompt user to select chapters to download
|
52
54
|
select_chapters
|
53
55
|
|
56
|
+
# remove simbols that cannot be used in folder's name on windows
|
57
|
+
remove_invalid_simbols(@manga_name)
|
54
58
|
# create manga directory
|
59
|
+
remove_invalid_simbols(@manga_name)
|
55
60
|
create_dir(@manga_name)
|
56
61
|
|
57
62
|
# download selected chapters
|
@@ -77,6 +82,8 @@ module DManga
|
|
77
82
|
|
78
83
|
# create chapter directory relative to manga directory
|
79
84
|
chapter_name = "#{chapter[0]}"
|
85
|
+
# remove simbols that cannot be used in folder's name on windows
|
86
|
+
remove_invalid_simbols chapter_name
|
80
87
|
chapter_dir = "#{@manga_name}/#{chapter_name}"
|
81
88
|
create_dir(chapter_dir)
|
82
89
|
|
@@ -87,7 +94,8 @@ module DManga
|
|
87
94
|
|
88
95
|
private
|
89
96
|
# Due to problems with open-uri and utf-8
|
90
|
-
# some chapters name need to be corrected
|
97
|
+
# some chapters' name need to be corrected.
|
98
|
+
# substitute Cap$amptulo for capitulo.
|
91
99
|
def correct_chapters_name
|
92
100
|
@chapters.each {|chapter| chapter[0].sub!(/[cC]ap.*?tulo/, "capitulo")}
|
93
101
|
end
|
@@ -186,8 +186,18 @@ module DManga
|
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
189
|
+
def zip_chapter
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
# return the distiny download directory
|
189
194
|
def download_dir
|
190
195
|
@options.download_dir
|
191
196
|
end
|
197
|
+
|
198
|
+
def remove_invalid_simbols(name)
|
199
|
+
# windows OS dont accep these simbols in folder name
|
200
|
+
name.gsub!(/[\/\\:*?"<>|]/, '_')
|
201
|
+
end
|
192
202
|
end
|
193
203
|
end
|
data/lib/dmanga/version.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'zip'
|
2
|
+
# This is a simple example which uses rubyzip to
|
3
|
+
# recursively generate a zip file from the contents of
|
4
|
+
# a specified directory. The directory itself is not
|
5
|
+
# included in the archive, rather just its contents.
|
6
|
+
#
|
7
|
+
# Usage:
|
8
|
+
# directory_to_zip = "/tmp/input"
|
9
|
+
# output_file = "/tmp/out.zip"
|
10
|
+
# zf = ZipFileGenerator.new(directory_to_zip, output_file)
|
11
|
+
# zf.write()
|
12
|
+
|
13
|
+
module DManga
|
14
|
+
|
15
|
+
class ZipFileGenerator
|
16
|
+
def initialize(input_dir, output_file)
|
17
|
+
@input_dir = input_dir
|
18
|
+
@output_file = output_file
|
19
|
+
end
|
20
|
+
|
21
|
+
# zip the input directory
|
22
|
+
def write
|
23
|
+
entries = Dir.entries(@input_dir) - %w(. ..)
|
24
|
+
|
25
|
+
::Zip::File.open(@output_file, ::Zip::File::CREATE) do |io|
|
26
|
+
write_entries entries, '', io
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# a helper method to make the recursion work:
|
33
|
+
def write_entries(entries, path, io)
|
34
|
+
entries.each do |e|
|
35
|
+
zip_file_path = path == '' ? e : File.join(path, e)
|
36
|
+
disk_file_path = File.join(@input_dir, zip_file_path)
|
37
|
+
puts "Deflating #{disk_file_path}"
|
38
|
+
|
39
|
+
put_into_archive(disk_file_path, io, zip_file_path)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def put_into_archive(disk_file_path, io, zip_file_path)
|
44
|
+
io.get_output_stream(zip_file_path) do |f|
|
45
|
+
f.write(File.open(disk_file_path, 'rb').read)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
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.1
|
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-05-
|
11
|
+
date: 2017-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-progressbar
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubyzip
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: formatador
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,6 +135,7 @@ files:
|
|
121
135
|
- lib/dmanga/site_parser_base.rb
|
122
136
|
- lib/dmanga/util.rb
|
123
137
|
- lib/dmanga/version.rb
|
138
|
+
- lib/dmanga/zip_file_generator.rb
|
124
139
|
homepage: https://github.com/david-endrew/DManga
|
125
140
|
licenses:
|
126
141
|
- MIT
|