cafe_basics 0.0.30 → 0.0.32

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_basics.rb +162 -137
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b708f080c9150f084831a31e1a4e5db79da52674dd854f076625f7f78c18f22d
4
- data.tar.gz: da2ac58b60ada62e1cb390ddfaa47ba8572221802eb9195f09123e5e41e4d59f
3
+ metadata.gz: 0fcdb4c34e5496f836951e76190096f36257b2f2f4159126dc45eac6e8fdf79e
4
+ data.tar.gz: 0d0ca80b13f393e2ebbdba90098e86ce77fd9af897413230b3907b19a3cd868a
5
5
  SHA512:
6
- metadata.gz: 99c14b3415ceb8c3f58870e7283df636e6e1776b8c1c70db84f136a087c4cfbc54c03cb5e0baf274b402b85b73e5e33f26bef00156916fe83c8cb0d03bfc8288
7
- data.tar.gz: deac9b4801c263e4e2bcb59745d2ba90c90dc52c1ec79cf04180e5573fe63184f1eaf6403b3e44d6409d57677d9bb05a9ae31c1c503f968264a0d394763e398a
6
+ metadata.gz: 62324a38a3d5452c556189c51cbe2da4dc68d09be622ffd4c174c4fe2c1f61158d4a91e637dec82c35671c0eca15430f09a6c8a1b672fbda639f4b1c49eb6564
7
+ data.tar.gz: 86d1aff31c0374ff05e08ac7515845de33053e5ef5185f43c13d9e0917befe7dcbb953d95df14c55b1c9d3a5136f9e25c8caa768303f18aca08cff56138df8b8
data/lib/cafe_basics.rb CHANGED
@@ -738,169 +738,194 @@ class Naver
738
738
  };
739
739
  JS
740
740
  sleep(1)
741
- # 이미지 등록 버튼 클릭
742
- @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[1]/button').click
743
- sleep(3)
744
- #key_stroke('escape')
745
-
746
- # 파일 경로 변환 (슬래시 -> 백슬래시)
747
- file_path = path.split('/').join("\\") # 윈도우 스타일 경로로 변환
748
-
749
- # 파일 입력 필드 찾기 (input[type="file"])
750
- file_input = @driver.find_element(:id, 'hidden-file')
751
-
752
- # send_keys로 파일 경로를 직접 입력하여 파일 업로드
753
- file_input.send_keys(file_path)
754
- sleep(3)
755
-
756
- @driver.action.key_down(:up).key_up(:up).perform
757
- sleep(1)
758
-
759
741
  begin
760
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
761
- #요소가 나타날 때까지 60초 동안 기다립니다.
762
- wait.until { @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//button[@data-name="image-resizing"]') }
763
- sleep(1)
764
- @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//button[@data-name="image-resizing"]').click
742
+ # 이미지 등록 버튼 클릭
743
+ # 기다릴 시간 설정
744
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
745
+ # 요소가 나타날 때까지 기다립니다.
746
+ wait.until { @driver.find_element(:xpath, '//ul[@class="se-toolbar se-document-toolbar se-toolbar-flexible"]//li[@class="se-toolbar-item se-toolbar-item-image"]//button[@data-name="image"]') }
747
+ # 해당 버튼을 찾고 클릭
748
+ image_button = @driver.find_element(:xpath, '//ul[@class="se-toolbar se-document-toolbar se-toolbar-flexible"]//li[@class="se-toolbar-item se-toolbar-item-image"]//button[@data-name="image"]')
749
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", image_button) # 크롤 이동
750
+ sleep(1)
751
+ @driver.find_element(:xpath, '//ul[@class="se-toolbar se-document-toolbar se-toolbar-flexible"]//li[@class="se-toolbar-item se-toolbar-item-image"]//button[@data-name="image"]').click
752
+ sleep(1)
765
753
 
766
- sleep(1)
767
- begin
768
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
769
- #요소가 나타날 때까지 60초 동안 기다립니다.
770
- wait.until { @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//div[@class="se-custom-layer-resizing-option-group"]//button[@class="se-custom-layer-resizing-reset-button"]') }
771
- sleep(1)
772
- @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//div[@class="se-custom-layer-resizing-option-group"]//button[@class="se-custom-layer-resizing-reset-button"]').click
773
- sleep(1)
774
- @driver.action.key_down(:enter).key_up(:enter).perform #엔터
775
- sleep(1)
776
- rescue
777
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
778
- #요소가 나타날 때까지 60초 동안 기다립니다.
779
- wait.until { @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//div[@class="se-custom-layer-resizing-option-group"]//button[@class="se-custom-layer-resizing-reset-button"]//span[@class="se-custom-layer-resizing-reset-label" and text()="초기화"]') }
780
- sleep(1)
781
- @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//div[@class="se-custom-layer-resizing-option-group"]//button[@class="se-custom-layer-resizing-reset-button"]//span[@class="se-custom-layer-resizing-reset-label" and text()="초기화"]').click
782
- sleep(1)
783
- @driver.action.key_down(:enter).key_up(:enter).perform #엔터
784
- sleep(1)
785
- end
786
- rescue
787
- @driver.action.key_down(:down).key_up(:down).perform
754
+ # 파일 경로 변환 (슬래시 -> 백슬래시)
755
+ file_path = path.split('/').join("\\") # 윈도우 스타일 경로로 변환
756
+ sleep(1)
757
+ # 파일 입력 필드 찾기 (input[type="file"])
758
+ file_input = @driver.find_element(:id, 'hidden-file')
759
+ sleep(1)
760
+ # send_keys로 파일 경로를 직접 입력하여 파일 업로드
761
+ file_input.send_keys(file_path)
762
+ sleep(3)
763
+
764
+ @driver.action.key_down(:up).key_up(:up).perform
765
+ sleep(1)
788
766
 
789
- end
790
-
791
-
792
- if option['사진타이틀'] == 'true'
793
767
  begin
768
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
769
+ #요소가 나타날 때까지 60초 동안 기다립니다.
770
+ wait.until { @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//button[@data-name="image-resizing"]') }
771
+ element = @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//button[@data-name="image-resizing"]')
772
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
773
+ sleep(1)
774
+ aria_expanded = element.attribute('aria-expanded')
775
+ if aria_expanded == 'false'
776
+ element.click
777
+ sleep(1) # 클릭 후 잠시 대기
778
+ else
779
+ end
780
+
781
+ begin
782
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
783
+ #요소가 나타날 때까지 60초 동안 기다립니다.
784
+ wait.until { @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//div[@class="se-custom-layer-resizing-option-group"]//button[@class="se-custom-layer-resizing-reset-button"]') }
785
+ sleep(1)
786
+ @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//div[@class="se-custom-layer-resizing-option-group"]//button[@class="se-custom-layer-resizing-reset-button"]').click
787
+ sleep(1)
788
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
789
+ sleep(1)
790
+ rescue
791
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
792
+ #요소가 나타날 때까지 60초 동안 기다립니다.
793
+ wait.until { @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//div[@class="se-custom-layer-resizing-option-group"]//button[@class="se-custom-layer-resizing-reset-button"]//span[@class="se-custom-layer-resizing-reset-label" and text()="초기화"]') }
794
+ sleep(1)
795
+ @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//div[@class="se-custom-layer-resizing-option-group"]//button[@class="se-custom-layer-resizing-reset-button"]//span[@class="se-custom-layer-resizing-reset-label" and text()="초기화"]').click
796
+ sleep(1)
797
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
798
+ sleep(1)
799
+ end
800
+ rescue
801
+ @driver.action.key_down(:down).key_up(:down).perform
802
+ end
803
+
804
+
805
+ if option['사진타이틀'] == 'true'
806
+ begin
807
+ @driver.action.key_down(:up).key_up(:up).perform
808
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
809
+ #요소가 나타날 때까지 60초 동안 기다립니다.
810
+ wait.until { @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]') }
811
+ sleep(1)
812
+ @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]').click
813
+ sleep(1)
814
+ @driver.action.send_keys(title).perform
815
+ sleep(1)
816
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
817
+ sleep(1)
818
+ rescue
819
+ @driver.action.key_down(:down).key_up(:down).perform
820
+ end
821
+ end
822
+
823
+
824
+ if i2.to_s.split('href="')[1] != nil
825
+ href2 = i2.to_s.split('href="')[1].split('"')[0]
794
826
  @driver.action.key_down(:up).key_up(:up).perform
795
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
796
- #요소가 나타날 때까지 60초 동안 기다립니다.
797
- wait.until { @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]') }
798
827
  sleep(1)
799
- @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]').click
828
+ @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[7]/div/button').click
800
829
  sleep(1)
801
- @driver.action.send_keys(title).perform
830
+ @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[7]/div/div/input').send_keys(href2)
802
831
  sleep(1)
803
- @driver.action.key_down(:enter).key_up(:enter).perform #엔터
832
+ @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[7]/div/div/button').click
804
833
  sleep(1)
805
- rescue
806
- @driver.action.key_down(:down).key_up(:down).perform
807
- end
808
- end
809
-
810
-
811
- if i2.to_s.split('href="')[1] != nil
812
- href2 = i2.to_s.split('href="')[1].split('"')[0]
813
- @driver.action.key_down(:up).key_up(:up).perform
814
- sleep(1)
815
- @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[7]/div/button').click
816
- sleep(1)
817
- @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[7]/div/div/input').send_keys(href2)
818
- sleep(1)
819
- @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[7]/div/div/button').click
820
- sleep(1)
821
- @driver.action.key_down(:enter).key_up(:enter).perform
822
- #key_stroke('enter')
823
- sleep(1)
834
+ @driver.action.key_down(:enter).key_up(:enter).perform
835
+ #key_stroke('enter')
836
+ sleep(1)
837
+ end
838
+ rescue => e
839
+ @driver.close
840
+ puts '이미지 등록실패! 인터넷 접속 불량 및 로딩 지연 다음 작업을 실행합니다.'
841
+ return 0
824
842
  end
825
843
 
826
844
  elsif i2.to_s.include?('<video')
827
845
  path = i2.to_s.split('src="')[1].split('"')[0]
828
846
  path = URI.decode_www_form(path)[0][0]
847
+ begin
848
+ @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[3]/button').click
849
+ sleep(3)
829
850
 
830
- @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[3]/button').click
831
- sleep(3)
832
-
833
-
834
- @driver.execute_script(<<~JS)
835
- window.URL.createObjectURL = function() {};
836
- HTMLInputElement.prototype.click = function() {
837
- console.log("File dialog suppressed");
838
- };
839
- JS
840
- sleep(1)
841
- # 파일 업로드 버튼 클릭 (이제 파일 선택 창이 뜨지 않음)
842
- @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/fieldset/div[1]/button[1]').click
843
- sleep(3)
844
-
845
- file_path = path.split('/').join("\\") # 윈도우 스타일 경로로 변환
846
- # 파일 입력 필드 찾기 (input[type="file"])
847
- file_input = @driver.find_element(:id, "hidden-input")
848
851
 
849
- # send_keys로 파일 경로를 직접 입력하여 파일 업로드
850
- file_input.send_keys(file_path)
851
-
852
- sleep(3)
853
- begin
854
- @driver.find_element(:xpath, '//*[@id="nvu_inp_box_title"]').send_keys(title)
852
+ @driver.execute_script(<<~JS)
853
+ window.URL.createObjectURL = function() {};
854
+ HTMLInputElement.prototype.click = function() {
855
+ console.log("File dialog suppressed");
856
+ };
857
+ JS
855
858
  sleep(1)
856
- rescue
857
- end
859
+ # 파일 업로드 버튼 클릭 (이제 파일 선택 창이 뜨지 않음)
860
+ @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/fieldset/div[1]/button[1]').click
861
+ sleep(3)
858
862
 
859
- begin
863
+ file_path = path.split('/').join("\\") # 윈도우 스타일 경로로 변환
864
+ sleep(1)
865
+ # 파일 입력 필드 찾기 (input[type="file"])
866
+ file_input = @driver.find_element(:id, "hidden-input")
867
+ sleep(1)
868
+ # send_keys로 파일 경로를 직접 입력하여 파일 업로드
869
+ file_input.send_keys(file_path)
870
+ sleep(3)
871
+
872
+ @driver.find_element(:xpath, '//*[@id="nvu_inp_box_title"]').send_keys(title)
873
+ sleep(1)
874
+
860
875
  @driver.find_element(:xpath, '//*[@id="nvu_inp_box_description"]').send_keys(title)
861
876
  sleep(1)
862
- rescue
863
- end
877
+
864
878
 
865
- begin
866
- @driver.find_element(:xpath, '//*[@id="nvu_inp_box_tag"]').send_keys(title)
879
+
880
+
881
+ tags2 = option['tag'].to_s
882
+ tag_mm2 = Array.new
883
+ tags2.split(',').each do |tag_value|
884
+ tag_mm2 << ''+tag_value
885
+ end
886
+ @driver.find_element(:xpath, '//*[@id="nvu_inp_box_tag"]').click
887
+ @driver.find_element(:xpath, '//*[@id="nvu_inp_box_tag"]').send_keys(tag_mm2.join("\n")+"\n")
867
888
  sleep(1)
868
- rescue
869
- end
870
889
 
871
- for n in 1..10
890
+ for n in 1..10
891
+ begin
892
+ puts @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text
893
+ if @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text == '업로드 완료'
894
+ break
895
+ end
896
+ sleep(10)
897
+ rescue
898
+ end
899
+ end
900
+
872
901
  begin
873
- puts @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text
874
- if @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text == '업로드 완료'
875
- break
876
- end
877
- sleep(10)
878
- rescue
879
- end
880
- end
902
+ @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[3]/button/span').click
903
+ sleep(3)
904
+ @driver.action.key_down(:up).key_up(:up).perform #x탭
905
+ sleep(1)
906
+ rescue
907
+ end
881
908
 
882
- begin
883
- @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[3]/button/span').click
884
- sleep(3)
885
- @driver.action.key_down(:up).key_up(:up).perform #x탭
886
- sleep(1)
887
- rescue
888
- end
909
+ begin
910
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
911
+ #요소가 나타날 때까지 60초 동안 기다립니다.
912
+ wait.until { @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]') }
913
+ sleep(1)
914
+ @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]').click
915
+ sleep(1)
916
+ @driver.action.send_keys(title).perform
917
+ sleep(1)
918
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
919
+ sleep(1)
920
+ rescue
921
+ @driver.action.key_down(:down).key_up(:down).perform
922
+ end
889
923
 
890
- begin
891
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
892
- #요소가 나타날 때까지 60초 동안 기다립니다.
893
- wait.until { @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]') }
894
- sleep(1)
895
- @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]').click
896
- sleep(1)
897
- @driver.action.send_keys(title).perform
898
- sleep(1)
899
- @driver.action.key_down(:enter).key_up(:enter).perform #엔터
900
- sleep(1)
901
- rescue
902
- @driver.action.key_down(:down).key_up(:down).perform
903
- end
924
+ rescue => e
925
+ @driver.close
926
+ puts '동영상 등록실패! 인터넷 접속 불량 및 로딩 지연 다음 작업을 실행합니다.'
927
+ return 0
928
+ end
904
929
 
905
930
  elsif i2.to_s.include?('<inyonggoo')
906
931
  if i2.text == ''
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-04 00:00:00.000000000 Z
11
+ date: 2025-02-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com