itch_client 0.3.0 → 0.4.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/.gitignore +2 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +36 -36
- data/README.md +23 -1
- data/itch_client.gemspec +1 -0
- data/lib/itch/bundle.rb +2 -2
- data/lib/itch/bundles.rb +7 -7
- data/lib/itch/game.rb +5 -0
- data/lib/itch/review.rb +23 -0
- data/lib/itch/reviews.rb +81 -0
- data/lib/itch/rewards.rb +2 -2
- data/lib/itch/version.rb +1 -1
- data/lib/itch_client.rb +1 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6f876530a8599ff397068d9d47e2e8adc23b98fcc72408316d0115f7207302d4
|
|
4
|
+
data.tar.gz: 3bb26a90883d227f89b07ec3f10ec4c02e207d8ebfa4ca96e630aff2ff478a7e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c7566cb970c91713a5c471b74a2a9d6b17d5b2fdf570976abc8b1f5b893a33fd45ca5b1160bf1f7324f49fd86eb50ebd7d1388b764c416fbb8c2d1493d7f46b9
|
|
7
|
+
data.tar.gz: 06566e4cf0598494518ca9a1a4d0c42ddb7ee1b4b8ba03b2d8e1fd10f885f9c84c226da62d55fad4001e2dfc11448afb033ee6b3e78dc715ffebcb304d5b82c6
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
itch_client (0.
|
|
4
|
+
itch_client (0.4.0)
|
|
5
5
|
mechanize (~> 2.8)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -12,16 +12,16 @@ GEM
|
|
|
12
12
|
ast (2.4.2)
|
|
13
13
|
coderay (1.1.3)
|
|
14
14
|
connection_pool (2.2.5)
|
|
15
|
-
diff-lcs (1.
|
|
15
|
+
diff-lcs (1.5.0)
|
|
16
16
|
domain_name (0.5.20190701)
|
|
17
17
|
unf (>= 0.0.5, < 1.0.0)
|
|
18
|
-
http-cookie (1.0.
|
|
18
|
+
http-cookie (1.0.4)
|
|
19
19
|
domain_name (~> 0.5)
|
|
20
|
-
io-console (0.5.
|
|
21
|
-
irb (1.
|
|
22
|
-
reline (>= 0.
|
|
23
|
-
mechanize (2.8.
|
|
24
|
-
addressable (~> 2.
|
|
20
|
+
io-console (0.5.11)
|
|
21
|
+
irb (1.4.1)
|
|
22
|
+
reline (>= 0.3.0)
|
|
23
|
+
mechanize (2.8.4)
|
|
24
|
+
addressable (~> 2.8)
|
|
25
25
|
domain_name (~> 0.5, >= 0.5.20190701)
|
|
26
26
|
http-cookie (~> 1.0, >= 1.0.3)
|
|
27
27
|
mime-types (~> 3.0)
|
|
@@ -32,58 +32,58 @@ GEM
|
|
|
32
32
|
webrick (~> 1.7)
|
|
33
33
|
webrobots (~> 0.1.2)
|
|
34
34
|
method_source (1.0.0)
|
|
35
|
-
mime-types (3.
|
|
35
|
+
mime-types (3.4.1)
|
|
36
36
|
mime-types-data (~> 3.2015)
|
|
37
|
-
mime-types-data (3.
|
|
37
|
+
mime-types-data (3.2022.0105)
|
|
38
38
|
net-http-digest_auth (1.4.1)
|
|
39
39
|
net-http-persistent (4.0.1)
|
|
40
40
|
connection_pool (~> 2.2)
|
|
41
|
-
nokogiri (1.
|
|
41
|
+
nokogiri (1.13.3-x86_64-linux)
|
|
42
42
|
racc (~> 1.4)
|
|
43
|
-
parallel (1.
|
|
44
|
-
parser (3.
|
|
43
|
+
parallel (1.22.1)
|
|
44
|
+
parser (3.1.1.0)
|
|
45
45
|
ast (~> 2.4.1)
|
|
46
46
|
pry (0.14.1)
|
|
47
47
|
coderay (~> 1.1)
|
|
48
48
|
method_source (~> 1.0)
|
|
49
49
|
public_suffix (4.0.6)
|
|
50
|
-
racc (1.
|
|
51
|
-
rainbow (3.
|
|
52
|
-
rake (13.0.
|
|
53
|
-
regexp_parser (2.
|
|
54
|
-
reline (0.
|
|
50
|
+
racc (1.6.0)
|
|
51
|
+
rainbow (3.1.1)
|
|
52
|
+
rake (13.0.6)
|
|
53
|
+
regexp_parser (2.2.1)
|
|
54
|
+
reline (0.3.1)
|
|
55
55
|
io-console (~> 0.5)
|
|
56
56
|
rexml (3.2.5)
|
|
57
|
-
rspec (3.
|
|
58
|
-
rspec-core (~> 3.
|
|
59
|
-
rspec-expectations (~> 3.
|
|
60
|
-
rspec-mocks (~> 3.
|
|
61
|
-
rspec-core (3.
|
|
62
|
-
rspec-support (~> 3.
|
|
63
|
-
rspec-expectations (3.
|
|
57
|
+
rspec (3.11.0)
|
|
58
|
+
rspec-core (~> 3.11.0)
|
|
59
|
+
rspec-expectations (~> 3.11.0)
|
|
60
|
+
rspec-mocks (~> 3.11.0)
|
|
61
|
+
rspec-core (3.11.0)
|
|
62
|
+
rspec-support (~> 3.11.0)
|
|
63
|
+
rspec-expectations (3.11.0)
|
|
64
64
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
65
|
-
rspec-support (~> 3.
|
|
66
|
-
rspec-mocks (3.
|
|
65
|
+
rspec-support (~> 3.11.0)
|
|
66
|
+
rspec-mocks (3.11.1)
|
|
67
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
68
|
-
rspec-support (~> 3.
|
|
69
|
-
rspec-support (3.
|
|
70
|
-
rubocop (1.
|
|
68
|
+
rspec-support (~> 3.11.0)
|
|
69
|
+
rspec-support (3.11.0)
|
|
70
|
+
rubocop (1.26.1)
|
|
71
71
|
parallel (~> 1.10)
|
|
72
|
-
parser (>= 3.
|
|
72
|
+
parser (>= 3.1.0.0)
|
|
73
73
|
rainbow (>= 2.2.2, < 4.0)
|
|
74
74
|
regexp_parser (>= 1.8, < 3.0)
|
|
75
75
|
rexml
|
|
76
|
-
rubocop-ast (>= 1.
|
|
76
|
+
rubocop-ast (>= 1.16.0, < 2.0)
|
|
77
77
|
ruby-progressbar (~> 1.7)
|
|
78
78
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
79
|
-
rubocop-ast (1.
|
|
80
|
-
parser (>= 3.
|
|
79
|
+
rubocop-ast (1.16.0)
|
|
80
|
+
parser (>= 3.1.1.0)
|
|
81
81
|
ruby-progressbar (1.11.0)
|
|
82
82
|
rubyntlm (0.6.3)
|
|
83
83
|
unf (0.1.4)
|
|
84
84
|
unf_ext
|
|
85
|
-
unf_ext (0.0.
|
|
86
|
-
unicode-display_width (2.
|
|
85
|
+
unf_ext (0.0.8.1)
|
|
86
|
+
unicode-display_width (2.1.0)
|
|
87
87
|
webrick (1.7.0)
|
|
88
88
|
webrobots (0.1.2)
|
|
89
89
|
|
data/README.md
CHANGED
|
@@ -171,6 +171,27 @@ client.game(12345).css
|
|
|
171
171
|
client.game(12345).css = "body { background-color: green; }"
|
|
172
172
|
```
|
|
173
173
|
|
|
174
|
+
### Reviews
|
|
175
|
+
|
|
176
|
+
Fetch current reviews
|
|
177
|
+
|
|
178
|
+
```ruby
|
|
179
|
+
reviews = client.game(12345).reviews.list
|
|
180
|
+
#=>
|
|
181
|
+
[
|
|
182
|
+
#<Itch::Review:0x0000557aa98c7930
|
|
183
|
+
@id="123456789",
|
|
184
|
+
@user_name="Billiam",
|
|
185
|
+
@user_id="billiam",
|
|
186
|
+
@date=<DateTime: 2022-04-03T10:02:00+00:00>,
|
|
187
|
+
@stars=4,
|
|
188
|
+
@review=[
|
|
189
|
+
"I really like this game",
|
|
190
|
+
"So much that I've added a second paragraph"
|
|
191
|
+
],
|
|
192
|
+
]
|
|
193
|
+
```
|
|
194
|
+
|
|
174
195
|
### Rewards
|
|
175
196
|
|
|
176
197
|
Fetch reward CSV data
|
|
@@ -252,7 +273,8 @@ filtered_rewards = rewards.select do |reward|
|
|
|
252
273
|
end
|
|
253
274
|
client.game(12345).rewards.save(filtered_rewards)
|
|
254
275
|
```
|
|
255
|
-
|
|
276
|
+
|
|
277
|
+
## Bundles
|
|
256
278
|
|
|
257
279
|
Fetch current bundles
|
|
258
280
|
|
data/itch_client.gemspec
CHANGED
|
@@ -16,6 +16,7 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
17
17
|
spec.metadata["source_code_uri"] = spec.homepage
|
|
18
18
|
spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.md"
|
|
19
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
19
20
|
|
|
20
21
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
21
22
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
data/lib/itch/bundle.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require_relative "simple_inspect"
|
|
2
4
|
|
|
3
5
|
module Itch
|
|
@@ -7,7 +9,6 @@ module Itch
|
|
|
7
9
|
|
|
8
10
|
attr_accessor :id, :title, :games, :purchases, :price, :earnings
|
|
9
11
|
|
|
10
|
-
# rubocop:disable Metrics/ParameterLists
|
|
11
12
|
def initialize(id, title, purchases, price, earnings)
|
|
12
13
|
@id = id
|
|
13
14
|
@title = title
|
|
@@ -15,7 +16,6 @@ module Itch
|
|
|
15
16
|
@price = price
|
|
16
17
|
@earnings = earnings
|
|
17
18
|
end
|
|
18
|
-
# rubocop:enable Metrics/ParameterLists
|
|
19
19
|
|
|
20
20
|
def url
|
|
21
21
|
format(Itch::URL::BUNDLE, id: @id)
|
data/lib/itch/bundles.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
require "bigdecimal"
|
|
3
4
|
|
|
4
5
|
require_relative "simple_inspect"
|
|
5
6
|
require_relative "bundle"
|
|
6
7
|
require_relative "request"
|
|
7
8
|
require_relative "require_auth"
|
|
8
9
|
|
|
9
|
-
|
|
10
10
|
module Itch
|
|
11
11
|
# Fetch bundles
|
|
12
12
|
class Bundles
|
|
@@ -23,16 +23,16 @@ module Itch
|
|
|
23
23
|
@agent.get(bundles_url)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
page.css(
|
|
26
|
+
page.css(".bundle_list table > tr").map do |row|
|
|
27
27
|
parse_row(row)
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def parse_row(row)
|
|
32
|
-
id = row.at_xpath(
|
|
33
|
-
vals = row.css(
|
|
34
|
-
price = BigDecimal(vals[5].gsub(/[^\d.-]/,
|
|
35
|
-
earnings = BigDecimal(vals[6].gsub(/[\D-]/,
|
|
32
|
+
id = row.at_xpath("td[2]/a/@href").value.match(%r{^/b/(\d+)/})[1]
|
|
33
|
+
vals = row.css("td").map(&:text)
|
|
34
|
+
price = BigDecimal(vals[5].gsub(/[^\d.-]/, ""))
|
|
35
|
+
earnings = BigDecimal(vals[6].gsub(/[\D-]/, ""))
|
|
36
36
|
|
|
37
37
|
Bundle.new(id, vals[1], vals[4].to_i, price, earnings)
|
|
38
38
|
end
|
data/lib/itch/game.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "reviews"
|
|
3
4
|
require_relative "rewards"
|
|
4
5
|
require_relative "reward"
|
|
5
6
|
require_relative "require_auth"
|
|
@@ -48,6 +49,10 @@ module Itch
|
|
|
48
49
|
Rewards.new(@agent, @id)
|
|
49
50
|
end
|
|
50
51
|
|
|
52
|
+
def reviews
|
|
53
|
+
Reviews.new(@agent, @id)
|
|
54
|
+
end
|
|
55
|
+
|
|
51
56
|
def reward(id)
|
|
52
57
|
rewards.find { |reward| reward.id == id }
|
|
53
58
|
end
|
data/lib/itch/review.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "simple_inspect"
|
|
4
|
+
|
|
5
|
+
module Itch
|
|
6
|
+
# Data container for single review
|
|
7
|
+
class Review
|
|
8
|
+
include SimpleInspect
|
|
9
|
+
|
|
10
|
+
attr_reader :id, :user_name, :user_id, :stars, :date, :review
|
|
11
|
+
|
|
12
|
+
# rubocop:disable Metrics/ParameterLists
|
|
13
|
+
def initialize(user_name:, user_id:, stars:, date:, review:, id: nil)
|
|
14
|
+
@id = id
|
|
15
|
+
@user_name = user_name
|
|
16
|
+
@user_id = user_id
|
|
17
|
+
@stars = stars
|
|
18
|
+
@date = date
|
|
19
|
+
@review = review
|
|
20
|
+
end
|
|
21
|
+
# rubocop:enable Metrics/ParameterLists
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/itch/reviews.rb
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
require_relative "require_auth"
|
|
6
|
+
require_relative "simple_inspect"
|
|
7
|
+
require_relative "review"
|
|
8
|
+
require_relative "request"
|
|
9
|
+
|
|
10
|
+
module Itch
|
|
11
|
+
# Fetch reviews
|
|
12
|
+
class Reviews
|
|
13
|
+
include SimpleInspect
|
|
14
|
+
include RequireAuth
|
|
15
|
+
include Request
|
|
16
|
+
|
|
17
|
+
def initialize(agent, game_id)
|
|
18
|
+
@agent = agent
|
|
19
|
+
@game_id = game_id
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def list
|
|
23
|
+
all_reviews = []
|
|
24
|
+
|
|
25
|
+
page_number = 1
|
|
26
|
+
loop do
|
|
27
|
+
page_reviews = parse_page_reviews(page_number)
|
|
28
|
+
|
|
29
|
+
break if page_reviews.empty?
|
|
30
|
+
|
|
31
|
+
all_reviews += page_reviews
|
|
32
|
+
page_number += 1
|
|
33
|
+
sleep 0.5
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
all_reviews
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
protected
|
|
40
|
+
|
|
41
|
+
def parse_page_reviews(page_number)
|
|
42
|
+
page = with_login do
|
|
43
|
+
@agent.get(review_url(page_number))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
raise Error, "Could not find game id #{@game_id} rewards" unless page.code == "200"
|
|
47
|
+
|
|
48
|
+
page.css(".content_column .rating").map do |row|
|
|
49
|
+
parse_row row
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
54
|
+
def parse_row(row)
|
|
55
|
+
id = row.at_css("button[data-lightbox_url]")["data-lightbox_url"].split("/").last
|
|
56
|
+
stars = row.css(".star_picker .icon-star").length
|
|
57
|
+
header = row.at_css(".row_header")
|
|
58
|
+
date = DateTime.parse header.at_css("abbr")["title"].strip
|
|
59
|
+
|
|
60
|
+
user_link = header.at_css(".user_link")
|
|
61
|
+
user_name = user_link.search("./text()").text.strip
|
|
62
|
+
user_id = user_link["href"].split("/").last
|
|
63
|
+
|
|
64
|
+
text = row.css(".blurb p").map(&:text)
|
|
65
|
+
|
|
66
|
+
Review.new(
|
|
67
|
+
id: id,
|
|
68
|
+
user_name: user_name,
|
|
69
|
+
user_id: user_id,
|
|
70
|
+
stars: stars,
|
|
71
|
+
date: date,
|
|
72
|
+
review: text
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
|
76
|
+
|
|
77
|
+
def review_url(page = 1)
|
|
78
|
+
format(Itch::URL::REVIEWS, id: @game_id, page: page)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
data/lib/itch/rewards.rb
CHANGED
|
@@ -106,9 +106,9 @@ module Itch
|
|
|
106
106
|
input.name.match(/^rewards\[(\d+)\]\[id\]/)
|
|
107
107
|
end.value
|
|
108
108
|
|
|
109
|
-
attributes = %w[title description amount price].
|
|
109
|
+
attributes = %w[title description amount price].to_h do |name|
|
|
110
110
|
[name.to_sym, row.css_at(".reward_#{name}_input").value]
|
|
111
|
-
end
|
|
111
|
+
end
|
|
112
112
|
attributes[:claimed] = row.css_at(".claimed_count").text
|
|
113
113
|
|
|
114
114
|
Reward.new(@agent, @game_id, id, attributes)
|
data/lib/itch/version.rb
CHANGED
data/lib/itch_client.rb
CHANGED
|
@@ -35,6 +35,7 @@ module Itch
|
|
|
35
35
|
LOGIN = "https://itch.io/login"
|
|
36
36
|
MONTH_PURCHASES_CSV = "https://itch.io/export-purchases/by-date/%<month>d-%<year>d"
|
|
37
37
|
PURCHASES_CSV = "https://itch.io/export-purchases/all"
|
|
38
|
+
REVIEWS = "https://itch.io/game/ratings/%<id>d?page=%<page>d"
|
|
38
39
|
REWARD_CSV = "https://itch.io/game/rewards/%<id>d/claimed?format=csv"
|
|
39
40
|
REWARDS = "https://itch.io/game/rewards/%<id>d"
|
|
40
41
|
TOTP_FRAGMENT = "https://itch.io/totp/verify/"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: itch_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Billiam
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-04-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mechanize
|
|
@@ -53,6 +53,8 @@ files:
|
|
|
53
53
|
- lib/itch/purchases.rb
|
|
54
54
|
- lib/itch/request.rb
|
|
55
55
|
- lib/itch/require_auth.rb
|
|
56
|
+
- lib/itch/review.rb
|
|
57
|
+
- lib/itch/reviews.rb
|
|
56
58
|
- lib/itch/reward.rb
|
|
57
59
|
- lib/itch/rewards.rb
|
|
58
60
|
- lib/itch/simple_inspect.rb
|
|
@@ -65,6 +67,7 @@ metadata:
|
|
|
65
67
|
homepage_uri: https://github.com/Billiam/itch-client
|
|
66
68
|
source_code_uri: https://github.com/Billiam/itch-client
|
|
67
69
|
changelog_uri: https://github.com/Billiam/itch-client/CHANGELOG.md
|
|
70
|
+
rubygems_mfa_required: 'true'
|
|
68
71
|
post_install_message:
|
|
69
72
|
rdoc_options: []
|
|
70
73
|
require_paths:
|