artbase 0.1.0 → 0.2.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: fa2c17e20eba3ef7a381f5643f4f2fde0d7bed07bf1ea613fe4da8a324f5c500
4
- data.tar.gz: 7f124deeb894095131e7e472286deebc0703fd2ffbfa9bb1167e58a59745c4c5
3
+ metadata.gz: 1d2702ba1ca72c303474ee868074e5fc244d1a510d240cb7b533813b85f07bdd
4
+ data.tar.gz: 46591b009738fc8c45bd777b56b74dab8195f2fee6f967efa3a05b1c5efbe92b
5
5
  SHA512:
6
- metadata.gz: 74533360be3826d67c3b3b286fdeaabbe5623df8efa4dba377a3b2d6cadf8299c858202274ac4be69be581b722ee2c81e6edd5d3193b1dd80dbe5d98264e01f1
7
- data.tar.gz: b80f2676cf847d875ac321a9ee6ffb30357fe306c88173d08bc9cddbe0928e2c722a66fe5b8b9786dede41f3b12647ff99db5b4da2138ac937d7f332f6ebe53c
6
+ metadata.gz: 7a1a11ce316e7de3ec11b001262eb614b34cb0b53f9237357c60026fabddafd8b38839ba1ab77221f5062044aced9df44d082fe7146e68dc9dca4ee40dc5d1d0
7
+ data.tar.gz: 12dacbd59d727be09dbb626156a79e54dbc10a52ed13ed9b3963ee731dffcad45c08d23b812494780ff86bba51ea34fb3205258663759835ce94384229229b76
data/CHANGELOG.md CHANGED
@@ -1,3 +1,3 @@
1
- ### 0.0.1 / 2018-10-18
2
-
3
- * Everything is new. First release
1
+ ### 0.0.1 / 2018-10-18
2
+
3
+ * Everything is new. First release
data/Manifest.txt CHANGED
@@ -1,5 +1,4 @@
1
1
  CHANGELOG.md
2
- LICENSE.md
3
2
  Manifest.txt
4
3
  README.md
5
4
  Rakefile
@@ -7,15 +6,13 @@ bin/artbase
7
6
  lib/artbase.rb
8
7
  lib/artbase/attributes.rb
9
8
  lib/artbase/collection.rb
9
+ lib/artbase/collection/base.rb
10
10
  lib/artbase/collection/image.rb
11
11
  lib/artbase/collection/opensea.rb
12
12
  lib/artbase/collection/token.rb
13
13
  lib/artbase/helper.rb
14
14
  lib/artbase/image.rb
15
- lib/artbase/image/24x24.rb
16
- lib/artbase/image/32x32.rb
17
- lib/artbase/image/60x60.rb
18
- lib/artbase/image/80x80.rb
19
- lib/artbase/opensea.rb
15
+ lib/artbase/image/sample.rb
16
+ lib/artbase/retry.rb
20
17
  lib/artbase/tool.rb
21
18
  lib/artbase/version.rb
data/README.md CHANGED
@@ -1,39 +1,274 @@
1
- # artbase ("right-clicker") command line tool & scripts - download complete pixel art collections - yes, you can! - automate "right-click 'n' download" and much more
2
-
3
- * home :: [github.com/pixelartexchange/artbase](https://github.com/pixelartexchange/artbase)
4
- * bugs :: [github.com/pixelartexchange/artbase/issues](https://github.com/pixelartexchange/artbase/issues)
5
- * gem :: [rubygems.org/gems/artbase](https://rubygems.org/gems/artbase)
6
- * rdoc :: [rubydoc.info/gems/artbase](http://rubydoc.info/gems/artbase)
7
-
8
-
9
-
10
- ## Usage
11
-
12
-
13
- Note: The artbase is alpha - it's still the early days - it's a work-in-progress.
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
- ## Install
25
-
26
- Just install the gem:
27
-
28
- $ gem install artbase
29
-
30
-
31
- ## License
32
-
33
- The `artbase` scripts are dedicated to the public domain.
34
- Use it as you please with no restrictions whatsoever.
35
-
36
-
37
- ## Questions? Comments?
38
-
39
- Post them on the [CryptoPunksDev reddit](https://old.reddit.com/r/CryptoPunksDev). Thanks.
1
+ # artbase ("right-clicker") command line tool & scripts - download complete pixel art collections - yes, you can! - automate "right-click 'n' download" and much more
2
+
3
+ * home :: [github.com/pixelartexchange/artbase](https://github.com/pixelartexchange/artbase)
4
+ * bugs :: [github.com/pixelartexchange/artbase/issues](https://github.com/pixelartexchange/artbase/issues)
5
+ * gem :: [rubygems.org/gems/artbase](https://rubygems.org/gems/artbase)
6
+ * rdoc :: [rubydoc.info/gems/artbase](http://rubydoc.info/gems/artbase)
7
+
8
+
9
+
10
+ ## Usage
11
+
12
+
13
+ Note: The artbase is alpha - it's still the early days - it's a work-in-progress.
14
+
15
+
16
+
17
+
18
+ Let's try the 100 Blocky Doge (60x60) collection.
19
+
20
+
21
+ ### Step 0 - Collection Configuration Script
22
+
23
+ Create a directory with the collection slug (e.g. `blockydoge`)
24
+ matching the OpenSea collection slug
25
+ and add a config script - `blockydoge/config.rb`:
26
+
27
+ ``` ruby
28
+ COLLECTION = Collection.new(
29
+
30
+ 'blockydoge', # opensea collection slug
31
+ 100, # number of items
32
+
33
+ format: '60x60', # original pixel format
34
+ source: '512x512', # "big" source pixel format for
35
+ # downloaded image referenced in meta data
36
+
37
+ #####
38
+ # "automagically" get the id from the meta data name field
39
+ # via a "one-off / custom / hand-written" regex
40
+ # e.g. Blocky Doge #1 => 1
41
+ meta_slugify: /^Blocky Doge #(?<num>[0-9]+)$/,
42
+ )
43
+ ```
44
+
45
+ Sorry for the "magic" config format for now -
46
+ see the [**opensea.sandbox**](https://github.com/pixelartexchange/opensea.sandbox) for many more "real-world" examples.
47
+
48
+
49
+
50
+
51
+
52
+ That's it now you can:
53
+
54
+ - Download all meta data files via the OpenSea API
55
+ - Download all referenced images in the meta data file
56
+ - Pixelate all downloaded images from the source format (e.g. 512x512) to the original format (e.g. 60x60)
57
+ - Generate an all-in-one composite with the pixelated images
58
+ - Export all meta data attributes / traits to an all-in-one datafile in the comma-separated-values (.csv) format
59
+
60
+
61
+ ### Download all meta data files via the OpenSea API
62
+
63
+ Let's try:
64
+
65
+ ```
66
+ $ artbase blockydoge meta
67
+ ```
68
+
69
+ Note: All meta data files get stored by convention in `blockydoge/meta`.
70
+ Resulting in a file tree like:
71
+
72
+ ```
73
+ blockydoge/meta/
74
+ 0.json
75
+ 1.json
76
+ 2.json
77
+ 3.json
78
+ 4.json
79
+ 5.json
80
+ 6.json
81
+ 7.json
82
+ 8.json
83
+ 9.json
84
+ 10.json
85
+ 11.json
86
+ 12.json
87
+ ...
88
+ ```
89
+
90
+ Example - `blockydoge/meta/0.json`:
91
+
92
+ ``` json
93
+ {
94
+ "id": 52224520,
95
+ "token_id": "154226446513437...7290852067901441",
96
+ "num_sales": 1,
97
+ "image_url": "https://lh3.googleusercontent.com/fIQQ0A7...gTlbgMTQ",
98
+ "image_preview_url": "https://lh3.googleusercontent.com/fIQQ0A7...gTlbgMTQ=s250",
99
+ "image_thumbnail_url": "https://lh3.googleusercontent.com/fIQQ0A7...gTlbgMTQ=s128",
100
+ "image_original_url": null,
101
+ "name": "Blocky Doge #1",
102
+ "description": "Blocky Doge ... 100 unique pixelated Doge avatars...",
103
+ "external_link": null,
104
+
105
+ ...
106
+
107
+ "traits": [
108
+ { "trait_type": "Fur", "value": "Red Fur", ... },
109
+ { "trait_type": "Hat", "value": "Pink Party Hat", ... },
110
+ { "trait_type": "Expression", "value": "Smiley", ... },
111
+ ],
112
+
113
+ ...
114
+ }
115
+ ```
116
+
117
+
118
+
119
+ ### Download all referenced images in the meta data file
120
+
121
+ Let's try:
122
+
123
+ ```
124
+ $ artbase blockydoge img
125
+ ```
126
+
127
+ Note: All referenced images (in the source format e.g. 512x512)
128
+ get stored by convention in `blockydoge/i`.
129
+ Resulting in a file tree like:
130
+
131
+ ```
132
+ blockydoge/i/
133
+ 0.png
134
+ 1.png
135
+ 2.png
136
+ 3.png
137
+ 4.png
138
+ 5.png
139
+ 6.png
140
+ 7.png
141
+ 8.png
142
+ 9.png
143
+ 10.png
144
+ 11.png
145
+ 12.png
146
+ ...
147
+ ```
148
+
149
+ Example - `blockydoge/i/0.png` (512x512):
150
+
151
+ ![](i/blockydoge0-512x512.png)
152
+
153
+
154
+
155
+
156
+
157
+ ### Pixelate all downloaded images from the source format (e.g. 512x512) to the original format (e.g. 60x60)
158
+
159
+ Let's try:
160
+
161
+ ```
162
+ $ artbase blockydoge px
163
+ ```
164
+
165
+ Note: All referenced images pixelated down to the orginal format (e.g. 60x60)
166
+ get stored by convention in `blockydoge/ii`.
167
+ Resulting in a tree like:
168
+
169
+ ```
170
+ blockydoge/ii/
171
+ 000001.png
172
+ 000002.png
173
+ 000003.png
174
+ 000004.png
175
+ 000005.png
176
+ 000006.png
177
+ 000007.png
178
+ 000008.png
179
+ 000009.png
180
+ 000010.png
181
+ 000011.png
182
+ 000012.png
183
+ 000013.png
184
+ ...
185
+ ```
186
+
187
+
188
+ Example - `blockydoge/ii/000001.png` to `000013.png` (60x60):
189
+
190
+ ![](i/blockydoge000001.png)
191
+ ![](i/blockydoge000002.png)
192
+ ![](i/blockydoge000003.png)
193
+ ![](i/blockydoge000004.png)
194
+ ![](i/blockydoge000005.png)
195
+ ![](i/blockydoge000006.png)
196
+ ![](i/blockydoge000007.png)
197
+ ![](i/blockydoge000008.png)
198
+ ![](i/blockydoge000009.png)
199
+ ![](i/blockydoge000010.png)
200
+ ![](i/blockydoge000011.png)
201
+ ![](i/blockydoge000012.png)
202
+ ![](i/blockydoge000013.png)
203
+
204
+
205
+
206
+
207
+ ### Generate an all-in-one composite with the pixelated images
208
+
209
+ Let's try:
210
+
211
+ ```
212
+ $ artbase blockydoge composite
213
+ ```
214
+
215
+ Note: The all-in-one composite image gets saved by convention to `blockydoge/tmp/blockydoge-60x60.png`. Example:
216
+
217
+ ![](i/blockydoge-60x60.png)
218
+
219
+
220
+
221
+ ### Export all meta data attributes / traits to an all-in-one datafile in the comma-separated-values (.csv) format
222
+
223
+
224
+ Let's try:
225
+
226
+ ```
227
+ $ artbase blockydoge export
228
+ ```
229
+
230
+ Note: The all-in-one datafile gets saved by convention to `blockydoge/tmp/blockydoge.csv`.
231
+ Example:
232
+
233
+
234
+ ```
235
+ ID, Name, Fur, Hat, Expression, Glasses, Accessories, Mask, Collar
236
+ 0, Blocky Doge #1, Red Fur, Pink Party Hat, Smiley, , , ,
237
+ 1, Blocky Doge #2, Black and Tan Fur, Orange Cap, Tongue Out, , , ,
238
+ 2, Blocky Doge #3, , , Cream Fur, Teal Glasses, , ,
239
+ 3, Blocky Doge #4, Meme Fur, , , Maroon Glasses, , ,
240
+ 4, Blocky Doge #5, Black and Tan Fur, Blue Party Hat, , , , ,
241
+ 5, Blocky Doge #6, Red Fur, Pink Cap, , , , ,
242
+ 6, Blocky Doge #7, Red Fur, , , , None, ,
243
+ 7, Blocky Doge #8, Meme Fur, White Cap, , , , ,
244
+ 8, Blocky Doge #9, Cream Fur, , , Sunglasses, , ,
245
+ 9, Blocky Doge #10, Meme Fur, , , , , Lavender Mask,
246
+ 10, Blocky Doge #11, Black and Tan Fur, , , Black Glasses, , ,
247
+ 11, Blocky Doge #12, Black and Tan Fur, , , , , Salmon Mask,
248
+ 12, Blocky Doge #13, Cream Fur, Green Party Hat, , , , ,
249
+ ...
250
+ ```
251
+
252
+
253
+
254
+
255
+ That's it for now.
256
+
257
+
258
+
259
+ ## Install
260
+
261
+ Just install the gem:
262
+
263
+ $ gem install artbase
264
+
265
+
266
+ ## License
267
+
268
+ The `artbase` scripts are dedicated to the public domain.
269
+ Use it as you please with no restrictions whatsoever.
270
+
271
+
272
+ ## Questions? Comments?
273
+
274
+ Post them on the [CryptoPunksDev reddit](https://old.reddit.com/r/CryptoPunksDev). Thanks.
data/Rakefile CHANGED
@@ -1,29 +1,38 @@
1
- require 'hoe'
2
- require './lib/artbase/version.rb'
3
-
4
- Hoe.spec 'artbase' do
5
-
6
- self.version = Artbase::VERSION
7
-
8
- self.summary = "artbase"
9
- self.description = summary
10
-
11
- self.urls = { home: 'https://github.com/pixelartexchange/artbase'}
12
-
13
- self.author = 'Gerald Bauer'
14
- self.email = 'wwwmake@googlegroups.com'
15
-
16
- # switch extension to .markdown for gihub formatting
17
- self.readme_file = 'README.md'
18
- self.history_file = 'CHANGELOG.md'
19
-
20
- self.extra_deps = [
21
- ]
22
-
23
- self.licenses = ['Public Domain']
24
-
25
- self.spec_extras = {
26
- required_ruby_version: '>= 2.2.2'
27
- }
28
-
29
- end
1
+ require 'hoe'
2
+ require './lib/artbase/version.rb'
3
+
4
+
5
+ ###
6
+ # hack/ quick fix for broken intuit_values - overwrite with dummy
7
+ class Hoe
8
+ def intuit_values( input ); end
9
+ end
10
+
11
+
12
+ Hoe.spec 'artbase' do
13
+
14
+ self.version = Artbase::VERSION
15
+
16
+ self.summary = "artbase"
17
+ self.description = summary
18
+
19
+ self.urls = { home: 'https://github.com/pixelartexchange/artbase'}
20
+
21
+ self.author = 'Gerald Bauer'
22
+ self.email = 'wwwmake@googlegroups.com'
23
+
24
+ # switch extension to .markdown for gihub formatting
25
+ self.readme_file = 'README.md'
26
+ self.history_file = 'CHANGELOG.md'
27
+
28
+ self.extra_deps = [
29
+ ['webclient', '>= 0.2.2'],
30
+ ]
31
+
32
+ self.licenses = ['Public Domain']
33
+
34
+ self.spec_extras = {
35
+ required_ruby_version: '>= 2.2.2'
36
+ }
37
+
38
+ end
data/bin/artbase CHANGED
@@ -1,17 +1,17 @@
1
- #!/usr/bin/env ruby
2
-
3
- ###################
4
- # == DEV TIPS:
5
- #
6
- # For local testing run like:
7
- #
8
- # ruby -Ilib bin/artbase
9
- #
10
- # Set the executable bit in Linux. Example:
11
- #
12
- # % chmod a+x bin/artbase
13
- #
14
-
15
- require 'artbase'
16
-
17
- Artbase::Tool.main
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # == DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/artbase
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/artbase
13
+ #
14
+
15
+ require 'artbase'
16
+
17
+ Artbase::Tool.main
@@ -1,83 +1,83 @@
1
-
2
-
3
- def counter_to_text( counter )
4
-
5
- counter = counter.to_a
6
-
7
- attribute_counter = counter[0]
8
- more_counter = counter[1..-1]
9
-
10
-
11
- puts "Attribute Counts\n"
12
- trait_type, h = attribute_counter
13
-
14
- total = h[:by_type].values.reduce(0) { |sum,count| sum+count }
15
-
16
-
17
- types = h[:by_type]
18
- types = types.sort { |l,r| l[0]<=>r[0] } ## sort by name
19
-
20
- puts "\n"
21
- puts "|Name|Total (%)|"
22
- puts "|--------|----------:|"
23
-
24
- types.each do |rec|
25
- name = rec[0]
26
- count = rec[1]
27
- percent = Float(count*100)/Float(total)
28
-
29
- puts "| **#{name} Attributes** | #{count} (#{'%.2f' % percent}) |"
30
- end
31
- puts "\n"
32
-
33
- more_counter.each_with_index do |(trait_type, h),i|
34
- print " · " if i > 0 ## add separator
35
- print "#{trait_type } (#{h[:by_type].size})"
36
- end
37
- puts "\n\n"
38
-
39
-
40
-
41
- more_counter.each do |trait_type, h|
42
- print "### #{trait_type } (#{h[:by_type].size}) - "
43
- print "∑Total #{h[:count]}/#{total}\n"
44
-
45
- puts "\n"
46
- puts "|Name|Total (%)|"
47
- puts "|--------|----------:|"
48
-
49
- types = h[:by_type]
50
- types = types.sort do |l,r|
51
- # sort by 1) by count
52
- # 2) by name a-z
53
- res = r[1] <=> l[1]
54
- res = l[0] <=> r[0] if res == 0
55
- res
56
- end ## sort by count
57
- types.each do |rec|
58
- name = rec[0]
59
- count = rec[1]
60
- percent = Float(count*100)/Float(total)
61
-
62
- puts "| **#{name}** | #{count} (#{'%.2f' % percent}) |"
63
- end
64
- puts "\n\n"
65
- end
66
- end
67
-
68
-
69
-
70
-
71
- def counter_to_csv( counter )
72
-
73
- puts "type, name, count"
74
- counter.each do |trait_type, h|
75
- puts "#{trait_type}, ∑ Total, #{h[:count]}"
76
- h[:by_type].each do |trait_value, count|
77
- puts "#{trait_type}, #{trait_value}, #{count}"
78
- end
79
- end
80
- end
81
-
82
-
83
-
1
+
2
+
3
+ def counter_to_text( counter )
4
+
5
+ counter = counter.to_a
6
+
7
+ attribute_counter = counter[0]
8
+ more_counter = counter[1..-1]
9
+
10
+
11
+ puts "Attribute Counts\n"
12
+ trait_type, h = attribute_counter
13
+
14
+ total = h[:by_type].values.reduce(0) { |sum,count| sum+count }
15
+
16
+
17
+ types = h[:by_type]
18
+ types = types.sort { |l,r| l[0]<=>r[0] } ## sort by name
19
+
20
+ puts "\n"
21
+ puts "|Name|Total (%)|"
22
+ puts "|--------|----------:|"
23
+
24
+ types.each do |rec|
25
+ name = rec[0]
26
+ count = rec[1]
27
+ percent = Float(count*100)/Float(total)
28
+
29
+ puts "| **#{name} Attributes** | #{count} (#{'%.2f' % percent}) |"
30
+ end
31
+ puts "\n"
32
+
33
+ more_counter.each_with_index do |(trait_type, h),i|
34
+ print " · " if i > 0 ## add separator
35
+ print "#{trait_type } (#{h[:by_type].size})"
36
+ end
37
+ puts "\n\n"
38
+
39
+
40
+
41
+ more_counter.each do |trait_type, h|
42
+ print "### #{trait_type } (#{h[:by_type].size}) - "
43
+ print "∑Total #{h[:count]}/#{total}\n"
44
+
45
+ puts "\n"
46
+ puts "|Name|Total (%)|"
47
+ puts "|--------|----------:|"
48
+
49
+ types = h[:by_type]
50
+ types = types.sort do |l,r|
51
+ # sort by 1) by count
52
+ # 2) by name a-z
53
+ res = r[1] <=> l[1]
54
+ res = l[0] <=> r[0] if res == 0
55
+ res
56
+ end ## sort by count
57
+ types.each do |rec|
58
+ name = rec[0]
59
+ count = rec[1]
60
+ percent = Float(count*100)/Float(total)
61
+
62
+ puts "| **#{name}** | #{count} (#{'%.2f' % percent}) |"
63
+ end
64
+ puts "\n\n"
65
+ end
66
+ end
67
+
68
+
69
+
70
+
71
+ def counter_to_csv( counter )
72
+
73
+ puts "type, name, count"
74
+ counter.each do |trait_type, h|
75
+ puts "#{trait_type}, ∑ Total, #{h[:count]}"
76
+ h[:by_type].each do |trait_value, count|
77
+ puts "#{trait_type}, #{trait_value}, #{count}"
78
+ end
79
+ end
80
+ end
81
+
82
+
83
+