panchira 1.3.1 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf1b6f4f73236bda86a93f4ae24c377a2ef4dc8dad1f721d87cc78b0659ca413
4
- data.tar.gz: 5e75576bc2bd8c8d4147f12537750646e88d464e81800d6847c9210b9bf66831
3
+ metadata.gz: 45b393a405624e26e8d6555c1833e0f65e5e93deef13518197ec4b15fc3bff61
4
+ data.tar.gz: b770975cbbba8d66cf6acde417ae9d32e78d310f145726ff16b60824a49f99e3
5
5
  SHA512:
6
- metadata.gz: 911a1e50dc8d0d443bb323f2e260a88bc3c353c9c3e6cca1dc7d1f592b50c51d0ac92a8ce2a5bd0619f04a5a8cfc3db4d441e739908be861e522d8b555d36128
7
- data.tar.gz: ce917b7a4a905dc6364a39764262b9f4777e074c57f7962439cc8a3b1181feb2f995b1f756eaae431185e5a4a58d82c219a028582038fd1c0bcb771294b137a9
6
+ metadata.gz: 9c4ca217b6bd3fa782fa92d36ed1a1974880e2ff1746319cbd4f3e652d947807f74490b937a7f84cd4b1c8c46b0a95bd91a8374c28d575aa224c3c9ce6817385
7
+ data.tar.gz: b050fcb7586b81209e0d2f0ac521ab34c4db0ad05362655b3b25ae16c2d226a31b57da50019a195bb092080cfddf5eb1bdf44c80757f3943b1075860182b3add
@@ -16,7 +16,7 @@ on:
16
16
  jobs:
17
17
  test:
18
18
 
19
- runs-on: ubuntu-latest
19
+ runs-on: ubuntu-18.04
20
20
 
21
21
  steps:
22
22
  - uses: actions/checkout@v2
data/CHANGELOG.md CHANGED
@@ -4,6 +4,32 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## 1.3.5 - 2021-09-01
8
+ ### Added
9
+ - Added support for Pixiv Novel.
10
+
11
+ ### Fixed
12
+ - Fixed an issue where Image Resolver missed image scales.
13
+
14
+ ## 1.3.4 - 2021-07-26
15
+ ### Fixed
16
+ - Fixed an issue where Iwara Resolver failed when a description was present.
17
+
18
+ ## 1.3.3 - 2021-07-25
19
+ ### Added
20
+ - Added support for Iwara.
21
+
22
+ ### Fixed
23
+ - Fixed an issue where DLsite Resolver was retrieving wrong tags.
24
+
25
+ ## 1.3.2 - 2021-05-23
26
+ ### Fixed
27
+ - Fixed an issue where Fanza Resolver was retrieving incorrect canonical URLs.
28
+ - Fixed an issue where Narou Resolver was retrieving wrong descriptions.
29
+
30
+ ### Changed
31
+ - Updated dependencies.
32
+
7
33
  ## 1.3.1 - 2021-02-17
8
34
  ### Added
9
35
  - Added support for Fanza Video.
@@ -71,6 +97,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
71
97
  ### Added
72
98
  - Released Panchira gem. At this time we can parse only 5 websites.
73
99
 
100
+ [1.3.5]: https://github.com/nuita/panchira/releases/tag/v1.3.5
101
+ [1.3.4]: https://github.com/nuita/panchira/releases/tag/v1.3.4
102
+ [1.3.3]: https://github.com/nuita/panchira/releases/tag/v1.3.3
103
+ [1.3.2]: https://github.com/nuita/panchira/releases/tag/v1.3.2
74
104
  [1.3.1]: https://github.com/nuita/panchira/releases/tag/v1.3.1
75
105
  [1.3.0]: https://github.com/nuita/panchira/releases/tag/v1.3.0
76
106
  [1.2.0]: https://github.com/nuita/panchira/releases/tag/v1.2.0
data/Gemfile.lock CHANGED
@@ -1,41 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- panchira (1.3.1)
4
+ panchira (1.3.5)
5
5
  fastimage (~> 2.1.7)
6
6
  nokogiri (>= 1.10.9, < 1.12.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- ast (2.4.1)
11
+ ast (2.4.2)
12
12
  fastimage (2.1.7)
13
- minitest (5.14.2)
14
- nokogiri (1.11.1-x86_64-darwin)
13
+ minitest (5.14.4)
14
+ nokogiri (1.11.7-x86_64-darwin)
15
15
  racc (~> 1.4)
16
16
  parallel (1.20.1)
17
- parser (3.0.0.0)
17
+ parser (3.0.1.1)
18
18
  ast (~> 2.4.1)
19
19
  racc (1.5.2)
20
20
  rainbow (3.0.0)
21
21
  rake (12.3.3)
22
- regexp_parser (2.0.3)
23
- rexml (3.2.4)
24
- rubocop (1.7.0)
22
+ regexp_parser (2.1.1)
23
+ rexml (3.2.5)
24
+ rubocop (1.15.0)
25
25
  parallel (~> 1.10)
26
- parser (>= 2.7.1.5)
26
+ parser (>= 3.0.0.0)
27
27
  rainbow (>= 2.2.2, < 4.0)
28
28
  regexp_parser (>= 1.8, < 3.0)
29
29
  rexml
30
- rubocop-ast (>= 1.2.0, < 2.0)
30
+ rubocop-ast (>= 1.5.0, < 2.0)
31
31
  ruby-progressbar (~> 1.7)
32
- unicode-display_width (>= 1.4.0, < 2.0)
33
- rubocop-ast (1.4.0)
34
- parser (>= 2.7.1.5)
35
- rubocop-minitest (0.10.2)
36
- rubocop (>= 0.87, < 2.0)
32
+ unicode-display_width (>= 1.4.0, < 3.0)
33
+ rubocop-ast (1.5.0)
34
+ parser (>= 3.0.1.1)
35
+ rubocop-minitest (0.12.1)
36
+ rubocop (>= 0.90, < 2.0)
37
37
  ruby-progressbar (1.11.0)
38
- unicode-display_width (1.7.0)
38
+ unicode-display_width (2.0.0)
39
39
 
40
40
  PLATFORMS
41
41
  ruby
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Due to some legal or ethical issues, most hentai and NSFW platforms don't clarify their content on meta tags. As a result, most hentai platforms are rendered poorly on the card previews on social media.
8
8
 
9
- To solve this issue, Panchira is made to parse correct and uncensored metadata from such web platforms (at this time we cover **DLSite, Komiflo, Melonbooks, Nijie, Pixiv, Shousetsuka ni narou, Fanza and Twitter**).
9
+ To solve this issue, Panchira is made to parse correct and uncensored metadata from such web platforms (at this time we cover **DLSite, Komiflo, Melonbooks, Nijie, Pixiv, Shousetsuka ni narou, Fanza, Iwara and Twitter**).
10
10
 
11
11
  If you need card previews of hentai on your web application, but can't get them with simply parsing metatags, then it is time for Panchira.
12
12
 
@@ -39,7 +39,13 @@ module Panchira
39
39
  end
40
40
 
41
41
  def parse_tags
42
- @page.css('.main_genre').children.children.map(&:text)
42
+ @page.css('table[id*="work_"] tr').each do |tr|
43
+ next unless tr.css('th').text =~ /ジャンル/
44
+
45
+ return tr.css('td a').map do |node|
46
+ node.text.strip
47
+ end
48
+ end
43
49
  end
44
50
  end
45
51
 
@@ -41,6 +41,12 @@ module Panchira
41
41
 
42
42
  private
43
43
 
44
+ # canonical urlに別サービス(FANZA GAMES)のURLが設定されていることがあるため、
45
+ # 別サービスの場合はとりあえず元URLを設定する
46
+ def parse_canonical_url
47
+ @url
48
+ end
49
+
44
50
  def parse_circle
45
51
  @page.css('a.circleName__txt').first.text
46
52
  end
@@ -9,6 +9,8 @@ module Panchira
9
9
  result.canonical_url = @url
10
10
  result.image = PanchiraImage.new
11
11
  result.image.url = @url
12
+ result.image.width, result.image.height = FastImage.size(result.image.url)
13
+
12
14
  result.resolver = parse_resolver
13
15
  result
14
16
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Panchira
4
+ class IwaraResolver < Resolver
5
+ URL_REGEXP = /(www|ecchi)\.iwara\.tv\//.freeze
6
+
7
+ private
8
+ def parse_title
9
+ super.split(' | ')[0]
10
+ end
11
+
12
+ def parse_image_url
13
+ url = @page.at_css('#video-player')&.attributes['poster']&.value
14
+ 'https:' + url if url
15
+ end
16
+
17
+ def parse_author
18
+ @page.at_css('.node-info .username')&.children&.[](0)&.text
19
+ end
20
+
21
+ def parse_tags
22
+ @page.css('.field-name-field-categories .field-item').map { |e| e.children&.text }
23
+ end
24
+
25
+ def parse_description
26
+ @page.at_css('.field-name-body')&.text
27
+ end
28
+
29
+ def cookie
30
+ 'show_adult=1'
31
+ end
32
+
33
+ def parse_canonical_url
34
+ @url # canonical has relative path. ignore it
35
+ end
36
+ end
37
+
38
+ ::Panchira::Extensions.register(Panchira::IwaraResolver)
39
+ end
@@ -25,6 +25,10 @@ module Panchira
25
25
  Nokogiri::HTML.parse(res.body, uri)
26
26
  end
27
27
 
28
+ def parse_description
29
+ @desc&.xpath('//*[@id="noveltable1"]/tr/td')&.first&.text&.strip
30
+ end
31
+
28
32
  def parse_author
29
33
  @desc&.xpath('//*[@id="noveltable1"]/tr[2]/td')&.text&.strip
30
34
  end
@@ -33,6 +37,11 @@ module Panchira
33
37
  # つらい。
34
38
  @desc&.xpath('//*[@id="noveltable1"]/tr[3]')&.text&.split("\n\n\n")&.dig(1)&.split(' ')
35
39
  end
40
+
41
+ # og:urlで指定されたncode.syosetu.com/~~~にアクセスすると301で戻されるので何もしない
42
+ def parse_canonical_url
43
+ @url
44
+ end
36
45
  end
37
46
 
38
47
  class NcodeResolver < Resolver
@@ -47,6 +56,10 @@ module Panchira
47
56
  end
48
57
  end
49
58
 
59
+ def parse_description
60
+ @desc&.xpath('//*[@id="noveltable1"]/tr/td')&.first&.text&.strip
61
+ end
62
+
50
63
  def parse_author
51
64
  @desc&.xpath('//*[@id="noveltable1"]/tr[2]/td')&.text&.strip
52
65
  end
@@ -55,6 +68,11 @@ module Panchira
55
68
  # めっちゃつらい。
56
69
  @desc&.xpath('//*[@id="noveltable1"]/tr[3]')&.text&.split("\n\n\n")&.dig(1)&.delete("\u00A0")&.split(' ')&.grep_v('')
57
70
  end
71
+
72
+ # og:urlで指定されたncode.syosetu.com/~~~にアクセスすると301で戻されるので何もしない
73
+ def parse_canonical_url
74
+ @url
75
+ end
58
76
  end
59
77
  end
60
78
 
@@ -44,5 +44,32 @@ module Panchira
44
44
  end
45
45
  end
46
46
 
47
+ class PixivNovelResolver < Resolver
48
+ URL_REGEXP = %r{pixiv\.net/novel/show.php\?id=(\d+)}.freeze
49
+
50
+ def initialize(url)
51
+ super(url)
52
+ @novel_id = url.slice(URL_REGEXP, 1)
53
+
54
+ raw_json = URI.parse("https://www.pixiv.net/ajax/novel/#{@novel_id}").read('User-Agent' => user_agent)
55
+ @json = JSON.parse(raw_json)
56
+ end
57
+
58
+ private
59
+
60
+ def parse_title
61
+ @json['body']['title']
62
+ end
63
+
64
+ def parse_author
65
+ @json['body']['userName']
66
+ end
67
+
68
+ def parse_tags
69
+ @json['body']['tags']['tags'].map { |content| content['tag'] }
70
+ end
71
+ end
72
+
47
73
  ::Panchira::Extensions.register(Panchira::PixivResolver)
74
+ ::Panchira::Extensions.register(Panchira::PixivNovelResolver)
48
75
  end
@@ -67,17 +67,20 @@ module Panchira
67
67
  # fetch page and refresh canonical_url until canonical_url converges.
68
68
  loop do
69
69
  url_in_res = @page.css('//link[rel="canonical"]/@href').to_s
70
+ if url_in_res.empty?
71
+ url_in_res = @page.css('//meta[property="og:url"]/@content').to_s
72
+ end
70
73
 
71
74
  if url_in_res.empty?
72
75
  return history.last || @url
73
- else
74
- if history.include?(url_in_res) || history.length > 5
75
- return url_in_res
76
- else
77
- history.push(url_in_res)
78
- @page = fetch_page(url_in_res)
79
- end
80
76
  end
77
+
78
+ if history.include?(url_in_res) || history.length > 5
79
+ return url_in_res
80
+ end
81
+
82
+ history.push(url_in_res)
83
+ @page = fetch_page(url_in_res)
81
84
  end
82
85
  end
83
86
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Panchira
4
- VERSION = '1.3.1'
4
+ VERSION = '1.3.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panchira
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-17 00:00:00.000000000 Z
11
+ date: 2021-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -141,6 +141,7 @@ files:
141
141
  - lib/panchira/resolvers/dlsite_resolver.rb
142
142
  - lib/panchira/resolvers/fanza_resolver.rb
143
143
  - lib/panchira/resolvers/image_resolver.rb
144
+ - lib/panchira/resolvers/iwara_resolver.rb
144
145
  - lib/panchira/resolvers/komiflo_resolver.rb
145
146
  - lib/panchira/resolvers/melonbooks_resolver.rb
146
147
  - lib/panchira/resolvers/narou_resolver.rb