cafe_basics 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_basics.rb +149 -70
- 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: de85aa69c00be82b5906f50fecffbe4751fee24d8e3e73c52b3fceb575bc1111
|
4
|
+
data.tar.gz: e0b12494aa5e33797f849c7540134dd2fe3e7d4e061e8b9cc2b2381285f18ede
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f3216c8676cf48271abcea2fe38f84881f49b4d099d2dd419f76f9b5fc0e0a90dc779acc2be11704bd784d9042df4bbf987d07e844210a0cb8136315e96adcc
|
7
|
+
data.tar.gz: 35b7008ab9fdc3f90ddeb90bc0a6211c6fd5205cb621101538f1c5c9854f07ca314110a4f1ce94a580565e3e8b6785753f34a6296f483840dc0e4d95fc90985c
|
data/lib/cafe_basics.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
|
-
# webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
|
247
|
-
|
248
|
-
# Webdrivers가 드라이버를 다운로드할 경로를 설정
|
249
|
-
Webdrivers.cache_time = 86_400 # 하루로 설정 (기본값: 86_400초)
|
250
|
-
Webdrivers.install_dir = "./" # 크롬드라이버를 수동으로 설치할 경로를 설정
|
251
|
-
# 크롬드라이버 자동 업데이트 시도
|
252
|
-
Webdrivers::Chromedriver.update
|
253
|
-
puts "chromedriver 자동 다운로드 성공"
|
254
|
-
rescue => e
|
255
|
-
puts "chromedriver 자동 다운로드 실패: #{e.message}"
|
256
|
-
puts "폴더내 크롬드라이버를 사용합니다."
|
257
|
-
puts "크롬드라이버가 오래된 경우 오류 발생될 수 있으며, 만일 오류 발생시 아래 지침을 따라주세요."
|
258
|
-
puts "1.크롬 업데이트 2.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일을 열어 드라이버를 교체하세요."
|
259
|
-
chromedriver_path = './chromedriver.exe' # 수동 경로를 인스턴스 변수로 설정
|
260
|
-
Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
|
261
|
-
end
|
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') # 확장 프로그램 초기화 화면 방지
|
@@ -2512,6 +2527,22 @@ class Wordpress
|
|
2512
2527
|
@data['table'].pop
|
2513
2528
|
#제목끝
|
2514
2529
|
# content = " #{content} "
|
2530
|
+
if @data['포스트설정']['gpt키워드'].checked?
|
2531
|
+
gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
|
2532
|
+
gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
|
2533
|
+
chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
|
2534
|
+
gpt_text = chat.message(keyword)
|
2535
|
+
#content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
|
2536
|
+
content = content.to_s + "(자동생성글)" + gpt_text.to_s
|
2537
|
+
elsif @data['포스트설정']['내용을자동생성'].checked?
|
2538
|
+
content = auto_text
|
2539
|
+
elsif @data['포스트설정']['내용과자동생성'].checked?
|
2540
|
+
#content = content + "\n(자동생성글)\n" + auto_text
|
2541
|
+
content = content + "(자동생성글)" + auto_text
|
2542
|
+
end
|
2543
|
+
@data['table'][index][-1] = 45
|
2544
|
+
@data['table'] << []
|
2545
|
+
@data['table'].pop
|
2515
2546
|
|
2516
2547
|
if @data['포스트설정']['특정단어굵기'].checked?
|
2517
2548
|
content2 = ''
|
@@ -2551,7 +2582,7 @@ class Wordpress
|
|
2551
2582
|
content = content2
|
2552
2583
|
end
|
2553
2584
|
end
|
2554
|
-
@data['table'][index][-1] =
|
2585
|
+
@data['table'][index][-1] = 50
|
2555
2586
|
@data['table'] << []
|
2556
2587
|
@data['table'].pop
|
2557
2588
|
if @data['포스트설정']['단어크기변경'].checked?
|
@@ -2572,19 +2603,7 @@ class Wordpress
|
|
2572
2603
|
@data['table'][index][-1] = 50
|
2573
2604
|
@data['table'] << []
|
2574
2605
|
@data['table'].pop
|
2575
|
-
|
2576
|
-
gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
|
2577
|
-
gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
|
2578
|
-
chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
|
2579
|
-
gpt_text = chat.message(keyword)
|
2580
|
-
#content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
|
2581
|
-
content = content.to_s + "(자동생성글)" + gpt_text.to_s
|
2582
|
-
elsif @data['포스트설정']['내용을자동생성'].checked?
|
2583
|
-
content = auto_text
|
2584
|
-
elsif @data['포스트설정']['내용과자동생성'].checked?
|
2585
|
-
#content = content + "\n(자동생성글)\n" + auto_text
|
2586
|
-
content = content + "(자동생성글)" + auto_text
|
2587
|
-
end
|
2606
|
+
|
2588
2607
|
|
2589
2608
|
if @data['포스트설정']['내용키워드삽입'].checked?
|
2590
2609
|
puts '내용키워드삽입...'
|
@@ -2845,7 +2864,10 @@ class Wordpress
|
|
2845
2864
|
end
|
2846
2865
|
end
|
2847
2866
|
end
|
2867
|
+
|
2848
2868
|
|
2869
|
+
|
2870
|
+
##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
|
2849
2871
|
@data['table'][index][-1] = 70
|
2850
2872
|
@data['table'] << []
|
2851
2873
|
@data['table'].pop
|
@@ -2853,13 +2875,22 @@ class Wordpress
|
|
2853
2875
|
content_memory = content.split('(자동생성글)')
|
2854
2876
|
content = content_memory[0]
|
2855
2877
|
content_end = content_memory[1].to_s
|
2878
|
+
if @data['포스트설정']['gpt키워드'].checked?
|
2879
|
+
if @data['포스트설정']['gpt상단'].checked?
|
2880
|
+
content = "(자동생성글)\n" + content_end + "\n" + content
|
2881
|
+
else
|
2882
|
+
content = content + "\n(자동생성글)\n" + content_end
|
2883
|
+
end
|
2884
|
+
else
|
2885
|
+
content = content + "\n(자동생성글)\n" + content_end
|
2886
|
+
end
|
2856
2887
|
|
2857
2888
|
if @data['포스트설정']['특정단어키워드로변경'].checked?
|
2858
2889
|
@data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8').split(',').each do |i|
|
2859
2890
|
content = content.split(i.force_encoding('utf-8')).join(keyword)
|
2860
2891
|
end
|
2861
2892
|
end
|
2862
|
-
|
2893
|
+
|
2863
2894
|
@data['table'][index][-1] = 75
|
2864
2895
|
@data['table'] << []
|
2865
2896
|
@data['table'].pop
|
@@ -2876,12 +2907,7 @@ class Wordpress
|
|
2876
2907
|
ttr = 0
|
2877
2908
|
@data['포스트설정']['단어사진으로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
|
2878
2909
|
ttr = 1
|
2879
|
-
|
2880
|
-
# if @data['포스트설정']['내용사진링크'].checked?
|
2881
|
-
# content = content.split(i.force_encoding('utf-8')).join('<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword+'"></a>')
|
2882
|
-
# else
|
2883
|
-
# content = content.split(i.force_encoding('utf-8')).join('<img src="'+image_url+'" alt="'+keyword+'">')
|
2884
|
-
# end
|
2910
|
+
|
2885
2911
|
content = content.split(i.force_encoding('utf-8'))
|
2886
2912
|
content.each_with_index do |ccm, index3|
|
2887
2913
|
if index3 == content.length-1
|
@@ -2891,6 +2917,7 @@ class Wordpress
|
|
2891
2917
|
if i.force_encoding('utf-8').to_s.include?('@')
|
2892
2918
|
image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'">'+""
|
2893
2919
|
content[index3] = content[index3] + '**image()**'
|
2920
|
+
|
2894
2921
|
else
|
2895
2922
|
image_memory << ""+ '<img src="'+image_url+'" alt="'+keyword+'">'+""
|
2896
2923
|
content[index3] = content[index3] + '**image**'
|
@@ -2900,6 +2927,8 @@ class Wordpress
|
|
2900
2927
|
content = content.join('')
|
2901
2928
|
end
|
2902
2929
|
end
|
2930
|
+
|
2931
|
+
|
2903
2932
|
|
2904
2933
|
con_memory = Array.new
|
2905
2934
|
index5 = 0
|
@@ -2937,6 +2966,8 @@ class Wordpress
|
|
2937
2966
|
content = content.split(i.force_encoding('utf-8')).join("<sticker></sticker>")
|
2938
2967
|
end
|
2939
2968
|
end
|
2969
|
+
|
2970
|
+
|
2940
2971
|
|
2941
2972
|
if @data['포스트설정']['영상으로변경'].checked?
|
2942
2973
|
if @video.length == 0
|
@@ -2965,36 +2996,79 @@ class Wordpress
|
|
2965
2996
|
# end
|
2966
2997
|
#end
|
2967
2998
|
if @data['포스트설정']['지도로변경'].checked?
|
2968
|
-
# 지도 주소와 사용자 설정 단어들을 가져옵니다.
|
2969
2999
|
map_address = @data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8')
|
2970
|
-
|
2971
|
-
# 여러 단어로 설정된 '지도로변경단어'를 분리하여 배열로 저장
|
2972
3000
|
change_words = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',')
|
2973
3001
|
|
2974
|
-
# content를 각 줄로 분할
|
2975
3002
|
content_lines = content.split("\n")
|
3003
|
+
new_lines = []
|
3004
|
+
|
3005
|
+
content_lines.each do |line|
|
3006
|
+
# 이미 처리된 줄은 건너뜀
|
3007
|
+
if line.include?("<koreamap>")
|
3008
|
+
new_lines << line
|
3009
|
+
next
|
3010
|
+
end
|
3011
|
+
|
3012
|
+
processed = false
|
2976
3013
|
|
2977
|
-
content_lines.each_with_index do |line, index|
|
2978
|
-
# 각 단어에 대해 처리
|
2979
3014
|
change_words.each do |change_word|
|
2980
|
-
#
|
2981
|
-
if line.
|
2982
|
-
|
2983
|
-
if
|
2984
|
-
|
2985
|
-
|
2986
|
-
|
2987
|
-
|
2988
|
-
#
|
2989
|
-
|
3015
|
+
# 1. [단어][주소] 패턴 처리: 분리 + 출력
|
3016
|
+
if line =~ /#{Regexp.escape(change_word)}\[(.*?)\]/
|
3017
|
+
match_data = line.match(/(.*)#{Regexp.escape(change_word)}\[(.*?)\](.*)/)
|
3018
|
+
if match_data
|
3019
|
+
before = match_data[1]
|
3020
|
+
address = match_data[2]
|
3021
|
+
after = match_data[3]
|
3022
|
+
|
3023
|
+
# 태그 추출
|
3024
|
+
open_tag = before[/<p[^>]*?>/i] || ""
|
3025
|
+
close_tag = after[/<\/p>/i] || ""
|
3026
|
+
|
3027
|
+
# 텍스트 정리
|
3028
|
+
before_text = before.sub(open_tag, '')
|
3029
|
+
after_text = after.sub(close_tag, '')
|
3030
|
+
|
3031
|
+
# 줄 분리
|
3032
|
+
new_lines << "#{open_tag}#{before_text}</p>" unless before_text.strip.empty?
|
3033
|
+
new_lines << "<koreamap>#{address}</koreamap>"
|
3034
|
+
new_lines << "#{open_tag}#{after_text}#{close_tag}" unless after_text.strip.empty?
|
3035
|
+
|
3036
|
+
processed = true
|
3037
|
+
break
|
2990
3038
|
end
|
2991
3039
|
end
|
3040
|
+
|
3041
|
+
# 2. 일반 단어 처리 (한 줄에만 등장하는 경우)
|
3042
|
+
if !processed && line.include?(change_word)
|
3043
|
+
parts = line.split(change_word, 2)
|
3044
|
+
prefix = parts[0]
|
3045
|
+
suffix = parts[1]
|
3046
|
+
|
3047
|
+
open_tag = prefix[/<p[^>]*?>/i] || ""
|
3048
|
+
close_tag = suffix[/<\/p>/i] || ""
|
3049
|
+
|
3050
|
+
prefix_text = prefix.sub(open_tag, '')
|
3051
|
+
suffix_text = suffix.sub(close_tag, '')
|
3052
|
+
|
3053
|
+
new_lines << "#{open_tag}#{prefix_text}</p>" unless prefix_text.strip.empty?
|
3054
|
+
new_lines << "<koreamap>#{map_address}</koreamap>"
|
3055
|
+
new_lines << "#{open_tag}#{suffix_text}#{close_tag}" unless suffix_text.strip.empty?
|
3056
|
+
|
3057
|
+
processed = true
|
3058
|
+
break
|
3059
|
+
end
|
2992
3060
|
end
|
3061
|
+
|
3062
|
+
# 변경이 없었으면 원래 줄 추가
|
3063
|
+
new_lines << line unless processed
|
2993
3064
|
end
|
2994
3065
|
|
2995
|
-
|
2996
|
-
content = content_lines.join("\n")
|
3066
|
+
content = new_lines.join("\n")
|
2997
3067
|
end
|
3068
|
+
|
3069
|
+
|
3070
|
+
|
3071
|
+
|
2998
3072
|
|
2999
3073
|
if @data['포스트설정']['인용구변경'].checked?
|
3000
3074
|
if @data['포스트설정']['인용구문구설정'].checked?
|
@@ -3032,21 +3106,26 @@ class Wordpress
|
|
3032
3106
|
@data['table'] << []
|
3033
3107
|
@data['table'].pop
|
3034
3108
|
|
3109
|
+
|
3110
|
+
parts = content.split('(자동생성글)', 2)
|
3111
|
+
content_main = parts[0].strip
|
3112
|
+
content_end = parts[1].to_s.strip
|
3113
|
+
|
3035
3114
|
soosick_1 = ''
|
3036
3115
|
soosick_2 = ''
|
3037
3116
|
if @data['포스트설정']['자동글 수식에 입력'].checked?
|
3038
|
-
|
3039
|
-
|
3117
|
+
content = content_main
|
3118
|
+
soosick_1 = content_end
|
3040
3119
|
else
|
3041
|
-
|
3042
|
-
|
3043
|
-
|
3044
|
-
else
|
3045
|
-
content = content+"\n"+content_end+"\n"
|
3046
|
-
end
|
3120
|
+
if @data['포스트설정']['gpt키워드'].checked?
|
3121
|
+
if @data['포스트설정']['gpt상단'].checked?
|
3122
|
+
content = content_end + "\n" + content_main + "\n"
|
3047
3123
|
else
|
3048
|
-
|
3124
|
+
content = content_main + "\n" + content_end + "\n"
|
3049
3125
|
end
|
3126
|
+
else
|
3127
|
+
content = content_main + "\n" + content_end + "\n"
|
3128
|
+
end
|
3050
3129
|
end
|
3051
3130
|
|
3052
3131
|
if @data['포스트설정']['막글삽입'].checked?
|
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.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
|