webtoon_source 0.7.0 → 0.9.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 +4 -4
- data/.ruby-version +1 -0
- data/lib/webtoon_source/asura_scans.rb +31 -10
- data/lib/webtoon_source/version.rb +1 -1
- data/lib/webtoon_source.rb +5 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 494e1c0f0c1310a98d9650cd127796b2032cdc3ff5816c0e63bf1d6118f7edce
|
|
4
|
+
data.tar.gz: b4904c1caf832e60b31f80ee054aee0c1ebe0712bf96d990e27e2cb77a0bbad8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 25430f93d58dc18a2a4324cd911d98dbbcdcc0d0de86fe9ab8d993c4a81d2e7bf1ba3ae8bc37d6bd26143588a27e7f13deb094dfbe026e03141cc484f4d83f2b
|
|
7
|
+
data.tar.gz: 60bd6991d986bb62d4e0f09a5ca4d002c3b28afa23b7c75ed4a0c6f5a686035d08156423a2421ca3527cf8ed933d73e0ae2dc9aff105a65b7ba29c769834cf70
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.4.9
|
|
@@ -6,17 +6,19 @@ class WebtoonSource::AsuraScans
|
|
|
6
6
|
SERIES_NAME_PATTERN = /(.+)-/
|
|
7
7
|
PANEL_PATTERN = %r{{\\"order\\":(\d+),\\"url\\":\\"(https://gg.asuracomic.net/storage/media/\d+/conversions/[^"]+)\\"}}
|
|
8
8
|
|
|
9
|
-
PANEL_ORDER =
|
|
10
|
-
PANEL_LINK =
|
|
9
|
+
PANEL_ORDER = 1
|
|
10
|
+
PANEL_LINK = 0
|
|
11
11
|
|
|
12
12
|
def initialize(domain)
|
|
13
|
-
@conn = Faraday.new(domain)
|
|
13
|
+
@conn = Faraday.new(domain) do |config|
|
|
14
|
+
config.headers["User-Agent"] = "WebtoonSource/#{WebtoonSource::VERSION}"
|
|
15
|
+
end
|
|
14
16
|
|
|
15
17
|
yield(self) if block_given?
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
def latest_updates(params = { page: 1 })
|
|
19
|
-
response = @conn.get("/
|
|
21
|
+
response = @conn.get("/comics", params)
|
|
20
22
|
# Capture group 1 - series slug
|
|
21
23
|
# Capture group 2 - anchor tag inner content.
|
|
22
24
|
series_pattern = %r{<a\s+href="series/([^"]+)"[^>]*>(.*?)</a>}
|
|
@@ -43,7 +45,7 @@ class WebtoonSource::AsuraScans
|
|
|
43
45
|
|
|
44
46
|
media_conn = Faraday.new(panel_domain)
|
|
45
47
|
|
|
46
|
-
panels.each do |
|
|
48
|
+
panels.each do |link, order|
|
|
47
49
|
panel_path = URI(link).path
|
|
48
50
|
panel_name = "#{order.rjust(2, "0")}.webp"
|
|
49
51
|
|
|
@@ -63,23 +65,42 @@ class WebtoonSource::AsuraScans
|
|
|
63
65
|
|
|
64
66
|
def panels(chapter_slug)
|
|
65
67
|
response = @conn.get(chapter_slug)
|
|
68
|
+
chapter_number = chapter_slug.match(%r{chapter/(.+)}).to_a.last
|
|
69
|
+
|
|
70
|
+
panel_pattern = %r{(https://cdn.asurascans.com/asura-images/chapters/.+?/#{chapter_number}/(\d+)\.webp)}
|
|
66
71
|
|
|
67
|
-
panels = response.body.scan(
|
|
72
|
+
panels = response.body.scan(panel_pattern).uniq
|
|
68
73
|
panels.sort { |a, b| a[PANEL_ORDER].to_i <=> b[PANEL_ORDER].to_i }
|
|
69
74
|
end
|
|
70
75
|
|
|
71
76
|
def chapters(slug)
|
|
72
|
-
response = @conn.get("
|
|
73
|
-
chapter_pattern = %r{
|
|
77
|
+
response = @conn.get("comics/#{slug}")
|
|
78
|
+
chapter_pattern = %r{<a\shref="/comics/#{slug}/chapter/([^"]+)}
|
|
74
79
|
|
|
75
80
|
chapters = response.body.scan(chapter_pattern).flatten.uniq
|
|
76
81
|
|
|
77
82
|
sorted = chapters.sort { |a, b| a.to_i <=> b.to_i }
|
|
78
83
|
|
|
79
84
|
sorted.map do |chapter|
|
|
80
|
-
chapter_slug = "
|
|
85
|
+
chapter_slug = "comics/#{slug}/chapter/#{chapter}"
|
|
81
86
|
|
|
82
|
-
{ chapter_number: chapter
|
|
87
|
+
{ chapter_slug:, chapter_number: chapter }
|
|
83
88
|
end
|
|
84
89
|
end
|
|
90
|
+
|
|
91
|
+
def search(params)
|
|
92
|
+
title, comic_type = params.values_at(:title, :comic_type)
|
|
93
|
+
|
|
94
|
+
search_params = {
|
|
95
|
+
q: title,
|
|
96
|
+
type: comic_type
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
response = @conn.get("browse", search_params)
|
|
100
|
+
|
|
101
|
+
slug_pattern = %r{<a\s+href="/comics/([^"]+)"}
|
|
102
|
+
slugs = response.body.scan(slug_pattern).flatten.uniq
|
|
103
|
+
|
|
104
|
+
slugs.first
|
|
105
|
+
end
|
|
85
106
|
end
|
data/lib/webtoon_source.rb
CHANGED
|
@@ -14,7 +14,7 @@ class WebtoonSource
|
|
|
14
14
|
DEFAULT_STORAGE_PATH = File.join(Dir.home, "webtoon_source")
|
|
15
15
|
|
|
16
16
|
DOMAINS = {
|
|
17
|
-
asura_scans: "https://
|
|
17
|
+
asura_scans: "https://asurascans.com",
|
|
18
18
|
manhuaus: "https://manhuaus.com/"
|
|
19
19
|
}.freeze
|
|
20
20
|
|
|
@@ -71,6 +71,10 @@ class WebtoonSource
|
|
|
71
71
|
jikan_service.search(params)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
+
def search_source(params)
|
|
75
|
+
@source.search(params)
|
|
76
|
+
end
|
|
77
|
+
|
|
74
78
|
private
|
|
75
79
|
|
|
76
80
|
def domain_callback(new_domain)
|
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.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Kenneth Sinay
|
|
@@ -35,6 +35,7 @@ executables: []
|
|
|
35
35
|
extensions: []
|
|
36
36
|
extra_rdoc_files: []
|
|
37
37
|
files:
|
|
38
|
+
- ".ruby-version"
|
|
38
39
|
- CHANGELOG.md
|
|
39
40
|
- CODE_OF_CONDUCT.md
|
|
40
41
|
- LICENSE.txt
|
|
@@ -62,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
62
63
|
- !ruby/object:Gem::Version
|
|
63
64
|
version: '0'
|
|
64
65
|
requirements: []
|
|
65
|
-
rubygems_version:
|
|
66
|
+
rubygems_version: 3.6.9
|
|
66
67
|
specification_version: 4
|
|
67
68
|
summary: A gem to source your manhwas from webtoon platforms.
|
|
68
69
|
test_files: []
|