cafe_buy 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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cafe_buy.rb +148 -64
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a81adfdb6db38c7c18c803598e6765f8051ec7accbc45c322caaa886fdfaff7
4
- data.tar.gz: 1c15e95def1d4c4a7bf955210898f20c964ce22fcbba62a7b6d19c37265b8d0e
3
+ metadata.gz: f7d1d08cfc2046a4e39a2a937dee9258273151f4db341c7c52ad5af1427d4189
4
+ data.tar.gz: 69a442ae792c8a4fe66758d1d794575e23a9520e5488423880733725cab5e3d9
5
5
  SHA512:
6
- metadata.gz: fd664c0ee759c0b525b02908d6c7fd57f8d106052dc41ee645ca568685d9042c1565ea8ed91e488abf8c627f5407a16d703d2c6fa1408e10439f75559c6d0eae
7
- data.tar.gz: 3ef6cb65abd99bb36b7143b05dcc9f0aa5efd389d6d1e557b58c0b2653a59e1d3c24f57638377f8e08f1b000396994360aa5aba8b4bcd167091d96191889dbeb
6
+ metadata.gz: '0198b0f66b6da5ae5830c5c00f254371138e7a06b5be916f05e32fb6ad42d6a0ef79f3fb91877c4ab1a596ac9d9a06ccc0260211fb04bf8db255c9c5a2ca7e0f'
7
+ data.tar.gz: d6406d1aebd2678d436d3357e698117601fca72335892258f164a3437b52d27c2d9211fbb779c6a9391f50532e06af8c94ec5a529652bc7abc97f3fd37c897ba
data/lib/cafe_buy.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
- #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
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
- #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
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') # 확장 프로그램 초기화 화면 방지
@@ -2863,6 +2878,22 @@ class Wordpress
2863
2878
  @data['table'].pop
2864
2879
  #제목끝
2865
2880
  # content = " #{content} "
2881
+ if @data['포스트설정']['gpt키워드'].checked?
2882
+ gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2883
+ gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2884
+ chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2885
+ gpt_text = chat.message(keyword)
2886
+ #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2887
+ content = content.to_s + "(자동생성글)" + gpt_text.to_s
2888
+ elsif @data['포스트설정']['내용을자동생성'].checked?
2889
+ content = auto_text
2890
+ elsif @data['포스트설정']['내용과자동생성'].checked?
2891
+ #content = content + "\n(자동생성글)\n" + auto_text
2892
+ content = content + "(자동생성글)" + auto_text
2893
+ end
2894
+ @data['table'][index][-1] = 45
2895
+ @data['table'] << []
2896
+ @data['table'].pop
2866
2897
 
2867
2898
  if @data['포스트설정']['특정단어굵기'].checked?
2868
2899
  content2 = ''
@@ -2902,7 +2933,7 @@ class Wordpress
2902
2933
  content = content2
2903
2934
  end
2904
2935
  end
2905
- @data['table'][index][-1] = 35
2936
+ @data['table'][index][-1] = 50
2906
2937
  @data['table'] << []
2907
2938
  @data['table'].pop
2908
2939
  if @data['포스트설정']['단어크기변경'].checked?
@@ -2923,19 +2954,7 @@ class Wordpress
2923
2954
  @data['table'][index][-1] = 50
2924
2955
  @data['table'] << []
2925
2956
  @data['table'].pop
2926
- if @data['포스트설정']['gpt키워드'].checked?
2927
- gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2928
- gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2929
- chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2930
- gpt_text = chat.message(keyword)
2931
- #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2932
- content = content.to_s + "(자동생성글)" + gpt_text.to_s
2933
- elsif @data['포스트설정']['내용을자동생성'].checked?
2934
- content = auto_text
2935
- elsif @data['포스트설정']['내용과자동생성'].checked?
2936
- #content = content + "\n(자동생성글)\n" + auto_text
2937
- content = content + "(자동생성글)" + auto_text
2938
- end
2957
+
2939
2958
 
2940
2959
  if @data['포스트설정']['내용키워드삽입'].checked?
2941
2960
  puts '내용키워드삽입...'
@@ -3196,7 +3215,10 @@ class Wordpress
3196
3215
  end
3197
3216
  end
3198
3217
  end
3218
+
3199
3219
 
3220
+
3221
+ ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
3200
3222
  @data['table'][index][-1] = 70
3201
3223
  @data['table'] << []
3202
3224
  @data['table'].pop
@@ -3204,13 +3226,22 @@ class Wordpress
3204
3226
  content_memory = content.split('(자동생성글)')
3205
3227
  content = content_memory[0]
3206
3228
  content_end = content_memory[1].to_s
3229
+ if @data['포스트설정']['gpt키워드'].checked?
3230
+ if @data['포스트설정']['gpt상단'].checked?
3231
+ content = "(자동생성글)\n" + content_end + "\n" + content
3232
+ else
3233
+ content = content + "\n(자동생성글)\n" + content_end
3234
+ end
3235
+ else
3236
+ content = content + "\n(자동생성글)\n" + content_end
3237
+ end
3207
3238
 
3208
3239
  if @data['포스트설정']['특정단어키워드로변경'].checked?
3209
3240
  @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8').split(',').each do |i|
3210
3241
  content = content.split(i.force_encoding('utf-8')).join(keyword)
3211
3242
  end
3212
3243
  end
3213
-
3244
+
3214
3245
  @data['table'][index][-1] = 75
3215
3246
  @data['table'] << []
3216
3247
  @data['table'].pop
@@ -3237,6 +3268,7 @@ class Wordpress
3237
3268
  if i.force_encoding('utf-8').to_s.include?('@')
3238
3269
  image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'">'+""
3239
3270
  content[index3] = content[index3] + '**image()**'
3271
+
3240
3272
  else
3241
3273
  image_memory << ""+ '<img src="'+image_url+'" alt="'+keyword+'">'+""
3242
3274
  content[index3] = content[index3] + '**image**'
@@ -3246,6 +3278,8 @@ class Wordpress
3246
3278
  content = content.join('')
3247
3279
  end
3248
3280
  end
3281
+
3282
+
3249
3283
 
3250
3284
  con_memory = Array.new
3251
3285
  index5 = 0
@@ -3283,6 +3317,8 @@ class Wordpress
3283
3317
  content = content.split(i.force_encoding('utf-8')).join("<sticker></sticker>")
3284
3318
  end
3285
3319
  end
3320
+
3321
+
3286
3322
 
3287
3323
  if @data['포스트설정']['영상으로변경'].checked?
3288
3324
  if @video.length == 0
@@ -3311,36 +3347,79 @@ class Wordpress
3311
3347
  # end
3312
3348
  #end
3313
3349
  if @data['포스트설정']['지도로변경'].checked?
3314
- # 지도 주소와 사용자 설정 단어들을 가져옵니다.
3315
3350
  map_address = @data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8')
3316
-
3317
- # 여러 단어로 설정된 '지도로변경단어'를 분리하여 배열로 저장
3318
3351
  change_words = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',')
3319
3352
 
3320
- # content를 각 줄로 분할
3321
3353
  content_lines = content.split("\n")
3354
+ new_lines = []
3355
+
3356
+ content_lines.each do |line|
3357
+ # 이미 처리된 줄은 건너뜀
3358
+ if line.include?("<koreamap>")
3359
+ new_lines << line
3360
+ next
3361
+ end
3362
+
3363
+ processed = false
3322
3364
 
3323
- content_lines.each_with_index do |line, index|
3324
- # 각 단어에 대해 처리
3325
3365
  change_words.each do |change_word|
3326
- # 'change_word'가 포함된 줄에 대해서만 처리
3327
- if line.include?(change_word)
3328
- # 설정된 단어 뒤에 괄호가 있는지 확인
3329
- if line.include?("[") && line.include?("]")
3330
- # 괄호 안의 주소를 찾아서 그 주소는 그대로 두고, 지도로 변경된 주소로 교체
3331
- address_in_brackets = line.match(/\[(.*?)\]/)[1] # 괄호 안의 주소를 추출
3332
- content_lines[index] = "<koreamap>#{address_in_brackets}</koreamap>"
3333
- else
3334
- # 괄호가 없다면 @data['포스트설정']['지도주소']를 추가
3335
- content_lines[index] = "<koreamap>#{map_address}</koreamap>"
3366
+ # 1. [단어][주소] 패턴 처리: 분리 + 출력
3367
+ if line =~ /#{Regexp.escape(change_word)}\[(.*?)\]/
3368
+ match_data = line.match(/(.*)#{Regexp.escape(change_word)}\[(.*?)\](.*)/)
3369
+ if match_data
3370
+ before = match_data[1]
3371
+ address = match_data[2]
3372
+ after = match_data[3]
3373
+
3374
+ # 태그 추출
3375
+ open_tag = before[/<p[^>]*?>/i] || ""
3376
+ close_tag = after[/<\/p>/i] || ""
3377
+
3378
+ # 텍스트 정리
3379
+ before_text = before.sub(open_tag, '')
3380
+ after_text = after.sub(close_tag, '')
3381
+
3382
+ # 줄 분리
3383
+ new_lines << "#{open_tag}#{before_text}</p>" unless before_text.strip.empty?
3384
+ new_lines << "<koreamap>#{address}</koreamap>"
3385
+ new_lines << "#{open_tag}#{after_text}#{close_tag}" unless after_text.strip.empty?
3386
+
3387
+ processed = true
3388
+ break
3336
3389
  end
3337
3390
  end
3391
+
3392
+ # 2. 일반 단어 처리 (한 줄에만 등장하는 경우)
3393
+ if !processed && line.include?(change_word)
3394
+ parts = line.split(change_word, 2)
3395
+ prefix = parts[0]
3396
+ suffix = parts[1]
3397
+
3398
+ open_tag = prefix[/<p[^>]*?>/i] || ""
3399
+ close_tag = suffix[/<\/p>/i] || ""
3400
+
3401
+ prefix_text = prefix.sub(open_tag, '')
3402
+ suffix_text = suffix.sub(close_tag, '')
3403
+
3404
+ new_lines << "#{open_tag}#{prefix_text}</p>" unless prefix_text.strip.empty?
3405
+ new_lines << "<koreamap>#{map_address}</koreamap>"
3406
+ new_lines << "#{open_tag}#{suffix_text}#{close_tag}" unless suffix_text.strip.empty?
3407
+
3408
+ processed = true
3409
+ break
3410
+ end
3338
3411
  end
3412
+
3413
+ # 변경이 없었으면 원래 줄 추가
3414
+ new_lines << line unless processed
3339
3415
  end
3340
3416
 
3341
- # 다시 content로 합치기
3342
- content = content_lines.join("\n")
3417
+ content = new_lines.join("\n")
3343
3418
  end
3419
+
3420
+
3421
+
3422
+
3344
3423
 
3345
3424
  if @data['포스트설정']['인용구변경'].checked?
3346
3425
  if @data['포스트설정']['인용구문구설정'].checked?
@@ -3378,21 +3457,26 @@ class Wordpress
3378
3457
  @data['table'] << []
3379
3458
  @data['table'].pop
3380
3459
 
3460
+
3461
+ parts = content.split('(자동생성글)', 2)
3462
+ content_main = parts[0].strip
3463
+ content_end = parts[1].to_s.strip
3464
+
3381
3465
  soosick_1 = ''
3382
3466
  soosick_2 = ''
3383
3467
  if @data['포스트설정']['자동글 수식에 입력'].checked?
3384
- content = content
3385
- soosick_1 = content_end
3468
+ content = content_main
3469
+ soosick_1 = content_end
3386
3470
  else
3387
- if @data['포스트설정']['gpt키워드'].checked?
3388
- if @data['포스트설정']['gpt상단'].checked?
3389
- content = content_end+"\n"+content+"\n"
3390
- else
3391
- content = content+"\n"+content_end+"\n"
3392
- end
3471
+ if @data['포스트설정']['gpt키워드'].checked?
3472
+ if @data['포스트설정']['gpt상단'].checked?
3473
+ content = content_end + "\n" + content_main + "\n"
3393
3474
  else
3394
- content = content+"\n"+content_end+"\n"
3475
+ content = content_main + "\n" + content_end + "\n"
3395
3476
  end
3477
+ else
3478
+ content = content_main + "\n" + content_end + "\n"
3479
+ end
3396
3480
  end
3397
3481
 
3398
3482
  if @data['포스트설정']['막글삽입'].checked?
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.30
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-04-17 00:00:00.000000000 Z
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