|
@@ -0,0 +1,135 @@
|
|
|
+import traceback
|
|
|
+from selenium import webdriver
|
|
|
+from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
|
+import time
|
|
|
+import os
|
|
|
+import datetime
|
|
|
+import urllib.parse
|
|
|
+from selenium.webdriver.support.ui import WebDriverWait
|
|
|
+from selenium.webdriver.common.by import By
|
|
|
+from selenium.webdriver.support import expected_conditions as EC
|
|
|
+from selenium.webdriver.common.keys import Keys
|
|
|
+import codecs
|
|
|
+import random
|
|
|
+import requests
|
|
|
+import time
|
|
|
+import rpyc
|
|
|
+import sys
|
|
|
+import codecs
|
|
|
+import sys
|
|
|
+import time
|
|
|
+import dataset
|
|
|
+import os
|
|
|
+
|
|
|
+def scrolling(driver,pgnum):
|
|
|
+ ub = driver.find_element_by_css_selector('body')
|
|
|
+ for i in range(pgnum):
|
|
|
+ ub.send_keys(Keys.PAGE_DOWN)
|
|
|
+ if pgnum>1:
|
|
|
+ time.sleep(0.3)
|
|
|
+
|
|
|
+
|
|
|
+def restart_browser():
|
|
|
+# os.system('docker container restart p4444')
|
|
|
+# time.sleep(10)
|
|
|
+
|
|
|
+ options = webdriver.ChromeOptions()
|
|
|
+# options.add_argument("--proxy-server=socks5://130.61.93.198:1080")
|
|
|
+ options.add_argument("start-maximized")
|
|
|
+ options.add_argument('user-data-dir=C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data')
|
|
|
+ options.add_argument('--profile-directory=Profile 7')
|
|
|
+
|
|
|
+ driver=webdriver.Chrome(desired_capabilities=options.to_capabilities())
|
|
|
+ driver.set_window_size(1400,1000)
|
|
|
+ return driver
|
|
|
+
|
|
|
+db2 = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/hhh?charset=utf8mb4')
|
|
|
+#cursor=db2.query('select * from yt_tasks where yid not in (SELECT yid FROM hhh.yt_hhh_progress)')
|
|
|
+cursor=db2.query('select * from yt_tasks2 where yid not in (SELECT yid FROM hhh.yt_hhh_progress)')
|
|
|
+
|
|
|
+table=db2['yt_hhh_progress']
|
|
|
+yid=spath=title=desc=None
|
|
|
+for c in cursor:
|
|
|
+ print(c)
|
|
|
+ yid=c['yid']
|
|
|
+ spath=c['path']
|
|
|
+ print(spath)
|
|
|
+
|
|
|
+ title=c['title']
|
|
|
+ desc=c['desc']
|
|
|
+ break
|
|
|
+
|
|
|
+driver=restart_browser()
|
|
|
+url='https://www.youtube.com/upload'
|
|
|
+
|
|
|
+driver.get(url)
|
|
|
+print(spath)
|
|
|
+
|
|
|
+time.sleep(5)
|
|
|
+elmt=driver.find_element_by_xpath("//input[@type='file']")
|
|
|
+elmt.send_keys(spath)
|
|
|
+time.sleep(6)
|
|
|
+
|
|
|
+elmts=driver.find_elements_by_xpath("//div[@id='textbox']")
|
|
|
+elmt=elmts[0]
|
|
|
+elmt.click()
|
|
|
+for i in range(20):
|
|
|
+ elmt.send_keys(Keys.BACKSPACE)
|
|
|
+ time.sleep(0.1)
|
|
|
+elmt.send_keys(title)
|
|
|
+time.sleep(1)
|
|
|
+
|
|
|
+elmt=elmts[1]
|
|
|
+elmt.click()
|
|
|
+for i in range(15):
|
|
|
+ elmt.send_keys(Keys.ARROW_UP)
|
|
|
+ time.sleep(0.1)
|
|
|
+elmt.send_keys(Keys.RETURN)
|
|
|
+elmt.send_keys(Keys.ARROW_UP)
|
|
|
+
|
|
|
+elmt.send_keys(desc)
|
|
|
+elmt.send_keys(Keys.RETURN)
|
|
|
+
|
|
|
+time.sleep(1)
|
|
|
+
|
|
|
+elmt=driver.find_element_by_xpath("//*[@id='next-button']")
|
|
|
+elmt.click()
|
|
|
+time.sleep(3)
|
|
|
+
|
|
|
+elmt=driver.find_element_by_xpath("//*[@id='next-button']")
|
|
|
+elmt.click()
|
|
|
+time.sleep(3)
|
|
|
+
|
|
|
+elmt=driver.find_element_by_xpath("//*[@id='next-button']")
|
|
|
+elmt.click()
|
|
|
+
|
|
|
+elmt=driver.find_element_by_xpath("//div[@class='value style-scope ytcp-video-info']")
|
|
|
+new_yid=elmt.text
|
|
|
+table.insert({'yid':yid,'new_yid':new_yid,'dt':datetime.datetime.now()})
|
|
|
+
|
|
|
+#time.sleep(9999)
|
|
|
+
|
|
|
+time.sleep(3)
|
|
|
+elmt=driver.find_element_by_xpath("//*[@id='done-button']")
|
|
|
+elmt.click()
|
|
|
+time.sleep(3)
|
|
|
+
|
|
|
+cnt=0
|
|
|
+while True:
|
|
|
+ try:
|
|
|
+ cnt+=1
|
|
|
+# elmt=driver.find_element_by_xpath("//span[contains(text(),'檢查完畢,未發現任何問題')]")
|
|
|
+
|
|
|
+# if cnt >=20:
|
|
|
+# break
|
|
|
+ elmt=driver.find_element_by_xpath("//span[contains(text(),'檢查完畢,未發現任何問題')]")
|
|
|
+ break
|
|
|
+ except:
|
|
|
+ print('not yet')
|
|
|
+ time.sleep(5)
|
|
|
+
|
|
|
+driver.quit()
|
|
|
+#檢查完畢,未發現任何問題。
|
|
|
+sys.exit()
|
|
|
+#time.sleep(9999)
|
|
|
+
|