panchira 1.0.0 → 1.1.0

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: b5625692d52a2fa265db20d62c9311f877a27b4a8d099446bae7dda346b9fcb5
4
- data.tar.gz: 0be90bf0354d5f87ca15e213722c7c44b4c522ec9ad048a611c8f0d307e8fb84
3
+ metadata.gz: 1809ad9bff82b513e43a58b5270cf67232ccec9bb440b549b0faacfa24d1c9b5
4
+ data.tar.gz: 7948df0b4ef085a2f37c6ae7c30801da7bc6f5a997dff74e108d51e4c5f4204e
5
5
  SHA512:
6
- metadata.gz: 98c86bab322717af51f335a5c252dd465c3ec06fdb4bd54e3d3c166153e9571d3b6a94625ab708c286cf18ef8846114cc74cc6ec27f66e376bddbd4fbfcb8aae
7
- data.tar.gz: 1efabc99a91e770e47a06ddb527cf72ac361f165a0e5f5a4fcfc4ab17eae99436a55bdb70f721da0826117e6febd10062736b47c02442ae8870a6604070bf2e2
6
+ metadata.gz: 0cac7d53c293e5426db620e2fe7eb358b00e4bd7a5e1d0d05a743933f90056c1416391139b193a967a1a675c3bf6863ae691a99f893d4956cd49fd5d0316773b
7
+ data.tar.gz: 013ea3d18b91410392a8d1727197746ad6b210dac2898c44f68e81f67b5361ebf034bb5f24f594cd78177b00f862478dc4ebdba7022875a60351f32fc3b5826c
@@ -4,6 +4,22 @@ 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.1.0 - 2020-08-06
8
+ ### Added
9
+ - Added support for Fanza Books.
10
+ - Added support for direct links to an image.
11
+ - You can now set cookie by overriding Resolver#cookie in individual resolvers.
12
+
13
+ ### Changed
14
+ - Resolver::USER_AGENT changed to Resolver#user_agent.
15
+
16
+ ## 1.0.0 - 2020-06-23
17
+ ### Added
18
+ - Added support for tags.
19
+
20
+ ### Fixed
21
+ - Fixed some outdated documents.
22
+
7
23
  ## 0.3.0 - 2020-06-04
8
24
  ### Added
9
25
  - You can now register and use your own Resolver with this gem. (see Panchira::Extensions#register)
@@ -27,6 +43,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
27
43
  ### Added
28
44
  - Released Panchira gem. At this time we can parse only 5 websites.
29
45
 
46
+ [1.1.0]: https://github.com/nuita/panchira/releases/tag/v1.1.0
47
+ [1.0.0]: https://github.com/nuita/panchira/releases/tag/v1.0.0
30
48
  [0.3.0]: https://github.com/nuita/panchira/releases/tag/v0.3.0
31
49
  [0.2.0]: https://github.com/nuita/panchira/releases/tag/v0.2.0
32
50
  [0.1.1]: https://github.com/nuita/panchira/releases/tag/v0.1.1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- panchira (1.0.0)
4
+ panchira (1.1.0)
5
5
  fastimage (~> 2.1.7)
6
6
  nokogiri (~> 1.10.9)
7
7
 
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 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 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
 
@@ -16,7 +16,7 @@ This gem is derived from the [Nuita](https://github.com/nuita/nuita) project.
16
16
 
17
17
  **Please use this gem with appropriate censoring and age-restricting. Never violate local laws and copyrights.**
18
18
 
19
- If you are running one of the websites we cover and feel negative about it, please contact the community or the author([@kypkyp](https://github.com/kypkyp)).
19
+ If you are running one of the websites we cover and feel negative about this gem, please contact the community or the author([@kypkyp](https://github.com/kypkyp)).
20
20
 
21
21
  ## Installation
22
22
 
@@ -13,6 +13,9 @@ require_relative 'panchira/extensions'
13
13
  project_root = File.dirname(File.absolute_path(__FILE__))
14
14
  Dir.glob(project_root + '/panchira/resolvers/*_resolver.rb').sort.each { |file| require file }
15
15
 
16
+ # register fallback ImageResolver at the end. (resolver is selected by registration order)
17
+ ::Panchira::Extensions.register(Panchira::ImageResolver)
18
+
16
19
  # Main Panchira code goes here.
17
20
  # If you simply want to get data from your URL, then ::Panchira::fetch() will do.
18
21
  module Panchira
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'net/https'
4
+
5
+ module Panchira
6
+ module Fanza
7
+ class FanzaBookResolver < Resolver
8
+ URL_REGEXP = %r{book\.dmm\.co\.jp\/}.freeze
9
+
10
+ private
11
+
12
+ def parse_image
13
+ @page.css('.m-imgDetailProductPack/@src').first.to_s
14
+ end
15
+
16
+ def cookie
17
+ 'age_check_done=1;'
18
+ end
19
+ end
20
+ end
21
+
22
+ ::Panchira::Extensions.register(Panchira::Fanza::FanzaBookResolver)
23
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Panchira
4
+ class ImageResolver < Resolver
5
+ URL_REGEXP = %r{\.(png|gif|jpg|jpeg|webp)$}.freeze
6
+
7
+ def fetch
8
+ result = PanchiraResult.new
9
+ result.canonical_url = @url
10
+ result.image = PanchiraImage.new
11
+ result.image.url = @url
12
+ result
13
+ end
14
+ end
15
+ end
@@ -10,7 +10,7 @@ module Panchira
10
10
  @url = url
11
11
 
12
12
  @id = url.slice(URL_REGEXP, 1)
13
- raw_json = URI.parse("https://api.komiflo.com/content/id/#{@id}").read('User-Agent' => USER_AGENT)
13
+ raw_json = URI.parse("https://api.komiflo.com/content/id/#{@id}").read('User-Agent' => user_agent)
14
14
  @json = JSON.parse(raw_json)
15
15
  end
16
16
 
@@ -39,7 +39,7 @@ module Panchira
39
39
  end
40
40
 
41
41
  def parse_tags
42
- @json['content']['attributes']['tags']['children'].map{|content| content['data']['name']}
42
+ @json['content']['attributes']['tags']['children'].map { |content| content['data']['name'] }
43
43
  end
44
44
  end
45
45
 
@@ -8,7 +8,7 @@ module Panchira
8
8
  super(url)
9
9
  @illust_id = url.slice(URL_REGEXP, 2)
10
10
 
11
- raw_json = URI.parse("https://www.pixiv.net/ajax/illust/#{@illust_id}").read('User-Agent' => USER_AGENT)
11
+ raw_json = URI.parse("https://www.pixiv.net/ajax/illust/#{@illust_id}").read('User-Agent' => user_agent)
12
12
  @json = JSON.parse(raw_json)
13
13
  end
14
14
 
@@ -11,8 +11,6 @@ module Panchira
11
11
  # You must override this in subclasses to limit which urls to resolve.
12
12
  URL_REGEXP = URI::DEFAULT_PARSER.make_regexp
13
13
 
14
- USER_AGENT = "Mozilla/5.0 (compatible; PanchiraBot/#{VERSION}; +https://github.com/nuita/panchira)"
15
-
16
14
  def initialize(url)
17
15
  @url = url
18
16
  end
@@ -46,7 +44,12 @@ module Panchira
46
44
  private
47
45
 
48
46
  def fetch_page(url)
49
- raw_page = URI.parse(url).read('User-Agent' => self.class::USER_AGENT)
47
+ read_options = {
48
+ 'User-Agent' => user_agent,
49
+ 'Cookie' => cookie
50
+ }
51
+
52
+ raw_page = URI.parse(url).read(read_options)
50
53
  charset = raw_page.charset
51
54
  Nokogiri::HTML.parse(raw_page, url, charset)
52
55
  end
@@ -102,5 +105,13 @@ module Panchira
102
105
  def parse_tags
103
106
  []
104
107
  end
108
+
109
+ def cookie
110
+ ''
111
+ end
112
+
113
+ def user_agent
114
+ "Mozilla/5.0 (compatible; PanchiraBot/#{VERSION}; +https://github.com/nuita/panchira)"
115
+ end
105
116
  end
106
117
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Panchira
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
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.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-23 00:00:00.000000000 Z
11
+ date: 2020-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,6 +103,8 @@ files:
103
103
  - lib/panchira/extensions.rb
104
104
  - lib/panchira/panchira_result.rb
105
105
  - lib/panchira/resolvers/dlsite_resolver.rb
106
+ - lib/panchira/resolvers/fanza_resolver.rb
107
+ - lib/panchira/resolvers/image_resolver.rb
106
108
  - lib/panchira/resolvers/komiflo_resolver.rb
107
109
  - lib/panchira/resolvers/melonbooks_resolver.rb
108
110
  - lib/panchira/resolvers/narou_resolver.rb