cafe_basics 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.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: 56e8380865c93fed4f0e471b0fb5d7d20424052e54f3f11154598d80268d3b2b
|
4
|
+
data.tar.gz: a4cde618f660a0b07aa9e1223d67711d3b9f34704cb6d7f00d9033d5dda2b3f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d5750348d5784273487f9911c27c833538613ee4c85bc1e75e591af311c703347f557945cba197ef26783f377a4c0e0e89a5241c45b416e45b2dc22d154fcb7
|
7
|
+
data.tar.gz: 4a20d7f82b068c0ba7be293347175fb0c057429a32251825619fb77602229900a8ecfa7a7b478356934a9adf1d860e4bac4565c7bae0c3eb2f22162f54b81d6a
|
data/lib/cafe_basics.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
|
@@ -1964,21 +1965,81 @@ class Wordpress
|
|
1964
1965
|
|
1965
1966
|
|
1966
1967
|
|
1967
|
-
def auto_image
|
1968
|
+
def auto_image(keyword = nil)
|
1969
|
+
keyword ||= @keyword
|
1970
|
+
puts "키워드: #{keyword}"
|
1971
|
+
|
1972
|
+
client = HTTPClient.new
|
1973
|
+
client.default_header = {
|
1974
|
+
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '\
|
1975
|
+
'(KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
|
1976
|
+
'Accept' => 'application/json, text/javascript, */*; q=0.01',
|
1977
|
+
'Accept-Language' => 'en-US,en;q=0.9',
|
1978
|
+
'Referer' => "https://unsplash.com/s/photos/#{URI.encode_www_form_component(keyword)}",
|
1979
|
+
'X-Requested-With' => 'XMLHttpRequest'
|
1980
|
+
}
|
1981
|
+
|
1982
|
+
retry_count = 0
|
1983
|
+
max_retries = 10
|
1984
|
+
results = []
|
1985
|
+
|
1968
1986
|
begin
|
1969
1987
|
page = rand(1..15)
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1988
|
+
url = "https://unsplash.com/napi/search/photos?query=#{URI.encode_www_form_component(keyword)}&page=#{page}&per_page=20"
|
1989
|
+
puts "Request URL: #{url}"
|
1990
|
+
res = client.get(url)
|
1991
|
+
|
1992
|
+
unless res.status == 200
|
1993
|
+
puts "HTTP Error: #{res.status}"
|
1994
|
+
raise "HTTP Error"
|
1975
1995
|
end
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1996
|
+
|
1997
|
+
json = JSON.parse(res.body)
|
1998
|
+
results = json['results']
|
1999
|
+
mm = []
|
2000
|
+
|
2001
|
+
results.each do |photo|
|
2002
|
+
full_url = photo.dig('urls', 'full').to_s
|
2003
|
+
regular_url = photo.dig('urls', 'regular').to_s
|
2004
|
+
|
2005
|
+
if full_url.start_with?("https://images.unsplash.com/photo-") &&
|
2006
|
+
regular_url.include?("1080")
|
2007
|
+
mm << full_url
|
2008
|
+
end
|
2009
|
+
end
|
2010
|
+
|
2011
|
+
if mm.empty?
|
2012
|
+
raise "No matching image"
|
2013
|
+
end
|
2014
|
+
|
2015
|
+
selected_url = mm.sample
|
2016
|
+
Down.download(selected_url, destination: "./image/memory.png")
|
2017
|
+
puts "이미지 다운로드 완료: #{selected_url}"
|
2018
|
+
|
2019
|
+
rescue => e
|
2020
|
+
retry_count += 1
|
2021
|
+
puts "auto_image 에러: #{e.message} (재시도 #{retry_count}/#{max_retries})"
|
2022
|
+
sleep(3)
|
2023
|
+
if retry_count < max_retries
|
1981
2024
|
retry
|
2025
|
+
else
|
2026
|
+
puts "최대 재시도 초과. 조건 무시하고 랜덤 이미지 다운로드 시도..."
|
2027
|
+
|
2028
|
+
if results && !results.empty?
|
2029
|
+
random_photo = results.sample
|
2030
|
+
fallback_url = random_photo.dig('urls', 'full')
|
2031
|
+
if fallback_url
|
2032
|
+
Down.download(fallback_url, destination: "./image/memory.png")
|
2033
|
+
puts "랜덤 이미지 다운로드 완료: #{fallback_url}"
|
2034
|
+
else
|
2035
|
+
puts "랜덤 이미지 URL을 찾을 수 없습니다. 단색 배경 이미지 생성합니다."
|
2036
|
+
color_image
|
2037
|
+
end
|
2038
|
+
else
|
2039
|
+
puts "이미지 결과가 없어 다운로드할 수 없습니다. 단색 배경 이미지 생성합니다."
|
2040
|
+
color_image
|
2041
|
+
end
|
2042
|
+
end
|
1982
2043
|
end
|
1983
2044
|
end
|
1984
2045
|
|
@@ -2118,18 +2179,40 @@ class Wordpress
|
|
2118
2179
|
image_filter()
|
2119
2180
|
end
|
2120
2181
|
|
2121
|
-
insert_image_text1 = ''
|
2122
|
-
insert_image_text2 = ''
|
2123
2182
|
if @data['이미지설정']['글자삽입1'].checked?
|
2124
|
-
|
2183
|
+
if @data['이미지설정']['이미지글자1'].length == 0
|
2184
|
+
image_text_path1 = ''
|
2185
|
+
else
|
2186
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2187
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'].sample
|
2188
|
+
else
|
2189
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'][@image_text_soon1]
|
2190
|
+
@image_text_soon1 += 1
|
2191
|
+
if @image_text_soon1 > @data['이미지설정']['이미지글자1'].length - 1
|
2192
|
+
@image_text_soon1 = 0
|
2193
|
+
end
|
2194
|
+
end
|
2195
|
+
end
|
2125
2196
|
end
|
2126
2197
|
|
2127
2198
|
if @data['이미지설정']['글자삽입2'].checked?
|
2128
|
-
|
2199
|
+
if @data['이미지설정']['이미지글자2'].length == 0
|
2200
|
+
image_text_path2 = ''
|
2201
|
+
else
|
2202
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2203
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'].sample
|
2204
|
+
else
|
2205
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'][@image_text_soon2]
|
2206
|
+
@image_text_soon2 += 1
|
2207
|
+
if @image_text_soon2 > @data['이미지설정']['이미지글자2'].length - 1
|
2208
|
+
@image_text_soon2 = 0
|
2209
|
+
end
|
2210
|
+
end
|
2211
|
+
end
|
2129
2212
|
end
|
2130
|
-
|
2213
|
+
|
2131
2214
|
if @data['이미지설정']['글자삽입1'].checked? or @data['이미지설정']['글자삽입2'].checked?
|
2132
|
-
image_text(
|
2215
|
+
image_text(image_text_path1, image_text_path2)
|
2133
2216
|
end
|
2134
2217
|
|
2135
2218
|
if @data['이미지설정']['테두리사용'].checked?
|
@@ -2193,6 +2276,8 @@ class Wordpress
|
|
2193
2276
|
title_soon = 0
|
2194
2277
|
keyword_soon = 0
|
2195
2278
|
content_soon = 0
|
2279
|
+
@image_text_soon1 = 0
|
2280
|
+
@image_text_soon2 = 0
|
2196
2281
|
@my_ip = 'init'
|
2197
2282
|
@image_counter = 0
|
2198
2283
|
@inumber2 = 0
|
@@ -4427,9 +4512,30 @@ class Wordpress
|
|
4427
4512
|
top 1
|
4428
4513
|
left 6
|
4429
4514
|
}
|
4430
|
-
@data['이미지설정']['
|
4515
|
+
@data['이미지설정']['글자순서'] = checkbox('글자 리스트 순서대로 사용'){
|
4431
4516
|
top 2
|
4432
4517
|
left 0
|
4518
|
+
on_toggled{
|
4519
|
+
if @data['이미지설정']['글자순서'].checked?
|
4520
|
+
@data['이미지설정']['글자랜덤'].checked = false
|
4521
|
+
end
|
4522
|
+
}
|
4523
|
+
}
|
4524
|
+
|
4525
|
+
@data['이미지설정']['글자랜덤'] = checkbox('글자 리스트 랜덤으로 사용'){
|
4526
|
+
top 2
|
4527
|
+
left 1
|
4528
|
+
on_toggled{
|
4529
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
4530
|
+
@data['이미지설정']['글자순서'].checked = false
|
4531
|
+
end
|
4532
|
+
}
|
4533
|
+
}
|
4534
|
+
|
4535
|
+
|
4536
|
+
@data['이미지설정']['필터사용'] = checkbox('필터사용(색상 사진 적용불가)'){
|
4537
|
+
top 2
|
4538
|
+
left 2
|
4433
4539
|
}
|
4434
4540
|
@data['이미지설정']['테두리사용'] = checkbox('테두리 사용'){
|
4435
4541
|
top 3
|
@@ -5340,6 +5446,7 @@ class Wordpress
|
|
5340
5446
|
@data['포스트설정']['자동출처 사용'].checked = false
|
5341
5447
|
@data['포스트설정']['CCL사용'].checked = false
|
5342
5448
|
@data['포스트설정']['인용구랜덤'].checked = true
|
5449
|
+
@data['이미지설정']['글자순서'].checked = true
|
5343
5450
|
}.show
|
5344
5451
|
end
|
5345
5452
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cafe_basics
|
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
|