nblog_duo 111.113.777 → 111.115.779
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/nblog_duo.rb +141 -65
- 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: 97cc85a3f170c59e52cada916aa44bfc47074093da01f7d97ce7fbf2cb1f8515
|
4
|
+
data.tar.gz: 0ae365383002ba9ab2f62ca3a049c881ab8bc8bdc58b1608b923fd59f803a1d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2599ab747b6f40a19a68a2528897f12d3c2a20d3fc2ae8b19fa9ebb790a6408f9814c1816a383e61f1a6433c9ce5db5abd66b2807e1326779816e994c19d4250
|
7
|
+
data.tar.gz: 7723b3258f905973629ce97707acbd29e60bdbe88186504e0ed03a0078e3fe7d8327a22e3779e2af78f7f1267c30e940116f5daa08f396ae80ad80d87a43dde5
|
data/lib/nblog_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
|
-
# 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') # 확장 프로그램 초기화 화면 방지
|
@@ -2804,6 +2819,22 @@ class Wordpress
|
|
2804
2819
|
@data['table'].pop
|
2805
2820
|
#제목끝
|
2806
2821
|
# content = " #{content} "
|
2822
|
+
if @data['포스트설정']['gpt키워드'].checked?
|
2823
|
+
gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
|
2824
|
+
gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
|
2825
|
+
chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
|
2826
|
+
gpt_text = chat.message(keyword)
|
2827
|
+
#content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
|
2828
|
+
content = content.to_s + "(자동생성글)" + gpt_text.to_s
|
2829
|
+
elsif @data['포스트설정']['내용을자동생성'].checked?
|
2830
|
+
content = auto_text
|
2831
|
+
elsif @data['포스트설정']['내용과자동생성'].checked?
|
2832
|
+
#content = content + "\n(자동생성글)\n" + auto_text
|
2833
|
+
content = content + "(자동생성글)" + auto_text
|
2834
|
+
end
|
2835
|
+
@data['table'][index][-1] = 45
|
2836
|
+
@data['table'] << []
|
2837
|
+
@data['table'].pop
|
2807
2838
|
|
2808
2839
|
if @data['포스트설정']['특정단어굵기'].checked?
|
2809
2840
|
content2 = ''
|
@@ -2843,7 +2874,7 @@ class Wordpress
|
|
2843
2874
|
content = content2
|
2844
2875
|
end
|
2845
2876
|
end
|
2846
|
-
@data['table'][index][-1] =
|
2877
|
+
@data['table'][index][-1] = 50
|
2847
2878
|
@data['table'] << []
|
2848
2879
|
@data['table'].pop
|
2849
2880
|
if @data['포스트설정']['단어크기변경'].checked?
|
@@ -2864,19 +2895,7 @@ class Wordpress
|
|
2864
2895
|
@data['table'][index][-1] = 50
|
2865
2896
|
@data['table'] << []
|
2866
2897
|
@data['table'].pop
|
2867
|
-
|
2868
|
-
gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
|
2869
|
-
gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
|
2870
|
-
chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
|
2871
|
-
gpt_text = chat.message(keyword)
|
2872
|
-
#content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
|
2873
|
-
content = content.to_s + "(자동생성글)" + gpt_text.to_s
|
2874
|
-
elsif @data['포스트설정']['내용을자동생성'].checked?
|
2875
|
-
content = auto_text
|
2876
|
-
elsif @data['포스트설정']['내용과자동생성'].checked?
|
2877
|
-
#content = content + "\n(자동생성글)\n" + auto_text
|
2878
|
-
content = content + "(자동생성글)" + auto_text
|
2879
|
-
end
|
2898
|
+
|
2880
2899
|
|
2881
2900
|
if @data['포스트설정']['내용키워드삽입'].checked?
|
2882
2901
|
puts '내용키워드삽입...'
|
@@ -3148,6 +3167,15 @@ class Wordpress
|
|
3148
3167
|
content_memory = content.split('(자동생성글)')
|
3149
3168
|
content = content_memory[0]
|
3150
3169
|
content_end = content_memory[1].to_s
|
3170
|
+
if @data['포스트설정']['gpt키워드'].checked?
|
3171
|
+
if @data['포스트설정']['gpt상단'].checked?
|
3172
|
+
content = "(자동생성글)\n" + content_end + "\n" + content
|
3173
|
+
else
|
3174
|
+
content = content + "\n(자동생성글)\n" + content_end
|
3175
|
+
end
|
3176
|
+
else
|
3177
|
+
content = content + "\n(자동생성글)\n" + content_end
|
3178
|
+
end
|
3151
3179
|
|
3152
3180
|
if @data['포스트설정']['특정단어키워드로변경'].checked?
|
3153
3181
|
@data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8').split(',').each do |i|
|
@@ -3236,8 +3264,8 @@ class Wordpress
|
|
3236
3264
|
slide_names_only = slide_images.map { |pair| pair[1] }.join(' ')
|
3237
3265
|
|
3238
3266
|
# 각각 <slide>와 <slide1> 태그로 감싸기
|
3239
|
-
|
3240
|
-
|
3267
|
+
slide_html_full = "\n<slide>" + slide_full_paths + "</slide>\n"
|
3268
|
+
slide_html_names = "\n<slide1>" + slide_names_only + "</slide1>\n"
|
3241
3269
|
|
3242
3270
|
# 두 태그를 content에 추가
|
3243
3271
|
content[index3] = content[index3] + slide_html_full
|
@@ -3313,36 +3341,79 @@ class Wordpress
|
|
3313
3341
|
# end
|
3314
3342
|
#end
|
3315
3343
|
if @data['포스트설정']['지도로변경'].checked?
|
3316
|
-
# 지도 주소와 사용자 설정 단어들을 가져옵니다.
|
3317
3344
|
map_address = @data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8')
|
3318
|
-
|
3319
|
-
# 여러 단어로 설정된 '지도로변경단어'를 분리하여 배열로 저장
|
3320
3345
|
change_words = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',')
|
3321
3346
|
|
3322
|
-
# content를 각 줄로 분할
|
3323
3347
|
content_lines = content.split("\n")
|
3348
|
+
new_lines = []
|
3349
|
+
|
3350
|
+
content_lines.each do |line|
|
3351
|
+
# 이미 처리된 줄은 건너뜀
|
3352
|
+
if line.include?("<koreamap>")
|
3353
|
+
new_lines << line
|
3354
|
+
next
|
3355
|
+
end
|
3356
|
+
|
3357
|
+
processed = false
|
3324
3358
|
|
3325
|
-
content_lines.each_with_index do |line, index|
|
3326
|
-
# 각 단어에 대해 처리
|
3327
3359
|
change_words.each do |change_word|
|
3328
|
-
#
|
3329
|
-
if line.
|
3330
|
-
|
3331
|
-
if
|
3332
|
-
|
3333
|
-
|
3334
|
-
|
3335
|
-
|
3336
|
-
#
|
3337
|
-
|
3360
|
+
# 1. [단어][주소] 패턴 처리: 분리 + 출력
|
3361
|
+
if line =~ /#{Regexp.escape(change_word)}\[(.*?)\]/
|
3362
|
+
match_data = line.match(/(.*)#{Regexp.escape(change_word)}\[(.*?)\](.*)/)
|
3363
|
+
if match_data
|
3364
|
+
before = match_data[1]
|
3365
|
+
address = match_data[2]
|
3366
|
+
after = match_data[3]
|
3367
|
+
|
3368
|
+
# 태그 추출
|
3369
|
+
open_tag = before[/<p[^>]*?>/i] || ""
|
3370
|
+
close_tag = after[/<\/p>/i] || ""
|
3371
|
+
|
3372
|
+
# 텍스트 정리
|
3373
|
+
before_text = before.sub(open_tag, '')
|
3374
|
+
after_text = after.sub(close_tag, '')
|
3375
|
+
|
3376
|
+
# 줄 분리
|
3377
|
+
new_lines << "#{open_tag}#{before_text}</p>" unless before_text.strip.empty?
|
3378
|
+
new_lines << "<koreamap>#{address}</koreamap>"
|
3379
|
+
new_lines << "#{open_tag}#{after_text}#{close_tag}" unless after_text.strip.empty?
|
3380
|
+
|
3381
|
+
processed = true
|
3382
|
+
break
|
3338
3383
|
end
|
3339
3384
|
end
|
3385
|
+
|
3386
|
+
# 2. 일반 단어 처리 (한 줄에만 등장하는 경우)
|
3387
|
+
if !processed && line.include?(change_word)
|
3388
|
+
parts = line.split(change_word, 2)
|
3389
|
+
prefix = parts[0]
|
3390
|
+
suffix = parts[1]
|
3391
|
+
|
3392
|
+
open_tag = prefix[/<p[^>]*?>/i] || ""
|
3393
|
+
close_tag = suffix[/<\/p>/i] || ""
|
3394
|
+
|
3395
|
+
prefix_text = prefix.sub(open_tag, '')
|
3396
|
+
suffix_text = suffix.sub(close_tag, '')
|
3397
|
+
|
3398
|
+
new_lines << "#{open_tag}#{prefix_text}</p>" unless prefix_text.strip.empty?
|
3399
|
+
new_lines << "<koreamap>#{map_address}</koreamap>"
|
3400
|
+
new_lines << "#{open_tag}#{suffix_text}#{close_tag}" unless suffix_text.strip.empty?
|
3401
|
+
|
3402
|
+
processed = true
|
3403
|
+
break
|
3404
|
+
end
|
3340
3405
|
end
|
3406
|
+
|
3407
|
+
# 변경이 없었으면 원래 줄 추가
|
3408
|
+
new_lines << line unless processed
|
3341
3409
|
end
|
3342
3410
|
|
3343
|
-
|
3344
|
-
content = content_lines.join("\n")
|
3411
|
+
content = new_lines.join("\n")
|
3345
3412
|
end
|
3413
|
+
|
3414
|
+
|
3415
|
+
|
3416
|
+
|
3346
3417
|
|
3347
3418
|
if @data['포스트설정']['인용구변경'].checked?
|
3348
3419
|
if @data['포스트설정']['인용구문구설정'].checked?
|
@@ -3380,21 +3451,26 @@ class Wordpress
|
|
3380
3451
|
@data['table'] << []
|
3381
3452
|
@data['table'].pop
|
3382
3453
|
|
3454
|
+
|
3455
|
+
parts = content.split('(자동생성글)', 2)
|
3456
|
+
content_main = parts[0].strip
|
3457
|
+
content_end = parts[1].to_s.strip
|
3458
|
+
|
3383
3459
|
soosick_1 = ''
|
3384
3460
|
soosick_2 = ''
|
3385
3461
|
if @data['포스트설정']['자동글 수식에 입력'].checked?
|
3386
|
-
|
3387
|
-
|
3462
|
+
content = content_main
|
3463
|
+
soosick_1 = content_end
|
3388
3464
|
else
|
3389
|
-
|
3390
|
-
|
3391
|
-
|
3392
|
-
else
|
3393
|
-
content = content+"\n"+content_end+"\n"
|
3394
|
-
end
|
3465
|
+
if @data['포스트설정']['gpt키워드'].checked?
|
3466
|
+
if @data['포스트설정']['gpt상단'].checked?
|
3467
|
+
content = content_end + "\n" + content_main + "\n"
|
3395
3468
|
else
|
3396
|
-
|
3469
|
+
content = content_main + "\n" + content_end + "\n"
|
3397
3470
|
end
|
3471
|
+
else
|
3472
|
+
content = content_main + "\n" + content_end + "\n"
|
3473
|
+
end
|
3398
3474
|
end
|
3399
3475
|
|
3400
3476
|
if @data['포스트설정']['막글삽입'].checked?
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nblog_duo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 111.
|
4
|
+
version: 111.115.779
|
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
|