Jared 2 年之前
父節點
當前提交
4ac48b5bc0
共有 1 個文件被更改,包括 49 次插入7 次删除
  1. 49 7
      choozmo/watch_yt.py

+ 49 - 7
choozmo/watch_yt.py

@@ -22,7 +22,7 @@ def init_browser(proxy1='proxy1',tiny1='tiny1',socks5="9050",debug='9922',cdrive
     os.system('docker container restart '+proxy1)
     os.system('docker container restart '+tiny1)
 
-    time.sleep(11)
+    time.sleep(12)
     options = webdriver.ChromeOptions()
     options.add_argument('--headless')
     options.add_argument('--proxy-server=socks5://127.0.0.1:'+socks5)
@@ -58,7 +58,12 @@ class JParams(object):
     url='https://www.youtube.com/watch?v='+yt
     driver=init_browser(proxy1='proxy1',tiny1='tiny1',socks5="9050",debug='9922',cdriver='/root/webdriver/98/chromedriver')
     #driver.get('https://www.youtube.com/watch?v=K5DEJXajtqA')
-    driver.get(url)
+    try:
+        driver.get(url)
+    except:
+        driver.quit()
+        sys.exit()
+        return
     video = driver.find_element_by_id('movie_player')
     video.send_keys(Keys.SPACE) #hits space
     time.sleep(1)
@@ -67,7 +72,15 @@ class JParams(object):
     driver.execute_script('window.open("'+url+'","_blank");')
     driver.execute_script("window.scrollTo(0, window.scrollY + 400)")
     time.sleep(3)
-    driver.get(url)
+
+    try:
+        driver.get(url)
+    except:
+        driver.quit()
+        sys.exit()
+        return
+
+
     video = driver.find_element_by_id('movie_player')
     video.send_keys(Keys.SPACE) #hits space
     time.sleep(1)
@@ -76,7 +89,14 @@ class JParams(object):
     driver.execute_script('window.open("'+url+'","_blank");')
     driver.execute_script("window.scrollTo(0, window.scrollY + 400)")
     time.sleep(3)
-    driver.get(url)
+
+    try:
+        driver.get(url)
+    except:
+        driver.quit()
+        sys.exit()
+        return
+
     video = driver.find_element_by_id('movie_player')
     video.send_keys(Keys.SPACE) #hits space
     time.sleep(1)
@@ -86,7 +106,14 @@ class JParams(object):
     driver.execute_script('window.open("'+url+'","_blank");')
     driver.execute_script("window.scrollTo(0, window.scrollY + 400)")
     time.sleep(3)
-    driver.get(url)
+
+    try:
+        driver.get(url)
+    except:
+        driver.quit()
+        sys.exit()
+        return
+
     video = driver.find_element_by_id('movie_player')
     video.send_keys(Keys.SPACE) #hits space
     time.sleep(1)
@@ -95,7 +122,15 @@ class JParams(object):
     driver.execute_script('window.open("'+url+'","_blank");')
     driver.execute_script("window.scrollTo(0, window.scrollY + 400)")
     time.sleep(3)
-    driver.get(url)
+
+    try:
+        driver.get(url)
+    except:
+        driver.quit()
+        sys.exit()
+        return
+
+
     video = driver.find_element_by_id('movie_player')
     video.send_keys(Keys.SPACE) #hits space
     time.sleep(1)
@@ -104,7 +139,14 @@ class JParams(object):
     driver.execute_script('window.open("'+url+'","_blank");')
     driver.execute_script("window.scrollTo(0, window.scrollY + 400)")
     time.sleep(3)
-    driver.get(url)
+
+    try:
+        driver.get(url)
+    except:
+        driver.quit()
+        sys.exit()
+        return
+
     video = driver.find_element_by_id('movie_player')
     video.send_keys(Keys.SPACE) #hits space
     time.sleep(1)