Jared 2 years ago
parent
commit
9f4219ba67
1 changed files with 17 additions and 5 deletions
  1. 17 5
      choozmo/watch_yt.py

+ 17 - 5
choozmo/watch_yt.py

@@ -21,6 +21,8 @@ import fire
 from userAgentRandomizer import userAgents
 
 
+
+
 def init_browser(proxy1='proxy1',tiny1='tiny1',socks5="9050",debug='9922',cdriver=''):
     os.system('docker container restart '+proxy1)
     os.system('docker container restart '+tiny1)
@@ -30,7 +32,7 @@ def init_browser(proxy1='proxy1',tiny1='tiny1',socks5="9050",debug='9922',cdrive
     time.sleep(12)
     options = webdriver.ChromeOptions()
     options.add_argument('--headless')
-    options.add_argument('--proxy-server=socks5://127.0.0.1:'+socks5)
+#    options.add_argument('--proxy-server=socks5://127.0.0.1:'+socks5)
     options.add_argument('--disable-dev-shm-usage')
     options.add_argument('--no-sandbox')
     options.add_argument("--user-agent=" +user_agent)
@@ -42,8 +44,8 @@ def init_browser(proxy1='proxy1',tiny1='tiny1',socks5="9050",debug='9922',cdrive
 
 #    options.add_argument("--user-agent=" +user_agent)
     options.add_argument("--incognito")
-#    driver = webdriver.Chrome(executable_path=r'C:\portable\webdriver\chrome98\chromedriver.exe',options=options)
-    driver = webdriver.Chrome(executable_path=cdriver,options=options)
+    driver = webdriver.Chrome(executable_path=r'C:\portable\webdriver\chrome98\chromedriver.exe',options=options)
+#    driver = webdriver.Chrome(executable_path=cdriver,options=options)
 
 #    driver = webdriver.Chrome(executable_path=epath,options=options)
 
@@ -53,12 +55,19 @@ def init_browser(proxy1='proxy1',tiny1='tiny1',socks5="9050",debug='9922',cdrive
     print(q)
     process_query(q)
 
-
+db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
+yt_lst=[]
+cursor=db.query('select * from sbir_yt')
+for c in cursor:
+    yt_lst.append(c['url'])
 
 class JParams(object):
 
   def get(self, yt,proxy1,tiny1,socks5,debug,cdriver):
-    url='https://www.youtube.com/watch?v='+yt
+    if 'SBIR' in yt:    
+        yt=random.choice(yt_lst)
+        url='https://www.youtube.com/watch?v='+yt
+        print(url)
     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')
     try:
@@ -159,6 +168,9 @@ class JParams(object):
     driver.quit()
     sys.exit()
 
+
+
+
 if __name__ == '__main__':
   fire.Fire(JParams)