panchira 1.5.0 → 1.5.1

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: 9119f6e4ad4e4a3b551642f7d19a7853805d2c82b65c5fc868b472f265e7169c
4
- data.tar.gz: 03cbbf38e009cd326b4f40f467de1dcc1d0fb852de362b3dde05ed56eb65c2c2
3
+ metadata.gz: 642bed0e6765fbea03fe04681debc2d3c02a269cbc6a7547d68209f9b0b0aad7
4
+ data.tar.gz: 626ca110ca53489b8ec0289a0486a13abbeccc1aae1408bc6d51de058606e425
5
5
  SHA512:
6
- metadata.gz: 6ff2fab3b4489ade9e7accb6f10dc2d391aa5ba5ebbbb08f130926df81acd31eeae36d2208b915848e5e1337e71ab2a7cbe300eeeb728ed8669593fc139573f8
7
- data.tar.gz: df76a29e1af2515d4eee99568426295e02fbcf8b1b6b835932633458f3f287d4ca2460ec1a497a73f2f8a5e66a100acf71aa37e35be3dd778c95ac83f2f808e7
6
+ metadata.gz: aa1f9adc654d34794da25aa65c53526fed63c6d5c3528f9c201edf0433d10e802539fa3ca33a674bd3bcbeffd6f94d4502b57e7df0484d2dbd65237b9ffc2710
7
+ data.tar.gz: 645e6c3aafe4f5f2919c61ca4caf42ba045732be2b94a173061be632bf22c7deebe0500145c9f6e4d6d47eccab1d3922887ec6f85cf5af97162bd24a50a4d771
data/CHANGELOG.md CHANGED
@@ -4,10 +4,14 @@ 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.5.1 - 2022-03-20
8
+ ### Added
9
+ - Pixiv resolver can now fetch image URIs that are not proxied.
10
+
7
11
  ## 1.5.0 - 2022-03-01
8
12
  ### Changed
9
13
  - You can now set options in Panchira::fetch and Resolver's constructors.
10
- - Twitter resolvers can now fetch datas from API (requires bearer token).
14
+ - Twitter resolver can now fetch datas from API (requires bearer token).
11
15
  - Max execution time is now set to 10 seconds.
12
16
 
13
17
  ## 1.4.0 - 2022-01-10
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- panchira (1.5.0)
4
+ panchira (1.5.1)
5
5
  fastimage (~> 2.1.7)
6
6
  nokogiri (>= 1.10.9, < 1.14.0)
7
7
 
@@ -10,10 +10,8 @@ GEM
10
10
  specs:
11
11
  ast (2.4.2)
12
12
  fastimage (2.1.7)
13
- mini_portile2 (2.8.0)
14
13
  minitest (5.15.0)
15
- nokogiri (1.13.3)
16
- mini_portile2 (~> 2.8.0)
14
+ nokogiri (1.13.3-x86_64-darwin)
17
15
  racc (~> 1.4)
18
16
  parallel (1.21.0)
19
17
  parser (3.1.1.0)
data/README.md CHANGED
@@ -56,6 +56,14 @@ To use Twitter API instead of normal scraping, please set Twitter's bearer token
56
56
  > Panchira.fetch("https://twitter.com/example/status/1234567890", options: {twitter: {bearer_token: 'ABC...123'}})
57
57
  ```
58
58
 
59
+ ### About Pixiv proxy
60
+
61
+ By default, Panchira returns a link to [Pixiv.cat](https://pixiv.cat/) as a image URI, but you can change this behavior by setting `fetch_raw_image_url` as an option. To access not-proxied URI, pximg.net, you have to set Referer as `https://app-api.pixiv.net/` in HTTP request header.
62
+
63
+ ```
64
+ > Panchira.fetch("https://pixiv.net/artworks/12345678", options: {pixiv: {fetch_raw_image_url: true}})
65
+ ```
66
+
59
67
  ## Development
60
68
 
61
69
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -10,6 +10,8 @@ module Panchira
10
10
 
11
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
+
14
+ @fetch_raw_image_url = options&.dig(:pixiv, :fetch_raw_image_url)
13
15
  end
14
16
 
15
17
  private
@@ -27,6 +29,10 @@ module Panchira
27
29
  end
28
30
 
29
31
  def parse_image_url
32
+ if @fetch_raw_image_url
33
+ return @json['body']['urls']['original']
34
+ end
35
+
30
36
  proxy_url = "https://pixiv.cat/#{@illust_id}.jpg"
31
37
 
32
38
  case Net::HTTP.get_response(URI.parse(proxy_url))
@@ -10,6 +10,9 @@ module Panchira
10
10
  @id = @url.slice(URL_REGEXP, 2)
11
11
 
12
12
  @bearer_token = options&.dig(:twitter, :bearer_token)
13
+
14
+ @author = nil
15
+ @response = nil
13
16
  end
14
17
 
15
18
  def fetch
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Panchira
4
- VERSION = '1.5.0'
4
+ VERSION = '1.5.1'
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.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-01 00:00:00.000000000 Z
11
+ date: 2022-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler