cafe_buy_duo 0.1.30 → 0.1.35
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_duo.rb +148 -64
- 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: 2f22d70ec27de58f57890da03c82c3a5e07aa6c6b9bfd999825752a79bd3e0d7
|
4
|
+
data.tar.gz: f6809689b474d58d6f2de67fc0e159594afe6d07c5baddb025e7c6352b7172a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57b3cda29bcbbb9aa907fc1efdb90a543868724f3c65efa4328ea05278962fea81a02db64a9553bece40a935c6ceb02570849ec4d4e851ff507a4ff198f21822
|
7
|
+
data.tar.gz: 4164121816e66bbbfa0bd863716df0ca1b7376cbe928bd5ee6a0808bba5d364cb3307b7876328210d9bcf40e4fda5bafbd5994dceec00719564184a58df2a83f
|
data/lib/cafe_buy_duo.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'glimmer-dsl-libui'
|
2
2
|
require 'selenium-webdriver'
|
3
|
-
require 'webdrivers'
|
3
|
+
#require 'webdrivers'
|
4
4
|
require 'iconv'
|
5
5
|
require 'nokogiri'
|
6
6
|
require 'http'
|
@@ -241,25 +241,6 @@ end
|
|
241
241
|
class Naver
|
242
242
|
def initialize
|
243
243
|
@seed = 1
|
244
|
-
|
245
|
-
begin
|
246
|
-
# 웹드라이버가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
|
247
|
-
Webdrivers.cache_time = 86_400 # 하루로 설정 (기본값: 86_400초)
|
248
|
-
Webdrivers.install_dir = "./" # 크롬드라이버를 수동으로 설치할 경로를 설정
|
249
|
-
|
250
|
-
# 크롬드라이버 자동 업데이트 시도
|
251
|
-
Webdrivers::Chromedriver.update
|
252
|
-
puts "chromedriver 자동 다운로드 성공"
|
253
|
-
rescue => e
|
254
|
-
puts "chromedriver 자동 다운로드 실패: #{e.message}"
|
255
|
-
puts "폴더내 크롬드라이버를 사용합니다."
|
256
|
-
puts "크롬드라이버가 오래된 경우 오류 발생될 수 있으며, 만일 오류 발생시 아래 지침을 따라주세요."
|
257
|
-
puts "1.크롬 업데이트 2.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일을 열어 드라이버를 교체하세요."
|
258
|
-
chromedriver_path = './chromedriver.exe' # 수동 경로를 인스턴스 변수로 설정
|
259
|
-
Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
|
260
|
-
end
|
261
|
-
|
262
|
-
|
263
244
|
end
|
264
245
|
|
265
246
|
|
@@ -281,6 +262,18 @@ class Naver
|
|
281
262
|
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
282
263
|
if proxy == ''
|
283
264
|
begin
|
265
|
+
begin
|
266
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
267
|
+
rescue => e
|
268
|
+
puts "chromedriver 버전 불일치!!"
|
269
|
+
puts "아래 지침을 따라주세요."
|
270
|
+
puts "1.프로그램 종료!"
|
271
|
+
puts "2.크롬 업데이트!"
|
272
|
+
puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
|
273
|
+
puts "4.안내된 방식으로 크롬 드라이버 교체"
|
274
|
+
puts "5.재 시작"
|
275
|
+
exit 1
|
276
|
+
end
|
284
277
|
options = Selenium::WebDriver::Chrome::Options.new
|
285
278
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
286
279
|
#options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
@@ -308,7 +301,18 @@ class Naver
|
|
308
301
|
end
|
309
302
|
else
|
310
303
|
begin
|
311
|
-
|
304
|
+
begin
|
305
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
306
|
+
rescue => e
|
307
|
+
puts "chromedriver 버전 불일치!!"
|
308
|
+
puts "아래 지침을 따라주세요."
|
309
|
+
puts "1.프로그램 종료!"
|
310
|
+
puts "2.크롬 업데이트!"
|
311
|
+
puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
|
312
|
+
puts "4.안내된 방식으로 크롬 드라이버 교체"
|
313
|
+
puts "5.재 시작"
|
314
|
+
exit 1
|
315
|
+
end
|
312
316
|
options = Selenium::WebDriver::Chrome::Options.new
|
313
317
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
314
318
|
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
@@ -335,7 +339,18 @@ class Naver
|
|
335
339
|
puts e
|
336
340
|
puts 'proxy error...'
|
337
341
|
begin
|
338
|
-
|
342
|
+
begin
|
343
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
344
|
+
rescue => e
|
345
|
+
puts "chromedriver 버전 불일치!!"
|
346
|
+
puts "아래 지침을 따라주세요."
|
347
|
+
puts "1.프로그램 종료!"
|
348
|
+
puts "2.크롬 업데이트!"
|
349
|
+
puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
|
350
|
+
puts "4.안내된 방식으로 크롬 드라이버 교체"
|
351
|
+
puts "5.재 시작"
|
352
|
+
exit 1
|
353
|
+
end
|
339
354
|
options = Selenium::WebDriver::Chrome::Options.new
|
340
355
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
341
356
|
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
@@ -2931,6 +2946,22 @@ class Wordpress
|
|
2931
2946
|
@data['table'].pop
|
2932
2947
|
#제목끝
|
2933
2948
|
# content = " #{content} "
|
2949
|
+
if @data['포스트설정']['gpt키워드'].checked?
|
2950
|
+
gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
|
2951
|
+
gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
|
2952
|
+
chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
|
2953
|
+
gpt_text = chat.message(keyword)
|
2954
|
+
#content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
|
2955
|
+
content = content.to_s + "(자동생성글)" + gpt_text.to_s
|
2956
|
+
elsif @data['포스트설정']['내용을자동생성'].checked?
|
2957
|
+
content = auto_text
|
2958
|
+
elsif @data['포스트설정']['내용과자동생성'].checked?
|
2959
|
+
#content = content + "\n(자동생성글)\n" + auto_text
|
2960
|
+
content = content + "(자동생성글)" + auto_text
|
2961
|
+
end
|
2962
|
+
@data['table'][index][-1] = 45
|
2963
|
+
@data['table'] << []
|
2964
|
+
@data['table'].pop
|
2934
2965
|
|
2935
2966
|
if @data['포스트설정']['특정단어굵기'].checked?
|
2936
2967
|
content2 = ''
|
@@ -2970,7 +3001,7 @@ class Wordpress
|
|
2970
3001
|
content = content2
|
2971
3002
|
end
|
2972
3003
|
end
|
2973
|
-
@data['table'][index][-1] =
|
3004
|
+
@data['table'][index][-1] = 50
|
2974
3005
|
@data['table'] << []
|
2975
3006
|
@data['table'].pop
|
2976
3007
|
if @data['포스트설정']['단어크기변경'].checked?
|
@@ -2991,19 +3022,7 @@ class Wordpress
|
|
2991
3022
|
@data['table'][index][-1] = 50
|
2992
3023
|
@data['table'] << []
|
2993
3024
|
@data['table'].pop
|
2994
|
-
|
2995
|
-
gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
|
2996
|
-
gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
|
2997
|
-
chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
|
2998
|
-
gpt_text = chat.message(keyword)
|
2999
|
-
#content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
|
3000
|
-
content = content.to_s + "(자동생성글)" + gpt_text.to_s
|
3001
|
-
elsif @data['포스트설정']['내용을자동생성'].checked?
|
3002
|
-
content = auto_text
|
3003
|
-
elsif @data['포스트설정']['내용과자동생성'].checked?
|
3004
|
-
#content = content + "\n(자동생성글)\n" + auto_text
|
3005
|
-
content = content + "(자동생성글)" + auto_text
|
3006
|
-
end
|
3025
|
+
|
3007
3026
|
|
3008
3027
|
if @data['포스트설정']['내용키워드삽입'].checked?
|
3009
3028
|
puts '내용키워드삽입...'
|
@@ -3264,7 +3283,10 @@ class Wordpress
|
|
3264
3283
|
end
|
3265
3284
|
end
|
3266
3285
|
end
|
3286
|
+
|
3267
3287
|
|
3288
|
+
|
3289
|
+
##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
|
3268
3290
|
@data['table'][index][-1] = 70
|
3269
3291
|
@data['table'] << []
|
3270
3292
|
@data['table'].pop
|
@@ -3272,13 +3294,22 @@ class Wordpress
|
|
3272
3294
|
content_memory = content.split('(자동생성글)')
|
3273
3295
|
content = content_memory[0]
|
3274
3296
|
content_end = content_memory[1].to_s
|
3297
|
+
if @data['포스트설정']['gpt키워드'].checked?
|
3298
|
+
if @data['포스트설정']['gpt상단'].checked?
|
3299
|
+
content = "(자동생성글)\n" + content_end + "\n" + content
|
3300
|
+
else
|
3301
|
+
content = content + "\n(자동생성글)\n" + content_end
|
3302
|
+
end
|
3303
|
+
else
|
3304
|
+
content = content + "\n(자동생성글)\n" + content_end
|
3305
|
+
end
|
3275
3306
|
|
3276
3307
|
if @data['포스트설정']['특정단어키워드로변경'].checked?
|
3277
3308
|
@data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8').split(',').each do |i|
|
3278
3309
|
content = content.split(i.force_encoding('utf-8')).join(keyword)
|
3279
3310
|
end
|
3280
3311
|
end
|
3281
|
-
|
3312
|
+
|
3282
3313
|
@data['table'][index][-1] = 75
|
3283
3314
|
@data['table'] << []
|
3284
3315
|
@data['table'].pop
|
@@ -3305,6 +3336,7 @@ class Wordpress
|
|
3305
3336
|
if i.force_encoding('utf-8').to_s.include?('@')
|
3306
3337
|
image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'">'+""
|
3307
3338
|
content[index3] = content[index3] + '**image()**'
|
3339
|
+
|
3308
3340
|
else
|
3309
3341
|
image_memory << ""+ '<img src="'+image_url+'" alt="'+keyword+'">'+""
|
3310
3342
|
content[index3] = content[index3] + '**image**'
|
@@ -3314,6 +3346,8 @@ class Wordpress
|
|
3314
3346
|
content = content.join('')
|
3315
3347
|
end
|
3316
3348
|
end
|
3349
|
+
|
3350
|
+
|
3317
3351
|
|
3318
3352
|
con_memory = Array.new
|
3319
3353
|
index5 = 0
|
@@ -3351,6 +3385,8 @@ class Wordpress
|
|
3351
3385
|
content = content.split(i.force_encoding('utf-8')).join("<sticker></sticker>")
|
3352
3386
|
end
|
3353
3387
|
end
|
3388
|
+
|
3389
|
+
|
3354
3390
|
|
3355
3391
|
if @data['포스트설정']['영상으로변경'].checked?
|
3356
3392
|
if @video.length == 0
|
@@ -3379,36 +3415,79 @@ class Wordpress
|
|
3379
3415
|
# end
|
3380
3416
|
#end
|
3381
3417
|
if @data['포스트설정']['지도로변경'].checked?
|
3382
|
-
# 지도 주소와 사용자 설정 단어들을 가져옵니다.
|
3383
3418
|
map_address = @data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8')
|
3384
|
-
|
3385
|
-
# 여러 단어로 설정된 '지도로변경단어'를 분리하여 배열로 저장
|
3386
3419
|
change_words = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',')
|
3387
3420
|
|
3388
|
-
# content를 각 줄로 분할
|
3389
3421
|
content_lines = content.split("\n")
|
3422
|
+
new_lines = []
|
3423
|
+
|
3424
|
+
content_lines.each do |line|
|
3425
|
+
# 이미 처리된 줄은 건너뜀
|
3426
|
+
if line.include?("<koreamap>")
|
3427
|
+
new_lines << line
|
3428
|
+
next
|
3429
|
+
end
|
3430
|
+
|
3431
|
+
processed = false
|
3390
3432
|
|
3391
|
-
content_lines.each_with_index do |line, index|
|
3392
|
-
# 각 단어에 대해 처리
|
3393
3433
|
change_words.each do |change_word|
|
3394
|
-
#
|
3395
|
-
if line.
|
3396
|
-
|
3397
|
-
if
|
3398
|
-
|
3399
|
-
|
3400
|
-
|
3401
|
-
|
3402
|
-
#
|
3403
|
-
|
3434
|
+
# 1. [단어][주소] 패턴 처리: 분리 + 출력
|
3435
|
+
if line =~ /#{Regexp.escape(change_word)}\[(.*?)\]/
|
3436
|
+
match_data = line.match(/(.*)#{Regexp.escape(change_word)}\[(.*?)\](.*)/)
|
3437
|
+
if match_data
|
3438
|
+
before = match_data[1]
|
3439
|
+
address = match_data[2]
|
3440
|
+
after = match_data[3]
|
3441
|
+
|
3442
|
+
# 태그 추출
|
3443
|
+
open_tag = before[/<p[^>]*?>/i] || ""
|
3444
|
+
close_tag = after[/<\/p>/i] || ""
|
3445
|
+
|
3446
|
+
# 텍스트 정리
|
3447
|
+
before_text = before.sub(open_tag, '')
|
3448
|
+
after_text = after.sub(close_tag, '')
|
3449
|
+
|
3450
|
+
# 줄 분리
|
3451
|
+
new_lines << "#{open_tag}#{before_text}</p>" unless before_text.strip.empty?
|
3452
|
+
new_lines << "<koreamap>#{address}</koreamap>"
|
3453
|
+
new_lines << "#{open_tag}#{after_text}#{close_tag}" unless after_text.strip.empty?
|
3454
|
+
|
3455
|
+
processed = true
|
3456
|
+
break
|
3404
3457
|
end
|
3405
3458
|
end
|
3459
|
+
|
3460
|
+
# 2. 일반 단어 처리 (한 줄에만 등장하는 경우)
|
3461
|
+
if !processed && line.include?(change_word)
|
3462
|
+
parts = line.split(change_word, 2)
|
3463
|
+
prefix = parts[0]
|
3464
|
+
suffix = parts[1]
|
3465
|
+
|
3466
|
+
open_tag = prefix[/<p[^>]*?>/i] || ""
|
3467
|
+
close_tag = suffix[/<\/p>/i] || ""
|
3468
|
+
|
3469
|
+
prefix_text = prefix.sub(open_tag, '')
|
3470
|
+
suffix_text = suffix.sub(close_tag, '')
|
3471
|
+
|
3472
|
+
new_lines << "#{open_tag}#{prefix_text}</p>" unless prefix_text.strip.empty?
|
3473
|
+
new_lines << "<koreamap>#{map_address}</koreamap>"
|
3474
|
+
new_lines << "#{open_tag}#{suffix_text}#{close_tag}" unless suffix_text.strip.empty?
|
3475
|
+
|
3476
|
+
processed = true
|
3477
|
+
break
|
3478
|
+
end
|
3406
3479
|
end
|
3480
|
+
|
3481
|
+
# 변경이 없었으면 원래 줄 추가
|
3482
|
+
new_lines << line unless processed
|
3407
3483
|
end
|
3408
3484
|
|
3409
|
-
|
3410
|
-
content = content_lines.join("\n")
|
3485
|
+
content = new_lines.join("\n")
|
3411
3486
|
end
|
3487
|
+
|
3488
|
+
|
3489
|
+
|
3490
|
+
|
3412
3491
|
|
3413
3492
|
if @data['포스트설정']['인용구변경'].checked?
|
3414
3493
|
if @data['포스트설정']['인용구문구설정'].checked?
|
@@ -3446,21 +3525,26 @@ class Wordpress
|
|
3446
3525
|
@data['table'] << []
|
3447
3526
|
@data['table'].pop
|
3448
3527
|
|
3528
|
+
|
3529
|
+
parts = content.split('(자동생성글)', 2)
|
3530
|
+
content_main = parts[0].strip
|
3531
|
+
content_end = parts[1].to_s.strip
|
3532
|
+
|
3449
3533
|
soosick_1 = ''
|
3450
3534
|
soosick_2 = ''
|
3451
3535
|
if @data['포스트설정']['자동글 수식에 입력'].checked?
|
3452
|
-
|
3453
|
-
|
3536
|
+
content = content_main
|
3537
|
+
soosick_1 = content_end
|
3454
3538
|
else
|
3455
|
-
|
3456
|
-
|
3457
|
-
|
3458
|
-
else
|
3459
|
-
content = content+"\n"+content_end+"\n"
|
3460
|
-
end
|
3539
|
+
if @data['포스트설정']['gpt키워드'].checked?
|
3540
|
+
if @data['포스트설정']['gpt상단'].checked?
|
3541
|
+
content = content_end + "\n" + content_main + "\n"
|
3461
3542
|
else
|
3462
|
-
|
3543
|
+
content = content_main + "\n" + content_end + "\n"
|
3463
3544
|
end
|
3545
|
+
else
|
3546
|
+
content = content_main + "\n" + content_end + "\n"
|
3547
|
+
end
|
3464
3548
|
end
|
3465
3549
|
|
3466
3550
|
if @data['포스트설정']['막글삽입'].checked?
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cafe_buy_duo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-05-22 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: File to Clipboard gem
|
13
13
|
email: mymin26@naver.com
|