webtoon_source 0.6.0 → 0.7.0

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
  SHA256:
3
- metadata.gz: 07b90095a4ff0d2080dc569a2ee23258f94b09b39bbe7b3a3f44b7f2df369b66
4
- data.tar.gz: fed20be0a93c2c2468c65e5795267a896bd43e5989d9b68fe16e055b0288456d
3
+ metadata.gz: dfd2d015ec9990f46654bbf770096f0a9271869b04360b4c3834a4ec97858109
4
+ data.tar.gz: 29b6a510e90b685869b3f7f89ef853b1e709c675e8b419d573f9f33174f46815
5
5
  SHA512:
6
- metadata.gz: e1c6da5483a82ef197b7c3aa0c1f20dfa950a2757dda2ceae9cf2a65d716684b96e63d899e74bfdba8121e250327223df710e9400d5b72f047d2a5684c9e9268
7
- data.tar.gz: b79911952acd161ef9a0b4fb3a66fdd4f6efcfd5c4a7f7b17fa848a9555adf9f129851f1a4084922d20cd2abcb88734789906a67dcb34ef05f8ab6c027068efe
6
+ metadata.gz: e7fbf9d67172bcef0ecc38c6ed0e9375ebe12e2e7f7f07f75e955a0a3f51aad44de09b97eaeddce29dda7e5228705b871f1ee7c91c76940708285d718dc07b51
7
+ data.tar.gz: 2fe4b283b07f33b0a43c640b807045fabdfa0388bf2e3e4ae9f454d9f1f56c7d3e2bd11bba43e268472c9e539b0bd338af0a557b6ece3702d705104fac686ce1
@@ -32,9 +32,9 @@ class WebtoonSource::AsuraScans
32
32
  end
33
33
 
34
34
  def download(params) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
35
- panels, chapter, name = params.values_at(:panels, :chapter, :name)
35
+ panels, chapter, directory = params.values_at(:panels, :chapter, :directory)
36
36
 
37
- chapter_storage_path = File.join(@storage_path, name, chapter.to_s)
37
+ chapter_storage_path = File.join(@storage_path, directory, chapter.to_s)
38
38
 
39
39
  FileUtils.mkdir_p(chapter_storage_path) unless Dir.exist?(chapter_storage_path)
40
40
 
@@ -61,13 +61,25 @@ class WebtoonSource::AsuraScans
61
61
  slug.match(SERIES_NAME_PATTERN).to_a.last
62
62
  end
63
63
 
64
- def panels(params)
65
- slug, chapter = params.values_at(:slug, :chapter)
66
- chapter_slug = File.join("series", slug, "chapter", chapter.to_s)
67
-
64
+ def panels(chapter_slug)
68
65
  response = @conn.get(chapter_slug)
69
66
 
70
67
  panels = response.body.scan(PANEL_PATTERN).uniq
71
68
  panels.sort { |a, b| a[PANEL_ORDER].to_i <=> b[PANEL_ORDER].to_i }
72
69
  end
70
+
71
+ def chapters(slug)
72
+ response = @conn.get("series/#{slug}")
73
+ chapter_pattern = %r{\\"href\\":\\"#{slug}/chapter/([^"]+)\\"}
74
+
75
+ chapters = response.body.scan(chapter_pattern).flatten.uniq
76
+
77
+ sorted = chapters.sort { |a, b| a.to_i <=> b.to_i }
78
+
79
+ sorted.map do |chapter|
80
+ chapter_slug = "series/#{slug}/chapter/#{chapter}"
81
+
82
+ { chapter_number: chapter, chapter_slug: }
83
+ end
84
+ end
73
85
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class WebtoonSource
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
@@ -55,8 +55,12 @@ class WebtoonSource
55
55
  @source.download(params)
56
56
  end
57
57
 
58
- def panels(params)
59
- @source.panels(params)
58
+ def panels(chapter_slug)
59
+ @source.panels(chapter_slug)
60
+ end
61
+
62
+ def chapters(slug)
63
+ @source.chapters(slug)
60
64
  end
61
65
 
62
66
  def metadata(mal_id)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webtoon_source
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Kenneth Sinay