@@ -85,7 +85,7 @@ class bcolors:
8585 [ GitHub : https://github.com/MShawon/YouTube-Viewer ]
8686""" + bcolors .ENDC )
8787
88- SCRIPT_VERSION = '1.4.9 '
88+ SCRIPT_VERSION = '1.5.0 '
8989
9090proxy = None
9191driver = None
@@ -122,7 +122,7 @@ class bcolors:
122122output = requests .get (link , timeout = 60 ).text
123123chrome_versions = output .split ('\n ' )
124124
125- browsers .chrome_ver + = chrome_versions
125+ browsers .chrome_ver = chrome_versions
126126
127127
128128class UrlsError (Exception ):
@@ -509,6 +509,17 @@ def bypass_signin(driver):
509509 pass
510510
511511
512+ def bypass_popup (driver ):
513+ try :
514+ agree = WebDriverWait (driver , 5 ).until (EC .visibility_of_element_located (
515+ (By .XPATH , '//*[@aria-label="Agree to the use of cookies and other data for the purposes described"]' )))
516+ driver .execute_script (
517+ "arguments[0].scrollIntoViewIfNeeded();" , agree )
518+ agree .click ()
519+ except :
520+ pass
521+
522+
512523def skip_initial_ad (driver , position , video ):
513524 try :
514525 video_len = duration_dict [video ]
@@ -750,7 +761,7 @@ def main_viewer(proxy_type, proxy, position):
750761 skip_initial_ad (driver , position , output )
751762
752763 try :
753- WebDriverWait (driver , 5 ).until (EC .element_to_be_clickable (
764+ WebDriverWait (driver , 5 ).until (EC .visibility_of_element_located (
754765 (By .XPATH , '//ytd-player[@id="ytd-player"]' )))
755766 except :
756767 raise CaptchaError
@@ -760,18 +771,22 @@ def main_viewer(proxy_type, proxy, position):
760771 if bandwidth :
761772 save_bandwidth (driver )
762773
774+ bypass_popup (driver )
775+
763776 play_video (driver )
764777
765778 view_stat = WebDriverWait (driver , 30 ).until (EC .visibility_of_element_located (
766779 (By .XPATH , '//span[@class="view-count style-scope ytd-video-view-count-renderer"]' ))).text
767780
768781 else :
769782 try :
770- WebDriverWait (driver , 5 ).until (EC .element_to_be_clickable (
783+ WebDriverWait (driver , 5 ).until (EC .visibility_of_element_located (
771784 (By .XPATH , '//*[@id="player-page"]' )))
772785 except :
773786 raise CaptchaError
774787
788+ bypass_popup (driver )
789+
775790 play_music (driver )
776791
777792 view_stat = 'music'
@@ -822,6 +837,11 @@ def main_viewer(proxy_type, proxy, position):
822837 sleep (5 )
823838 current_time = driver .execute_script (
824839 "return document.getElementById('movie_player').getCurrentTime()" )
840+ if youtube == 'Video' :
841+ play_video (driver )
842+ elif youtube == 'Music' :
843+ play_music (driver )
844+
825845 if current_time > video_len :
826846 break
827847
@@ -1007,6 +1027,7 @@ def main():
10071027 "Premium proxy needs extension to work. Chrome doesn't support extension in Headless mode." + bcolors .ENDC )
10081028 print (bcolors .WARNING +
10091029 f"Either use proxy without username & password or disable headless mode" + bcolors .ENDC )
1030+ print (input ())
10101031 sys .exit ()
10111032
10121033 if filename :
0 commit comments