cafe_buy 0.1.35 → 0.1.37
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/cafe_buy.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: 48247ce4be293f453c3d548a3653864df11aec18303eabce8fa67671fe5ab05d
|
4
|
+
data.tar.gz: ac807bc3fec65e439fb12d29f8dcc53eca7db615834566cbf774a3338103acf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe08f4b9609b95125e38cf89b6beeb173e4369ef70757abc2e3e2f5c74beda009908ea0d746fc74ae3a817a80f51d63e2a85f16cada2897a2d2217ddf7c7e235
|
7
|
+
data.tar.gz: 17cf01f9cdeab1d013c7357d693c4718081de74455ad2bcde19b71caa966b112e89e8b554ea7c7b0ba876f4ec15e3e7b7c8ba09c521cc096a00df254b2cdc20b
|
data/lib/cafe_buy.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
|
@@ -2301,21 +2302,81 @@ class Wordpress
|
|
2301
2302
|
|
2302
2303
|
|
2303
2304
|
|
2304
|
-
def auto_image
|
2305
|
+
def auto_image(keyword = nil)
|
2306
|
+
keyword ||= @keyword
|
2307
|
+
puts "키워드: #{keyword}"
|
2308
|
+
|
2309
|
+
client = HTTPClient.new
|
2310
|
+
client.default_header = {
|
2311
|
+
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '\
|
2312
|
+
'(KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
|
2313
|
+
'Accept' => 'application/json, text/javascript, */*; q=0.01',
|
2314
|
+
'Accept-Language' => 'en-US,en;q=0.9',
|
2315
|
+
'Referer' => "https://unsplash.com/s/photos/#{URI.encode_www_form_component(keyword)}",
|
2316
|
+
'X-Requested-With' => 'XMLHttpRequest'
|
2317
|
+
}
|
2318
|
+
|
2319
|
+
retry_count = 0
|
2320
|
+
max_retries = 10
|
2321
|
+
results = []
|
2322
|
+
|
2305
2323
|
begin
|
2306
2324
|
page = rand(1..15)
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2325
|
+
url = "https://unsplash.com/napi/search/photos?query=#{URI.encode_www_form_component(keyword)}&page=#{page}&per_page=20"
|
2326
|
+
puts "Request URL: #{url}"
|
2327
|
+
res = client.get(url)
|
2328
|
+
|
2329
|
+
unless res.status == 200
|
2330
|
+
puts "HTTP Error: #{res.status}"
|
2331
|
+
raise "HTTP Error"
|
2312
2332
|
end
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2333
|
+
|
2334
|
+
json = JSON.parse(res.body)
|
2335
|
+
results = json['results']
|
2336
|
+
mm = []
|
2337
|
+
|
2338
|
+
results.each do |photo|
|
2339
|
+
full_url = photo.dig('urls', 'full').to_s
|
2340
|
+
regular_url = photo.dig('urls', 'regular').to_s
|
2341
|
+
|
2342
|
+
if full_url.start_with?("https://images.unsplash.com/photo-") &&
|
2343
|
+
regular_url.include?("1080")
|
2344
|
+
mm << full_url
|
2345
|
+
end
|
2346
|
+
end
|
2347
|
+
|
2348
|
+
if mm.empty?
|
2349
|
+
raise "No matching image"
|
2350
|
+
end
|
2351
|
+
|
2352
|
+
selected_url = mm.sample
|
2353
|
+
Down.download(selected_url, destination: "./image/memory.png")
|
2354
|
+
puts "이미지 다운로드 완료: #{selected_url}"
|
2355
|
+
|
2356
|
+
rescue => e
|
2357
|
+
retry_count += 1
|
2358
|
+
puts "auto_image 에러: #{e.message} (재시도 #{retry_count}/#{max_retries})"
|
2359
|
+
sleep(3)
|
2360
|
+
if retry_count < max_retries
|
2318
2361
|
retry
|
2362
|
+
else
|
2363
|
+
puts "최대 재시도 초과. 조건 무시하고 랜덤 이미지 다운로드 시도..."
|
2364
|
+
|
2365
|
+
if results && !results.empty?
|
2366
|
+
random_photo = results.sample
|
2367
|
+
fallback_url = random_photo.dig('urls', 'full')
|
2368
|
+
if fallback_url
|
2369
|
+
Down.download(fallback_url, destination: "./image/memory.png")
|
2370
|
+
puts "랜덤 이미지 다운로드 완료: #{fallback_url}"
|
2371
|
+
else
|
2372
|
+
puts "랜덤 이미지 URL을 찾을 수 없습니다. 단색 배경 이미지 생성합니다."
|
2373
|
+
color_image
|
2374
|
+
end
|
2375
|
+
else
|
2376
|
+
puts "이미지 결과가 없어 다운로드할 수 없습니다. 단색 배경 이미지 생성합니다."
|
2377
|
+
color_image
|
2378
|
+
end
|
2379
|
+
end
|
2319
2380
|
end
|
2320
2381
|
end
|
2321
2382
|
|
@@ -2455,18 +2516,40 @@ class Wordpress
|
|
2455
2516
|
image_filter()
|
2456
2517
|
end
|
2457
2518
|
|
2458
|
-
insert_image_text1 = ''
|
2459
|
-
insert_image_text2 = ''
|
2460
2519
|
if @data['이미지설정']['글자삽입1'].checked?
|
2461
|
-
|
2520
|
+
if @data['이미지설정']['이미지글자1'].length == 0
|
2521
|
+
image_text_path1 = ''
|
2522
|
+
else
|
2523
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2524
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'].sample
|
2525
|
+
else
|
2526
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'][@image_text_soon1]
|
2527
|
+
@image_text_soon1 += 1
|
2528
|
+
if @image_text_soon1 > @data['이미지설정']['이미지글자1'].length - 1
|
2529
|
+
@image_text_soon1 = 0
|
2530
|
+
end
|
2531
|
+
end
|
2532
|
+
end
|
2462
2533
|
end
|
2463
2534
|
|
2464
2535
|
if @data['이미지설정']['글자삽입2'].checked?
|
2465
|
-
|
2536
|
+
if @data['이미지설정']['이미지글자2'].length == 0
|
2537
|
+
image_text_path2 = ''
|
2538
|
+
else
|
2539
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2540
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'].sample
|
2541
|
+
else
|
2542
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'][@image_text_soon2]
|
2543
|
+
@image_text_soon2 += 1
|
2544
|
+
if @image_text_soon2 > @data['이미지설정']['이미지글자2'].length - 1
|
2545
|
+
@image_text_soon2 = 0
|
2546
|
+
end
|
2547
|
+
end
|
2548
|
+
end
|
2466
2549
|
end
|
2467
|
-
|
2550
|
+
|
2468
2551
|
if @data['이미지설정']['글자삽입1'].checked? or @data['이미지설정']['글자삽입2'].checked?
|
2469
|
-
image_text(
|
2552
|
+
image_text(image_text_path1, image_text_path2)
|
2470
2553
|
end
|
2471
2554
|
|
2472
2555
|
if @data['이미지설정']['테두리사용'].checked?
|
@@ -2530,6 +2613,8 @@ class Wordpress
|
|
2530
2613
|
title_soon = 0
|
2531
2614
|
keyword_soon = 0
|
2532
2615
|
content_soon = 0
|
2616
|
+
@image_text_soon1 = 0
|
2617
|
+
@image_text_soon2 = 0
|
2533
2618
|
@my_ip = 'init'
|
2534
2619
|
@image_counter = 0
|
2535
2620
|
@inumber2 = 0
|
@@ -4811,9 +4896,30 @@ class Wordpress
|
|
4811
4896
|
top 1
|
4812
4897
|
left 6
|
4813
4898
|
}
|
4814
|
-
@data['이미지설정']['
|
4899
|
+
@data['이미지설정']['글자순서'] = checkbox('글자 리스트 순서대로 사용'){
|
4815
4900
|
top 2
|
4816
4901
|
left 0
|
4902
|
+
on_toggled{
|
4903
|
+
if @data['이미지설정']['글자순서'].checked?
|
4904
|
+
@data['이미지설정']['글자랜덤'].checked = false
|
4905
|
+
end
|
4906
|
+
}
|
4907
|
+
}
|
4908
|
+
|
4909
|
+
@data['이미지설정']['글자랜덤'] = checkbox('글자 리스트 랜덤으로 사용'){
|
4910
|
+
top 2
|
4911
|
+
left 1
|
4912
|
+
on_toggled{
|
4913
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
4914
|
+
@data['이미지설정']['글자순서'].checked = false
|
4915
|
+
end
|
4916
|
+
}
|
4917
|
+
}
|
4918
|
+
|
4919
|
+
|
4920
|
+
@data['이미지설정']['필터사용'] = checkbox('필터사용(색상 사진 적용불가)'){
|
4921
|
+
top 2
|
4922
|
+
left 2
|
4817
4923
|
}
|
4818
4924
|
@data['이미지설정']['테두리사용'] = checkbox('테두리 사용'){
|
4819
4925
|
top 3
|
@@ -5936,6 +6042,7 @@ class Wordpress
|
|
5936
6042
|
@data['포스트설정']['자동출처 사용'].checked = false
|
5937
6043
|
@data['포스트설정']['CCL사용'].checked = false
|
5938
6044
|
@data['포스트설정']['인용구랜덤'].checked = true
|
6045
|
+
@data['이미지설정']['글자순서'].checked = true
|
5939
6046
|
|
5940
6047
|
}.show
|
5941
6048
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cafe_buy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.37
|
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
|