cafe_basics_duo 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_basics_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: 0ea656b168468dcf680e00ba06a615aca79d3e3748eb33cfa1bee9f90923c29d
|
4
|
+
data.tar.gz: 6f892b0c8c816bb68af4ffd3aac73f04327c8934d90af79cd77cda7e67718b44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b30ffce6f681d19d52e248866ac695f991f7e39d130dfb329c9d88cc731f23b879a9d99929a8c53675abce0f14f1f9000efacd6a35cb046973dad4030055ae7b
|
7
|
+
data.tar.gz: 27490fd24522ec64ffb0a47c8cbab371c172ed272764e5ac959e1b743c49574b72ddcc5418e29e3789cc6623d9be6d36d4232637a2e6aa85104fa6cce7f6d879
|
data/lib/cafe_basics_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
|
@@ -2031,21 +2032,81 @@ class Wordpress
|
|
2031
2032
|
|
2032
2033
|
|
2033
2034
|
|
2034
|
-
def auto_image
|
2035
|
+
def auto_image(keyword = nil)
|
2036
|
+
keyword ||= @keyword
|
2037
|
+
puts "키워드: #{keyword}"
|
2038
|
+
|
2039
|
+
client = HTTPClient.new
|
2040
|
+
client.default_header = {
|
2041
|
+
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '\
|
2042
|
+
'(KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
|
2043
|
+
'Accept' => 'application/json, text/javascript, */*; q=0.01',
|
2044
|
+
'Accept-Language' => 'en-US,en;q=0.9',
|
2045
|
+
'Referer' => "https://unsplash.com/s/photos/#{URI.encode_www_form_component(keyword)}",
|
2046
|
+
'X-Requested-With' => 'XMLHttpRequest'
|
2047
|
+
}
|
2048
|
+
|
2049
|
+
retry_count = 0
|
2050
|
+
max_retries = 10
|
2051
|
+
results = []
|
2052
|
+
|
2035
2053
|
begin
|
2036
2054
|
page = rand(1..15)
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2055
|
+
url = "https://unsplash.com/napi/search/photos?query=#{URI.encode_www_form_component(keyword)}&page=#{page}&per_page=20"
|
2056
|
+
puts "Request URL: #{url}"
|
2057
|
+
res = client.get(url)
|
2058
|
+
|
2059
|
+
unless res.status == 200
|
2060
|
+
puts "HTTP Error: #{res.status}"
|
2061
|
+
raise "HTTP Error"
|
2042
2062
|
end
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2063
|
+
|
2064
|
+
json = JSON.parse(res.body)
|
2065
|
+
results = json['results']
|
2066
|
+
mm = []
|
2067
|
+
|
2068
|
+
results.each do |photo|
|
2069
|
+
full_url = photo.dig('urls', 'full').to_s
|
2070
|
+
regular_url = photo.dig('urls', 'regular').to_s
|
2071
|
+
|
2072
|
+
if full_url.start_with?("https://images.unsplash.com/photo-") &&
|
2073
|
+
regular_url.include?("1080")
|
2074
|
+
mm << full_url
|
2075
|
+
end
|
2076
|
+
end
|
2077
|
+
|
2078
|
+
if mm.empty?
|
2079
|
+
raise "No matching image"
|
2080
|
+
end
|
2081
|
+
|
2082
|
+
selected_url = mm.sample
|
2083
|
+
Down.download(selected_url, destination: "./image/memory.png")
|
2084
|
+
puts "이미지 다운로드 완료: #{selected_url}"
|
2085
|
+
|
2086
|
+
rescue => e
|
2087
|
+
retry_count += 1
|
2088
|
+
puts "auto_image 에러: #{e.message} (재시도 #{retry_count}/#{max_retries})"
|
2089
|
+
sleep(3)
|
2090
|
+
if retry_count < max_retries
|
2048
2091
|
retry
|
2092
|
+
else
|
2093
|
+
puts "최대 재시도 초과. 조건 무시하고 랜덤 이미지 다운로드 시도..."
|
2094
|
+
|
2095
|
+
if results && !results.empty?
|
2096
|
+
random_photo = results.sample
|
2097
|
+
fallback_url = random_photo.dig('urls', 'full')
|
2098
|
+
if fallback_url
|
2099
|
+
Down.download(fallback_url, destination: "./image/memory.png")
|
2100
|
+
puts "랜덤 이미지 다운로드 완료: #{fallback_url}"
|
2101
|
+
else
|
2102
|
+
puts "랜덤 이미지 URL을 찾을 수 없습니다. 단색 배경 이미지 생성합니다."
|
2103
|
+
color_image
|
2104
|
+
end
|
2105
|
+
else
|
2106
|
+
puts "이미지 결과가 없어 다운로드할 수 없습니다. 단색 배경 이미지 생성합니다."
|
2107
|
+
color_image
|
2108
|
+
end
|
2109
|
+
end
|
2049
2110
|
end
|
2050
2111
|
end
|
2051
2112
|
|
@@ -2185,18 +2246,40 @@ class Wordpress
|
|
2185
2246
|
image_filter()
|
2186
2247
|
end
|
2187
2248
|
|
2188
|
-
insert_image_text1 = ''
|
2189
|
-
insert_image_text2 = ''
|
2190
2249
|
if @data['이미지설정']['글자삽입1'].checked?
|
2191
|
-
|
2250
|
+
if @data['이미지설정']['이미지글자1'].length == 0
|
2251
|
+
image_text_path1 = ''
|
2252
|
+
else
|
2253
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2254
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'].sample
|
2255
|
+
else
|
2256
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'][@image_text_soon1]
|
2257
|
+
@image_text_soon1 += 1
|
2258
|
+
if @image_text_soon1 > @data['이미지설정']['이미지글자1'].length - 1
|
2259
|
+
@image_text_soon1 = 0
|
2260
|
+
end
|
2261
|
+
end
|
2262
|
+
end
|
2192
2263
|
end
|
2193
2264
|
|
2194
2265
|
if @data['이미지설정']['글자삽입2'].checked?
|
2195
|
-
|
2266
|
+
if @data['이미지설정']['이미지글자2'].length == 0
|
2267
|
+
image_text_path2 = ''
|
2268
|
+
else
|
2269
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2270
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'].sample
|
2271
|
+
else
|
2272
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'][@image_text_soon2]
|
2273
|
+
@image_text_soon2 += 1
|
2274
|
+
if @image_text_soon2 > @data['이미지설정']['이미지글자2'].length - 1
|
2275
|
+
@image_text_soon2 = 0
|
2276
|
+
end
|
2277
|
+
end
|
2278
|
+
end
|
2196
2279
|
end
|
2197
|
-
|
2280
|
+
|
2198
2281
|
if @data['이미지설정']['글자삽입1'].checked? or @data['이미지설정']['글자삽입2'].checked?
|
2199
|
-
image_text(
|
2282
|
+
image_text(image_text_path1, image_text_path2)
|
2200
2283
|
end
|
2201
2284
|
|
2202
2285
|
if @data['이미지설정']['테두리사용'].checked?
|
@@ -2260,6 +2343,8 @@ class Wordpress
|
|
2260
2343
|
title_soon = 0
|
2261
2344
|
keyword_soon = 0
|
2262
2345
|
content_soon = 0
|
2346
|
+
@image_text_soon1 = 0
|
2347
|
+
@image_text_soon2 = 0
|
2263
2348
|
@my_ip = 'init'
|
2264
2349
|
@image_counter = 0
|
2265
2350
|
@inumber2 = 0
|
@@ -4500,9 +4585,30 @@ class Wordpress
|
|
4500
4585
|
top 1
|
4501
4586
|
left 6
|
4502
4587
|
}
|
4503
|
-
@data['이미지설정']['
|
4588
|
+
@data['이미지설정']['글자순서'] = checkbox('글자 리스트 순서대로 사용'){
|
4504
4589
|
top 2
|
4505
4590
|
left 0
|
4591
|
+
on_toggled{
|
4592
|
+
if @data['이미지설정']['글자순서'].checked?
|
4593
|
+
@data['이미지설정']['글자랜덤'].checked = false
|
4594
|
+
end
|
4595
|
+
}
|
4596
|
+
}
|
4597
|
+
|
4598
|
+
@data['이미지설정']['글자랜덤'] = checkbox('글자 리스트 랜덤으로 사용'){
|
4599
|
+
top 2
|
4600
|
+
left 1
|
4601
|
+
on_toggled{
|
4602
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
4603
|
+
@data['이미지설정']['글자순서'].checked = false
|
4604
|
+
end
|
4605
|
+
}
|
4606
|
+
}
|
4607
|
+
|
4608
|
+
|
4609
|
+
@data['이미지설정']['필터사용'] = checkbox('필터사용(색상 사진 적용불가)'){
|
4610
|
+
top 2
|
4611
|
+
left 2
|
4506
4612
|
}
|
4507
4613
|
@data['이미지설정']['테두리사용'] = checkbox('테두리 사용'){
|
4508
4614
|
top 3
|
@@ -5413,6 +5519,7 @@ class Wordpress
|
|
5413
5519
|
@data['포스트설정']['자동출처 사용'].checked = false
|
5414
5520
|
@data['포스트설정']['CCL사용'].checked = false
|
5415
5521
|
@data['포스트설정']['인용구랜덤'].checked = true
|
5522
|
+
@data['이미지설정']['글자순서'].checked = true
|
5416
5523
|
}.show
|
5417
5524
|
end
|
5418
5525
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cafe_basics_duo
|
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
|