cafe_basics 0.0.70 → 0.1.30
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 +101 -114
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b856cedf8ca448a0adde15939f0d2bf5fb6ffdd82a1401cec0c34d64c24dc2b0
|
4
|
+
data.tar.gz: 934f814c108d7fa53335062fb2d3152b272e9e6c73d39071aaf00e0f1e502bad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b767f73bc35199747d32247d79be6292232bd32da9f6a02fb504320fada48576a54fe1892d241039a0e97651fc94b607b276c8bb838685183008245541402ea3
|
7
|
+
data.tar.gz: db9c3da369b2abef780d2c65cefa08d4d773c35cbf8350830e3e7b1ffe336a8e791a9dfb11f60097277c82409494fb166896c8867e1b58d922863dd804718f32
|
data/lib/cafe_basics.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'glimmer-dsl-libui'
|
2
2
|
require 'selenium-webdriver'
|
3
|
-
|
3
|
+
require 'webdrivers'
|
4
4
|
require 'iconv'
|
5
5
|
require 'nokogiri'
|
6
6
|
require 'http'
|
@@ -241,7 +241,28 @@ 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
|
+
|
244
263
|
end
|
264
|
+
|
265
|
+
|
245
266
|
def chrome_setup(user_id, proxy)
|
246
267
|
naver_cookie_dir = "C:/naver_cookie"
|
247
268
|
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
@@ -260,10 +281,9 @@ class Naver
|
|
260
281
|
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
261
282
|
if proxy == ''
|
262
283
|
begin
|
263
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
264
284
|
options = Selenium::WebDriver::Chrome::Options.new
|
265
285
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
266
|
-
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
286
|
+
#options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
267
287
|
options.add_argument('--disable-sync') # Chrome 동기화 비활성화
|
268
288
|
options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
|
269
289
|
options.add_argument('--no-default-browser-check')
|
@@ -288,7 +308,7 @@ class Naver
|
|
288
308
|
end
|
289
309
|
else
|
290
310
|
begin
|
291
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
311
|
+
#Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
292
312
|
options = Selenium::WebDriver::Chrome::Options.new
|
293
313
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
294
314
|
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
@@ -315,7 +335,7 @@ class Naver
|
|
315
335
|
puts e
|
316
336
|
puts 'proxy error...'
|
317
337
|
begin
|
318
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
338
|
+
#Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
319
339
|
options = Selenium::WebDriver::Chrome::Options.new
|
320
340
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
321
341
|
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
@@ -348,6 +368,7 @@ class Naver
|
|
348
368
|
|
349
369
|
|
350
370
|
|
371
|
+
|
351
372
|
def login(user_id, user_pw, proxy)
|
352
373
|
@user_id = user_id
|
353
374
|
@user_id11 = user_id
|
@@ -1954,20 +1975,27 @@ class Wordpress
|
|
1954
1975
|
|
1955
1976
|
def save_image
|
1956
1977
|
if @data['이미지설정']['이미지'].length == 0
|
1957
|
-
|
1978
|
+
return
|
1979
|
+
end
|
1980
|
+
|
1981
|
+
if @data['이미지설정']['순서사용'].checked?
|
1982
|
+
image_path = @data['이미지설정']['이미지'][@image_counter][2]
|
1983
|
+
@image_counter += 1
|
1984
|
+
if @image_counter > @data['이미지설정']['이미지'].length - 1
|
1985
|
+
@image_counter = 0
|
1986
|
+
end
|
1958
1987
|
else
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
@image_counter = 0
|
1964
|
-
end
|
1965
|
-
else
|
1966
|
-
image_path = @data['이미지설정']['이미지'].sample[2]
|
1988
|
+
# 초기화가 안됐거나 다 썼으면 새롭게 섞는다
|
1989
|
+
@shuffled_images ||= []
|
1990
|
+
if @shuffled_images.empty?
|
1991
|
+
@shuffled_images = @data['이미지설정']['이미지'].shuffle
|
1967
1992
|
end
|
1968
|
-
|
1969
|
-
|
1993
|
+
|
1994
|
+
image_path = @shuffled_images.shift[2]
|
1970
1995
|
end
|
1996
|
+
|
1997
|
+
img = Magick::Image.read(image_path).first
|
1998
|
+
img.write('./image/memory.png')
|
1971
1999
|
end
|
1972
2000
|
|
1973
2001
|
def change_image_size(w)
|
@@ -2741,128 +2769,77 @@ class Wordpress
|
|
2741
2769
|
puts '내용사진자동삽입...'
|
2742
2770
|
sn = @data['포스트설정']['내용사진자동삽입시작숫자'].text.to_s.force_encoding('utf-8').to_i
|
2743
2771
|
en = @data['포스트설정']['내용사진자동삽입끝숫자'].text.to_s.force_encoding('utf-8').to_i
|
2772
|
+
|
2744
2773
|
begin
|
2745
2774
|
cn = rand(sn..en)
|
2746
2775
|
rescue
|
2747
2776
|
cn = 0
|
2748
2777
|
puts 'cn = rand(sn..en) error cn = 1'
|
2749
2778
|
end
|
2750
|
-
|
2779
|
+
|
2751
2780
|
if cn != 0
|
2752
|
-
|
2781
|
+
# content5 구성 및 위치 배열 생성
|
2753
2782
|
if @data['포스트설정']['내용과자동생성'].checked?
|
2754
|
-
if @data['포스트설정']['자동글 수식에 입력'].checked?
|
2755
|
-
for n in 1..cn
|
2756
|
-
position << rand(0..(content.split("(자동생성글)")[0].split("\n").length-1))
|
2757
|
-
sleep(2)
|
2758
|
-
end
|
2759
|
-
else
|
2760
|
-
for n in 1..cn
|
2761
|
-
position << rand(0..(content.split("(자동생성글)")[0].split("\n").length-1))
|
2762
|
-
sleep(2)
|
2763
|
-
end
|
2764
|
-
end
|
2765
|
-
# position.pop
|
2766
|
-
else
|
2767
|
-
for n in 1..cn
|
2768
|
-
position << rand(0..(content.split("\n").length-2))
|
2769
|
-
sleep(2)
|
2770
|
-
end
|
2771
|
-
end
|
2772
|
-
|
2773
|
-
if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
|
2774
2783
|
if @data['포스트설정']['자동글 수식에 입력'].checked?
|
2775
2784
|
content5 = content.split("(자동생성글)")[0].to_s.split("\n")
|
2776
2785
|
content55 = content.split("(자동생성글)")[1].to_s
|
2786
|
+
position = content5.length.times.to_a.sample(cn).sort.reverse
|
2777
2787
|
else
|
2778
2788
|
content5 = content.split("(자동생성글)")[0].to_s.split("\n")
|
2779
2789
|
content55 = content.split("(자동생성글)")[1].to_s
|
2790
|
+
position = content5.length.times.to_a.sample(cn).sort.reverse
|
2780
2791
|
end
|
2792
|
+
elsif @data['포스트설정']['gpt키워드'].checked?
|
2793
|
+
content5 = content.split("(자동생성글)")[1].to_s.split("\n")
|
2794
|
+
content_prefix = content.split("(자동생성글)")[0].to_s
|
2795
|
+
content55 = ''
|
2796
|
+
position = content5.length.times.to_a.sample(cn).sort.reverse
|
2781
2797
|
else
|
2798
|
+
content5 = content.split("\n")
|
2782
2799
|
content55 = ''
|
2783
|
-
|
2800
|
+
position = content5.length.times.to_a.sample(cn).sort.reverse
|
2784
2801
|
end
|
2785
|
-
|
2786
|
-
|
2787
|
-
puts content55
|
2788
|
-
p position
|
2789
|
-
|
2802
|
+
|
2803
|
+
# 중복 필터링 로직
|
2790
2804
|
while true
|
2791
2805
|
check11 = 0
|
2792
|
-
|
2793
|
-
if content5[
|
2806
|
+
position.each_with_index do |pos, idx|
|
2807
|
+
if content5[pos].to_s.include?('style') || content5[pos].to_s.include?('<') || content5[pos].to_s.include?('>')
|
2794
2808
|
check11 = 1
|
2795
|
-
position[
|
2809
|
+
position[idx] += 4
|
2796
2810
|
end
|
2797
2811
|
end
|
2798
|
-
if check11 == 0
|
2799
|
-
break
|
2800
|
-
end
|
2812
|
+
break if check11 == 0
|
2801
2813
|
end
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
# puts '사진넣는위치 => '+i.to_s
|
2814
|
-
# if @data['포스트설정']['내용사진링크'].checked?
|
2815
|
-
# image_memory << ""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword.force_encoding('utf-8')+'"></a>'+""
|
2816
|
-
# content5.insert(i, '**image**')
|
2817
|
-
# else
|
2818
|
-
# image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'" class="aligncenter size-full">'+""
|
2819
|
-
# content5.insert(i, '**image**')
|
2820
|
-
# end
|
2821
|
-
# end
|
2822
|
-
|
2823
|
-
# if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
|
2824
|
-
# content = content5.join("\n")+'(자동생성글)'+content55
|
2825
|
-
# iconv = Iconv.new('UTF-8', 'ASCII-8BIT')
|
2826
|
-
# content = iconv.iconv(content)
|
2827
|
-
# content = content.encode('UTF-8', 'binary', invalid: :replace, replace: '')
|
2828
|
-
# puts content
|
2829
|
-
# image_url = image_url22
|
2830
|
-
|
2831
|
-
# if @data['포스트설정']['자동글 수식에 입력'].checked?
|
2832
|
-
|
2833
|
-
# else
|
2834
|
-
# if @data['포스트설정']['내용사진링크'].checked?
|
2835
|
-
# content = content.split('(자동생성글)')[0]+""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword+'"></a>'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
|
2836
|
-
# else
|
2837
|
-
# content = content.split('(자동생성글)')[0]+""+'<img src="'+image_url+'" alt="'+keyword+'" >'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
|
2838
|
-
# end
|
2839
|
-
# end
|
2840
|
-
###여기까지 이미지 순서대로 안되서 변경##-------------------------------------------------------------------------------
|
2841
|
-
|
2842
|
-
##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
|
2843
|
-
if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
|
2814
|
+
|
2815
|
+
if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
|
2816
|
+
sleep(2)
|
2817
|
+
puts '이미지 자동 세탁 중 · · · '
|
2818
|
+
end
|
2819
|
+
|
2820
|
+
p content5
|
2821
|
+
puts content55
|
2822
|
+
p position
|
2823
|
+
|
2844
2824
|
sleep(2)
|
2845
|
-
|
2846
|
-
|
2847
|
-
|
2848
|
-
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
content5.insert(i, '**image**')
|
2855
|
-
else
|
2856
|
-
image_memory << ""+'<img src="'+image_url22+'" alt="'+keyword+'" class="aligncenter size-full">'+""
|
2857
|
-
content5.insert(i, '**image**')
|
2825
|
+
position.each do |i|
|
2826
|
+
image_url22 = get_image_file().force_encoding('utf-8')
|
2827
|
+
if @data['포스트설정']['내용사진링크'].checked?
|
2828
|
+
image_tag = '<a href="' + @data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8') +
|
2829
|
+
'"><img src="' + image_url22 + '" alt="' + keyword.force_encoding('utf-8') + '" class="aligncenter size-full"></a>'
|
2830
|
+
else
|
2831
|
+
image_tag = '<img src="' + image_url22 + '" alt="' + keyword + '" class="aligncenter size-full">'
|
2832
|
+
end
|
2833
|
+
content5.insert(i, image_tag)
|
2858
2834
|
end
|
2859
|
-
|
2860
|
-
|
2861
|
-
|
2862
|
-
|
2863
|
-
|
2864
|
-
|
2865
|
-
|
2835
|
+
|
2836
|
+
sleep(2)
|
2837
|
+
puts '이미지 자동 세탁 완료 · · · '
|
2838
|
+
|
2839
|
+
if @data['포스트설정']['내용과자동생성'].checked?
|
2840
|
+
content = content5.join("\n") + '(자동생성글)' + content55
|
2841
|
+
elsif @data['포스트설정']['gpt키워드'].checked?
|
2842
|
+
content = content_prefix + "(자동생성글)" + content5.join("\n")
|
2866
2843
|
else
|
2867
2844
|
content = content5.join("\n")
|
2868
2845
|
end
|
@@ -3192,9 +3169,19 @@ class Wordpress
|
|
3192
3169
|
end
|
3193
3170
|
|
3194
3171
|
|
3172
|
+
#if @data['포스트설정']['내용첫줄제목에입력'].checked?
|
3173
|
+
# title = content.split("\n")[0]
|
3174
|
+
#end
|
3195
3175
|
if @data['포스트설정']['내용첫줄제목에입력'].checked?
|
3196
|
-
|
3197
|
-
|
3176
|
+
# 콘텐츠를 줄 단위로 분리
|
3177
|
+
content_lines = content.split("\n")
|
3178
|
+
|
3179
|
+
# 첫 번째 줄이 <img src=로 시작하는지 확인하고, 시작하는 경우 두 번째 줄부터 확인
|
3180
|
+
title = content_lines.find { |line| !line.start_with?('<img src=') }
|
3181
|
+
|
3182
|
+
# 만약 첫 번째 줄부터 <img src=로 시작하는 경우, 두 번째 줄을 제목으로 설정
|
3183
|
+
title ||= content_lines[1] # 첫 번째 줄이 <img src=일 경우 두 번째 줄을 사용
|
3184
|
+
|
3198
3185
|
end
|
3199
3186
|
|
3200
3187
|
if @data['포스트설정']['제목을내용첫줄입력'].checked?
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cafe_basics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-
|
10
|
+
date: 2025-04-17 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: File to Clipboard gem
|
14
13
|
email: mymin26@naver.com
|
@@ -21,7 +20,6 @@ homepage: ''
|
|
21
20
|
licenses:
|
22
21
|
- zon
|
23
22
|
metadata: {}
|
24
|
-
post_install_message:
|
25
23
|
rdoc_options: []
|
26
24
|
require_paths:
|
27
25
|
- lib
|
@@ -36,8 +34,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
34
|
- !ruby/object:Gem::Version
|
37
35
|
version: '0'
|
38
36
|
requirements: []
|
39
|
-
rubygems_version: 3.
|
40
|
-
signing_key:
|
37
|
+
rubygems_version: 3.6.7
|
41
38
|
specification_version: 4
|
42
39
|
summary: file to clipboard
|
43
40
|
test_files: []
|