nblog_duo 111.115.779 → 111.117.779
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/lib/nblog_duo.rb +125 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7df465618acef3ede01210a3696d49385eae583b85fbfd92995e4f31dc3abc1a
|
4
|
+
data.tar.gz: 55b9603a4eb26e2ddfc0e3329ad3ebbd951ba3093cc019720c5258064675b141
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26530cd3df068bb3a34c107ec5fa2e333d1afb6693ae9367ab3cf2a30f059a075672d378f94fb6d759cfa3c31e5e65457238e3895900124a6d97b21bc3eeea05
|
7
|
+
data.tar.gz: f856b2d6def37833efbf52f234a5507642b9304308819a5a5059c62128d478d02394947f1bea3bf6cfc7073fb192bac555e12d24a70b0fad55ae9d20151531fb
|
data/lib/nblog_duo.rb
CHANGED
@@ -17,6 +17,7 @@ require 'cgi'
|
|
17
17
|
require 'digest'
|
18
18
|
require 'auto_click'
|
19
19
|
require 'rainbow/refinement'
|
20
|
+
require 'httpclient'
|
20
21
|
include AutoClickMethods
|
21
22
|
using Rainbow
|
22
23
|
include Glimmer
|
@@ -2222,21 +2223,81 @@ class Wordpress
|
|
2222
2223
|
return @data2
|
2223
2224
|
end
|
2224
2225
|
|
2225
|
-
|
2226
|
+
def auto_image(keyword = nil)
|
2227
|
+
keyword ||= @keyword
|
2228
|
+
puts "키워드: #{keyword}"
|
2229
|
+
|
2230
|
+
client = HTTPClient.new
|
2231
|
+
client.default_header = {
|
2232
|
+
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '\
|
2233
|
+
'(KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
|
2234
|
+
'Accept' => 'application/json, text/javascript, */*; q=0.01',
|
2235
|
+
'Accept-Language' => 'en-US,en;q=0.9',
|
2236
|
+
'Referer' => "https://unsplash.com/s/photos/#{URI.encode_www_form_component(keyword)}",
|
2237
|
+
'X-Requested-With' => 'XMLHttpRequest'
|
2238
|
+
}
|
2239
|
+
|
2240
|
+
retry_count = 0
|
2241
|
+
max_retries = 10
|
2242
|
+
results = []
|
2243
|
+
|
2226
2244
|
begin
|
2227
2245
|
page = rand(1..15)
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2246
|
+
url = "https://unsplash.com/napi/search/photos?query=#{URI.encode_www_form_component(keyword)}&page=#{page}&per_page=20"
|
2247
|
+
puts "Request URL: #{url}"
|
2248
|
+
res = client.get(url)
|
2249
|
+
|
2250
|
+
unless res.status == 200
|
2251
|
+
puts "HTTP Error: #{res.status}"
|
2252
|
+
raise "HTTP Error"
|
2233
2253
|
end
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2254
|
+
|
2255
|
+
json = JSON.parse(res.body)
|
2256
|
+
results = json['results']
|
2257
|
+
mm = []
|
2258
|
+
|
2259
|
+
results.each do |photo|
|
2260
|
+
full_url = photo.dig('urls', 'full').to_s
|
2261
|
+
regular_url = photo.dig('urls', 'regular').to_s
|
2262
|
+
|
2263
|
+
if full_url.start_with?("https://images.unsplash.com/photo-") &&
|
2264
|
+
regular_url.include?("1080")
|
2265
|
+
mm << full_url
|
2266
|
+
end
|
2267
|
+
end
|
2268
|
+
|
2269
|
+
if mm.empty?
|
2270
|
+
raise "No matching image"
|
2271
|
+
end
|
2272
|
+
|
2273
|
+
selected_url = mm.sample
|
2274
|
+
Down.download(selected_url, destination: "./image/memory.png")
|
2275
|
+
puts "이미지 다운로드 완료: #{selected_url}"
|
2276
|
+
|
2277
|
+
rescue => e
|
2278
|
+
retry_count += 1
|
2279
|
+
puts "auto_image 에러: #{e.message} (재시도 #{retry_count}/#{max_retries})"
|
2280
|
+
sleep(3)
|
2281
|
+
if retry_count < max_retries
|
2239
2282
|
retry
|
2283
|
+
else
|
2284
|
+
puts "최대 재시도 초과. 조건 무시하고 랜덤 이미지 다운로드 시도..."
|
2285
|
+
|
2286
|
+
if results && !results.empty?
|
2287
|
+
random_photo = results.sample
|
2288
|
+
fallback_url = random_photo.dig('urls', 'full')
|
2289
|
+
if fallback_url
|
2290
|
+
Down.download(fallback_url, destination: "./image/memory.png")
|
2291
|
+
puts "랜덤 이미지 다운로드 완료: #{fallback_url}"
|
2292
|
+
else
|
2293
|
+
puts "랜덤 이미지 URL을 찾을 수 없습니다. 단색 배경 이미지 생성합니다."
|
2294
|
+
color_image
|
2295
|
+
end
|
2296
|
+
else
|
2297
|
+
puts "이미지 결과가 없어 다운로드할 수 없습니다. 단색 배경 이미지 생성합니다."
|
2298
|
+
color_image
|
2299
|
+
end
|
2300
|
+
end
|
2240
2301
|
end
|
2241
2302
|
end
|
2242
2303
|
|
@@ -2393,18 +2454,40 @@ class Wordpress
|
|
2393
2454
|
image_filter()
|
2394
2455
|
end
|
2395
2456
|
|
2396
|
-
insert_image_text1 = ''
|
2397
|
-
insert_image_text2 = ''
|
2398
2457
|
if @data['이미지설정']['글자삽입1'].checked?
|
2399
|
-
|
2458
|
+
if @data['이미지설정']['이미지글자1'].length == 0
|
2459
|
+
image_text_path1 = ''
|
2460
|
+
else
|
2461
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2462
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'].sample
|
2463
|
+
else
|
2464
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'][@image_text_soon1]
|
2465
|
+
@image_text_soon1 += 1
|
2466
|
+
if @image_text_soon1 > @data['이미지설정']['이미지글자1'].length - 1
|
2467
|
+
@image_text_soon1 = 0
|
2468
|
+
end
|
2469
|
+
end
|
2470
|
+
end
|
2400
2471
|
end
|
2401
2472
|
|
2402
2473
|
if @data['이미지설정']['글자삽입2'].checked?
|
2403
|
-
|
2474
|
+
if @data['이미지설정']['이미지글자2'].length == 0
|
2475
|
+
image_text_path2 = ''
|
2476
|
+
else
|
2477
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2478
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'].sample
|
2479
|
+
else
|
2480
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'][@image_text_soon2]
|
2481
|
+
@image_text_soon2 += 1
|
2482
|
+
if @image_text_soon2 > @data['이미지설정']['이미지글자2'].length - 1
|
2483
|
+
@image_text_soon2 = 0
|
2484
|
+
end
|
2485
|
+
end
|
2486
|
+
end
|
2404
2487
|
end
|
2405
|
-
|
2488
|
+
|
2406
2489
|
if @data['이미지설정']['글자삽입1'].checked? or @data['이미지설정']['글자삽입2'].checked?
|
2407
|
-
image_text(
|
2490
|
+
image_text(image_text_path1, image_text_path2)
|
2408
2491
|
end
|
2409
2492
|
|
2410
2493
|
if @data['이미지설정']['테두리사용'].checked?
|
@@ -2468,6 +2551,8 @@ class Wordpress
|
|
2468
2551
|
title_soon = 0
|
2469
2552
|
keyword_soon = 0
|
2470
2553
|
content_soon = 0
|
2554
|
+
@image_text_soon1 = 0
|
2555
|
+
@image_text_soon2 = 0
|
2471
2556
|
@my_ip = 'init'
|
2472
2557
|
@image_counter = 0
|
2473
2558
|
@inumber2 = 0
|
@@ -4842,9 +4927,30 @@ class Wordpress
|
|
4842
4927
|
top 1
|
4843
4928
|
left 6
|
4844
4929
|
}
|
4845
|
-
@data['이미지설정']['
|
4930
|
+
@data['이미지설정']['글자순서'] = checkbox('글자 리스트 순서대로 사용'){
|
4846
4931
|
top 2
|
4847
4932
|
left 0
|
4933
|
+
on_toggled{
|
4934
|
+
if @data['이미지설정']['글자순서'].checked?
|
4935
|
+
@data['이미지설정']['글자랜덤'].checked = false
|
4936
|
+
end
|
4937
|
+
}
|
4938
|
+
}
|
4939
|
+
|
4940
|
+
@data['이미지설정']['글자랜덤'] = checkbox('글자 리스트 랜덤으로 사용'){
|
4941
|
+
top 2
|
4942
|
+
left 1
|
4943
|
+
on_toggled{
|
4944
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
4945
|
+
@data['이미지설정']['글자순서'].checked = false
|
4946
|
+
end
|
4947
|
+
}
|
4948
|
+
}
|
4949
|
+
|
4950
|
+
|
4951
|
+
@data['이미지설정']['필터사용'] = checkbox('필터사용(색상 사진 적용불가)'){
|
4952
|
+
top 2
|
4953
|
+
left 2
|
4848
4954
|
}
|
4849
4955
|
@data['이미지설정']['테두리사용'] = checkbox('테두리 사용'){
|
4850
4956
|
top 3
|
@@ -5853,6 +5959,7 @@ class Wordpress
|
|
5853
5959
|
@data['포스트설정']['공감허용'].checked = true
|
5854
5960
|
@data['포스트설정']['발행기능'].checked = true
|
5855
5961
|
@data['포스트설정']['인용구랜덤'].checked = true
|
5962
|
+
@data['이미지설정']['글자순서'].checked = true
|
5856
5963
|
}.show
|
5857
5964
|
end
|
5858
5965
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nblog_duo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 111.
|
4
|
+
version: 111.117.779
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-05-
|
10
|
+
date: 2025-05-23 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: File to Clipboard gem
|
13
13
|
email: mymin26@naver.com
|