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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89a02baa638bb1e68dfd240f1159a6e04b1b935f
4
- data.tar.gz: 033d848cf382353bcf2908be17a432be9ac12863
3
+ metadata.gz: 2920708055ee2ee6e8bbab751c8b9d8bac78b9eb
4
+ data.tar.gz: ee8cd018624cd2ce7b693d7fc4a2f60531ba676a
5
5
  SHA512:
6
- metadata.gz: dbf3d772a0f1baac1e2ed2e9e6decea33e6c4b7133e3d6da5faa3d1676a8e68e4d4f7381551d9edf7b53a18f0df43ec41804b549074885fe41d2742626273110
7
- data.tar.gz: 3013f80239e7a61973ec510e4cb7532823d958e2f61c396d07a38898004eb7e3b16524899bca915b0ab08a1f004e3209e5f5d555d9f71be0109de21a0e7c7c69
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
- `gem update dmanga`
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
  <!--![exemplo de uso](https://github.com/david-endrew/somethings/blob/master/uso_exemplo.gif)-->
86
- ![exemplo de uso](https://github.com/david-endrew/somethings/blob/master/uso_exemplo.gif)
98
+ ![exemplo de uso](https://github.com/dkeas/somethings/blob/master/uso_exemplo.gif)
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:\window\users\images\manga e animes" "One piece"`
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
 
@@ -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 = "Download any manga from mangahost.net"
13
- spec.description = "Download any manga from mangahost.net. You can search and " +
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
- #require 'pry'
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
- # remove simbols that cannot be used in folder's name on windows
58
- remove_invalid_simbols(@manga_name)
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
- remove_invalid_simbols(@manga_name)
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
- # remove simbols that cannot be used in folder's name on windows
90
- remove_invalid_simbols chapter_name
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
- # substitute Cap$amptulo for capitulo.
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
- # substitute Cru00e9ditos for Créditos.
120
+ # substitute Cru00e9ditos for Créditos.
110
121
  # one uri at a time
111
122
  def correct_image_uri(img_uri)
112
- img_uri.sub!(/[cC]r.{2,10}ditos/, "Créditos")
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
- # require 'pry'
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:45.0) Gecko/20100101 Firefox/45.0"
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 a path relative to download directory
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
- DManga::display_feedback "\nCriando diretorio '#{relative_path}' em '#{@options.download_dir}'" if @options.verbose
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
@@ -1,3 +1,3 @@
1
1
  module DManga
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  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.3
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-05-31 00:00:00.000000000 Z
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: Download any manga from mangahost.net. You can search and select any
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: Download any manga from mangahost.net
176
+ summary: Downloads any manga from mangahost.net
177
177
  test_files: []