From 316a8ad0beb402b8cfc02223740da7c1ffff66e5 Mon Sep 17 00:00:00 2001 From: MShawon Date: Sat, 14 May 2022 03:34:57 +0600 Subject: [PATCH] fixes #369, improvements and bug fixes --- extension/always_active.zip | Bin 38885 -> 38852 bytes extension/fingerprint_defender.zip | Bin 5260 -> 5260 bytes extension/spoof_timezone.zip | Bin 120434 -> 120399 bytes extension/webrtc_control.zip | Bin 45214 -> 45183 bytes requirements.txt | Bin 1530 -> 1560 bytes youtube_viewer.py | 85 ++++++++++++++-------- youtubeviewer/basics.py | 4 +- youtubeviewer/bypass.py | 2 +- youtubeviewer/web/static/app.js | 1 + youtubeviewer/web/templates/homepage.html | 7 +- youtubeviewer/website.py | 4 +- 11 files changed, 68 insertions(+), 35 deletions(-) diff --git a/extension/always_active.zip b/extension/always_active.zip index 6c0d2b7d262b426369d0f6a9443f8d951afbdef8..32f5074218d02afd600934471b38229d783d3315 100644 GIT binary patch delta 921 zcmaF5p6SSXrVXr&%nwA?P3B-!0MVPZ8O2(`441ZD9QAKS)`b|@9R9X~k%3_kGXn!J z0|P^DVqRuiYH^8PR&jn_>?Gg3#|AvD-z{5@y}p)rMms-I-9T)Fr2TT_9Q zgD0=;-g4P}UGKNgm+I!->i>DD?o9f(%a`hA-I~30@64OK&mOv$n|AS2s;U@ugCf7U;Dw7NBw$gwalK3p}cIW zKhNHNQh)ic=Qn4&+pn24TuefJ)-yF9xTL%Py+uSoqr26+Mfb(`owc)E z_V10GzhP13w;dU3YxZeZS@IpwzjyvY8a=xWzaG!uKEU4o)kgCz~fpZs%T7%PJ=$9Ja54<}1c&Y$Fr#JhyTGo9>$BsX(1 zLS-D1c>ENExb)=jp?s4sOff@}Us=vK*<`9ITts|w>r@+c2JV^LC4rvyFDab@_B51_ z?vWQ$EyQN;t^#```~k$%kU*GhHZ6+n(XvC+fPSidgX6 uit(akn#rBh_4LljvUh?k)@87^(RIO>niniKN))W%gO85tP`0nEa{uq@}TZ`mxU&AI3&=wd^ULwcjXCdD}lz-=$#*7t%dbbC)Vk+~#S! zBhJ$!*?pSV_jB9pXY(fS5pdVaB9H-3gp)BOkt*`e|c!gTUp3bEEIf z$X{!#9UN%8q3(g!+6g5~93{RabU5ueX7xj`{zg;w6!}BdzaG|4^7vApF?U77Wh^-5ED`&7D%|SQc^K?bMzJ8={Y^tBOqcFS#w0 z<7b%V?U_YUkv1JKOT|)89{s#v-oAQC7q_YxHP_51Ni}Y2Tkv6iiSOa;U-5rTo)ynM z$=cQtR_2?qprGQseaW1;8BC0^?6)P QAQ=x;H|_x^3vT{r(;jKd?NY8w-2zx&VU z&Jr__x%d6iF(#)eAMEblG$?=j!b|g$@8KB<5Ay8H;{&`Ind})vfKklBV7_in2 zHz%0#+Es0zA|8E%v1|VvZ^_9ACX2E%Fo05w=|ltd8K+{zxqxztb^>N1K>F+yA21(b z6hv*$L^Dxl*J!ZZC2__1AoF4!{lvK@Gfozs{A!{LD`$f8d~u-Z(v$rrIkVQZ!+0Bk zygzGUJdw#RNW6;4&aB_AK;+_Bzx;-&vYX<}`dUc^YToxyzRBySn6Ylz2NPLY&No?j zswrGVd~(WE8(!(xUfU&s?#gBl+K%kc<5Mj}TQ4Pm-7ek(@h8~dV7IGJ^I%=_6lQY& zG*2Ynk7@1*9w$5>P0pCEH~H=q4mGeopp6W=9N(FMbbvQ28!+@4gn;llko95$hz9@$ C_nM9X diff --git a/extension/fingerprint_defender.zip b/extension/fingerprint_defender.zip index 0d7cb7128aa83b387b10ad922f87ea0faeac2fa3..3be74e8a401823d8c074fa4113ba24ff18bd421c 100644 GIT binary patch delta 134 zcmeCt?9trtQ;4rup}vSS{RSh$<#p}v@+Y$k`-+J+v_OPJR9WBTUuO*PW@NHwnB31H zF}X=tn=k)fD@6L-i<0;GlXnXT@};%iJ`6U*?DebH`IDtYeAI$AE`tayIy~zW*br7W R1|VPs!gGua3@d~{JOD5}F1r8# delta 134 zcmeCt?9trtQ;6@c)(mE~g6oWXJq~|REtt$M>?^iw`W&#(oqUkcb;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FS6Sjfn(l2n8G+cxFb9&uLMhRY+RSiHZ!>3;WD(7c7$7Us^d4&;5PyY`x%6z)^ lHAY3X>8Vl>zZqRLUkMH}RyL4hrGc=Xi-BR+X<%W<001SpH9i0U delta 1430 zcmX@VhW*nT_6^rrS^Q1^`AojeD$i1(Wa_i|AL|Ea!G0i%0SSmqHuMtTEas&U%ko|j zsK{!$uynlyi)mo?kN%23j0_AuEDQ|1Kn=Nxd6{Xc#U*-K#rb)$A*YKT83^q8EUG21 zxuMy4MaaLz@0)fm)tElv__hw6ol6Wict5>g{>4C|@0HxwFE&eFD@nJ{QVv-hdXxRM z)scg>BCP>JCcBLCdox9!9QxAATs?`Yt75TE%ifgLN1N(5u6Z71_F#imW9g-gAg%Cu zJLYemzUR#SO$}N1n%n>J95Z#6{`jv^FWvu0 z$?v7r!Gd#fc^JBQ&Qyohg|9uiG?uJ;IH~-`>f3H5 z)6RtP{nwK3D{GmpV|r=(f?1+-k5u<9Vs_e>m%Tmy?20b=GaXkQ3;)gy5k5P0m6W&s zN!v$dS458|-00ZIpE)slPK})NFO$St7F9tjxhMgnblItnruH?QDZSUfcK7{nsNc4I z<`FfWIl;Y<@hMNexIJs88C)1f&DJ z8JX-EM8HW7lpd#Ro?+D2V31cbnx}q+@p=E8y~_))GoDpzswU`0ylHC5q2L*=oAsc}BbGy%!ld z_%CgPcxx- zTnq|eV;LDF7#PwoaFsM%V`ObD2Rqeh2SisRP#0s>^tD$R75Jm-E5ULBY$;&d?ttW? lrgL0lR8;G8sshVFQzbCuSlK{^O9Np&7X!oH)4*bs0RS!0M&$qi diff --git a/extension/webrtc_control.zip b/extension/webrtc_control.zip index bfcb880ed0cbf047809f786bb4a9bd525e167018..b1576401dbef1b355c6bb4abe23fd54bc56af03c 100644 GIT binary patch delta 1607 zcmbRDkm>&erU}(7cSP2OOstm|1knsgKxE=W@r}n;F@Y6qE@3u-vevLRIbkZET<9Ub zIn2Xb5u$u)W~dT`^{<yM6ij0_ChSQr?1fi~tQ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$02uEOQwFxegJk delta 47 zcmbQi^NV|f1|y@ {youtube} Found : {output} | Watch Duration : {duration} "}) if youtube == 'Video' and collect_id: - video_id = driver.find_element( - By.XPATH, '//*[@id="page-manager"]/ytd-watch-flexy').get_attribute('video-id') - if video_id and video_id not in suggested: - suggested.append(video_id) + try: + video_id = driver.find_element( + By.XPATH, '//*[@id="page-manager"]/ytd-watch-flexy').get_attribute('video-id') + if video_id and video_id not in suggested: + suggested.append(video_id) + except WebDriverException: + pass error = 0 loop = int(video_len/4) @@ -407,12 +415,16 @@ def control_player(driver, output, position, proxy, youtube, collect_id=True): if error == 10: error_msg = f'Taking too long to play the video | Reason : buffering' if current_state == -1: - error_msg = f'Failed to play the video | Possible Reason : {proxy} not working anymore' + error_msg = f"Failed to play the video | Possible Reason : {proxy.split('@')[-1]} not working anymore" raise Exception(error_msg) elif current_time > video_len or driver.current_url != current_url: break + output = textwrap.fill(text=output, width=75, break_on_hyphens=False) + video_statistics[output] = video_statistics.get(output, 0) + 1 + website.html_table = tabulate(video_statistics.items(), headers=headers, + showindex=True, numalign='center', stralign='center', tablefmt="html") return current_url @@ -449,7 +461,7 @@ def music_and_video(proxy, position, youtube, driver, output, view_stat): for i in range(rand_choice): if i == 0: current_url = control_player( - driver, output, position, proxy, youtube) + driver, output, position, proxy, youtube, collect_id=True) update_view_count(position) @@ -463,7 +475,8 @@ def music_and_video(proxy, position, youtube, driver, output, view_stat): try: output = play_next_video(driver, suggested) except WebDriverException as e: - raise Exception(f'Error suggested | {e.args[0]}') + raise Exception( + f'Error suggested | {type(e).__name__} | {e.args[0]}') print(timestamp() + bcolors.OKBLUE + f"Worker {position} | Found next suggested video : [{output}]" + bcolors.ENDC) @@ -476,7 +489,7 @@ def music_and_video(proxy, position, youtube, driver, output, view_stat): features(driver) current_url = control_player( - driver, output, position, proxy, youtube) + driver, output, position, proxy, youtube, collect_id=False) update_view_count(position) @@ -495,7 +508,8 @@ def channel_or_endscreen(proxy, position, youtube, driver, view_stat, current_ur try: output, log, option = play_from_channel(driver, channel_name) except WebDriverException as e: - raise Exception(f'Error channel | {e.args[0]}') + raise Exception( + f'Error channel | {type(e).__name__} | {e.args[0]}') print(timestamp() + bcolors.OKBLUE + f"Worker {position} | {log}" + bcolors.ENDC) @@ -506,7 +520,8 @@ def channel_or_endscreen(proxy, position, youtube, driver, view_stat, current_ur try: output = play_end_screen_video(driver) except WebDriverException as e: - raise Exception(f'Error end screen | {e.args[0]}') + raise Exception( + f'Error end screen | {type(e).__name__} | {e.args[0]}') print(timestamp() + bcolors.OKBLUE + f"Worker {position} | Video played from end screen : [{output}]" + bcolors.ENDC) @@ -538,7 +553,7 @@ def windows_kill_drivers(): def quit_driver(driver, data_dir): - if driver in driver_dict: + if driver and driver in driver_dict: driver.quit() if data_dir in temp_folders: temp_folders.remove(data_dir) @@ -553,6 +568,8 @@ def quit_driver(driver, data_dir): def main_viewer(proxy_type, proxy, position): global width, viewports + driver = None + data_dir = None if cancel_all: raise KeyboardInterrupt @@ -595,6 +612,7 @@ def main_viewer(proxy_type, proxy, position): while proxy in bad_proxies: bad_proxies.remove(proxy) + sleep(1) patched_driver = os.path.join( patched_drivers, f'chromedriver_{position%threads}{exe_name}') @@ -668,12 +686,11 @@ def main_viewer(proxy_type, proxy, position): status = quit_driver(driver=driver, data_dir=data_dir) except Exception as e: - *_, exc_tb = sys.exc_info() print(timestamp() + bcolors.FAIL + - f"Worker {position} | Line : {exc_tb.tb_lineno} | " + str(e.args[0]) + bcolors.ENDC) + f"Worker {position} | Line : {e.__traceback__.tb_lineno} | {type(e).__name__} | {e.args[0]}" + bcolors.ENDC) create_html( - {"#f14c4c": f"Worker {position} | Line : {exc_tb.tb_lineno} | " + str(e.args[0])}) + {"#f14c4c": f"Worker {position} | Line : {e.__traceback__.tb_lineno} | {type(e).__name__} | {e.args[0]}"}) status = quit_driver(driver=driver, data_dir=data_dir) @@ -689,10 +706,10 @@ def main_viewer(proxy_type, proxy, position): except Exception as e: print(timestamp() + bcolors.FAIL + - f"Worker {position} | {e.args[0]}" + bcolors.ENDC) + f"Worker {position} | Line : {e.__traceback__.tb_lineno} | {type(e).__name__} | {e.args[0]}" + bcolors.ENDC) create_html( - {"#f14c4c": f"Worker {position} | {e.args[0]}"}) + {"#f14c4c": f"Worker {position} | Line : {e.__traceback__.tb_lineno} | {type(e).__name__} | {e.args[0]}"}) def get_proxy_list(): @@ -794,7 +811,7 @@ def view_video(position): def main(): - global cancel_all, proxy_list, total_proxies, threads, hash_config, futures + global cancel_all, proxy_list, total_proxies, threads, hash_config, futures, cpu_usage cancel_all = False start_time = time() @@ -819,7 +836,8 @@ def main(): if api: threads += 1 - pool_number = [i for i in range(total_proxies)] + loop = 0 + pool_number = list(range(total_proxies)) with ThreadPoolExecutor(max_workers=threads) as executor: futures = [executor.submit(view_video, position) @@ -830,7 +848,16 @@ def main(): while not_done: freshly_done, not_done = wait(not_done, timeout=1) done |= freshly_done - sleep(15) + + loop += 1 + for _ in range(70): + cpu = str(psutil.cpu_percent(0.2)) + cpu_usage = cpu + '%' + ' ' * \ + (5-len(cpu)) if cpu != '0.0' else cpu_usage + + if loop % 40 == 0: + print(tabulate(video_statistics.items(), + headers=headers, showindex=True, tablefmt="pretty")) if len(view) >= views: print(timestamp() + bcolors.WARNING + @@ -886,7 +913,7 @@ def main(): clean_exe_temp(folder='youtube_viewer') date_fmt = datetime.now().strftime("%d-%b-%Y %H:%M:%S") - cpu_usage = str(psutil.cpu_percent()) + cpu_usage = str(psutil.cpu_percent(1)) update_chrome_version() check_update() osname, exe_name = download_driver(patched_drivers=patched_drivers) diff --git a/youtubeviewer/basics.py b/youtubeviewer/basics.py index 34d23d7..0b3d847 100644 --- a/youtubeviewer/basics.py +++ b/youtubeviewer/basics.py @@ -177,16 +177,16 @@ def play_music(driver): def type_keyword(driver, keyword, retry=False): - input_keyword = driver.find_element(By.CSS_SELECTOR, 'input#search') if retry: for _ in range(30): try: - input_keyword.click() + driver.find_element(By.CSS_SELECTOR, 'input#search').click() break except WebDriverException: sleep(3) + input_keyword = driver.find_element(By.CSS_SELECTOR, 'input#search') input_keyword.clear() for letter in keyword: input_keyword.send_keys(letter) diff --git a/youtubeviewer/bypass.py b/youtubeviewer/bypass.py index d6918d5..2a0f022 100644 --- a/youtubeviewer/bypass.py +++ b/youtubeviewer/bypass.py @@ -93,7 +93,7 @@ def bypass_popup(driver): except WebDriverException: try: agree = driver.find_element( - By.XPATH, '//*[@aria-label="Accept the use of cookies and other data for the purposes described"]') + By.XPATH, f'//*[@aria-label="{choice(["Accept","Reject"])} the use of cookies and other data for the purposes described"]') click_popup(driver=driver, element=agree) except WebDriverException: pass diff --git a/youtubeviewer/web/static/app.js b/youtubeviewer/web/static/app.js index 08b5fd1..859ddb9 100644 --- a/youtubeviewer/web/static/app.js +++ b/youtubeviewer/web/static/app.js @@ -47,6 +47,7 @@ function queryLogs() { for (i = 1; i < 201; i++) { $('#logs-' + i).html(data.console[i - 1]); } + $('#video_statistics').html(data.table); }); } diff --git a/youtubeviewer/web/templates/homepage.html b/youtubeviewer/web/templates/homepage.html index c5f4213..9d7b0f4 100644 --- a/youtubeviewer/web/templates/homepage.html +++ b/youtubeviewer/web/templates/homepage.html @@ -6,7 +6,7 @@ - + @@ -50,6 +50,11 @@

Live Logs

Statistics + + +
+