MShawon / YouTube-Viewer

A multithreaded view bot for YouTube
MIT License
1.5k stars 760 forks source link

Fixed entire application. Should work as intended now. #612

Open leaskeg opened 4 months ago

leaskeg commented 4 months ago

Summary

This pull request addresses an issues where the repo is not working anymore. Tested locally and it works for me as it did before.

Changes

Testing

I think thats pretty much it. Works like before - tested with proxies from webshare

Please review and merge this to fix the application

AminDhouib commented 4 months ago

image

Appreciate the effort you put there, @leaskeg, though it seems like there are still some issues when I run it. It attempts to get the chrome driver automatically but fails to do so. I attached a screenshot of the error, including the written text.

PS C:\Users\amind\OneDrive\Desktop\Projects\YouTube-Viewer> py -3.10 .\youtube_viewer.py

Yb  dP  dP"Yb  88   88 888888 88   88 88""Yb 888888
 YbdP  dP   Yb 88   88   88   88   88 88__dP 88__
  8P   Yb   dP Y8   8P   88   Y8   8P 88""Yb 88""
 dP     YbodP  `YbodP'   88   `YbodP' 88oodP 888888

                        Yb    dP 88 888888 Yb        dP 888888 88""Yb
                         Yb  dP  88 88__    Yb  db  dP  88__   88__dP
                          YbdP   88 88""     YbdPYbdP   88""   88"Yb
                           YP    88 888888    YP  YP    888888 88  Yb

           [ GitHub : https://github.com/MShawon/YouTube-Viewer ]

+-------------------------- Version: 1.8.0 --------------------------+

Getting Chrome Driver...
Traceback (most recent call last):
  File "C:\Users\amind\OneDrive\Desktop\Projects\YouTube-Viewer\youtube_viewer.py", line 1003, in <module>
    osname, exe_name = download_driver(patched_drivers=patched_drivers)
  File "C:\Users\amind\OneDrive\Desktop\Projects\YouTube-Viewer\youtubeviewer\download_driver.py", line 112, in download_driver
    uc.install()
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\site-packages\undetected_chromedriver\_compat.py", line 262, in install
    ChromeDriverManager(executable_path, target_version, *args, **kwargs).install()
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\site-packages\undetected_chromedriver\_compat.py", line 192, in install
    self.fetch_chromedriver()
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\site-packages\undetected_chromedriver\_compat.py", line 221, in fetch_chromedriver
    ver = self.get_release_version_number().vstring
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\site-packages\undetected_chromedriver\_compat.py", line 211, in get_release_version_number
    return LooseVersion(urlopen(self.__class__.DL_BASE + path).read().decode())
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 525, in open
    response = meth(req, response)
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 634, in http_response
    response = self.parent.error(
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 563, in error
    return self._call_chain(*args)
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain
    result = func(*args)
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
leaskeg commented 4 months ago

image

Appreciate the effort you put there, @leaskeg, though it seems like there are still some issues when I run it. It attempts to get the chrome driver automatically but fails to do so. I attached a screenshot of the error, including the written text.

PS C:\Users\amind\OneDrive\Desktop\Projects\YouTube-Viewer> py -3.10 .\youtube_viewer.py

Yb  dP  dP"Yb  88   88 888888 88   88 88""Yb 888888
 YbdP  dP   Yb 88   88   88   88   88 88__dP 88__
  8P   Yb   dP Y8   8P   88   Y8   8P 88""Yb 88""
 dP     YbodP  `YbodP'   88   `YbodP' 88oodP 888888

                        Yb    dP 88 888888 Yb        dP 888888 88""Yb
                         Yb  dP  88 88__    Yb  db  dP  88__   88__dP
                          YbdP   88 88""     YbdPYbdP   88""   88"Yb
                           YP    88 888888    YP  YP    888888 88  Yb

           [ GitHub : https://github.com/MShawon/YouTube-Viewer ]

+-------------------------- Version: 1.8.0 --------------------------+

Getting Chrome Driver...
Traceback (most recent call last):
  File "C:\Users\amind\OneDrive\Desktop\Projects\YouTube-Viewer\youtube_viewer.py", line 1003, in <module>
    osname, exe_name = download_driver(patched_drivers=patched_drivers)
  File "C:\Users\amind\OneDrive\Desktop\Projects\YouTube-Viewer\youtubeviewer\download_driver.py", line 112, in download_driver
    uc.install()
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\site-packages\undetected_chromedriver\_compat.py", line 262, in install
    ChromeDriverManager(executable_path, target_version, *args, **kwargs).install()
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\site-packages\undetected_chromedriver\_compat.py", line 192, in install
    self.fetch_chromedriver()
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\site-packages\undetected_chromedriver\_compat.py", line 221, in fetch_chromedriver
    ver = self.get_release_version_number().vstring
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\site-packages\undetected_chromedriver\_compat.py", line 211, in get_release_version_number
    return LooseVersion(urlopen(self.__class__.DL_BASE + path).read().decode())
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 525, in open
    response = meth(req, response)
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 634, in http_response
    response = self.parent.error(
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 563, in error
    return self._call_chain(*args)
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain
    result = func(*args)
  File "C:\Users\amind\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

Could you attempt to download the chromedriver manually and add it to the folder? Much like below? I will attempt to work on the automatic version. But for now, this should be working. Fingers crossed.

image

leaskeg commented 4 months ago

Hope that sorts the issues with getting chromedriver. Remember to follow MShawon's installation guide: image

AminDhouib commented 4 months ago

I manually inserted a ChromeDriver and gave it a fixed path using driver_executable_path. However, the script should support adding ChromeDrivers automatically.

For the time being, I installed ChromeDriver and called it chromedriver1.exe. Source for download:

Replaced the following lines at line 113:

    driver = uc.Chrome(
        driver_executable_path="./chromedriver1.exe",
        options=options,
        major_version=major_version,
    )

It works so far. But yeah, it should automatically download Chrome drivers seamlessly. I have other scripts currently using undetected Selenium that always download the latest Chrome driver correctly, so the issue lies with how it is implemented now.

Note I am using Windows.

leaskeg commented 4 months ago

I manually inserted a ChromeDriver and gave it a fixed path using driver_executable_path. However, the script should support adding ChromeDrivers automatically.

For the time being, I installed ChromeDriver and called it chromedriver1.exe. Source for download:

Replaced the following lines at line 113:

    driver = uc.Chrome(
        driver_executable_path="./chromedriver1.exe",
        options=options,
        major_version=major_version,
    )

It works so far. But yeah, it should automatically download Chrome drivers seamlessly. I have other scripts currently using undetected Selenium that always download the latest Chrome driver correctly, so the issue lies with how it is implemented now.

Note I am using Windows.

I will attempt to make the automatic download work sometime next week :) Glad it works manually tho.

AminDhouib commented 4 months ago

Thanks, @leaskeg, for your efforts! And I appreciate what you have done to bring the project back to life.

I am curious about your current fixes. Are the views still active on your analytics?

leaskeg commented 4 months ago

Thanks, @leaskeg, for your efforts! And I appreciate what you have done to bring the project back to life.

I am curious about your current fixes. Are the views still active on your analytics?

They are actually! Tried with 100 views from webshares proxies. They counted.

knofte commented 4 months ago

@leaskeg And if I get " | HTTP | Random | Lat : 13.8196 | Lon : 100.04427 | TZ: Asia/Bangkok | Detected? : True " the detected = true, I guess it's because of proxies not because of the app? (linux)

leaskeg commented 4 months ago

@leaskeg And if I get " | HTTP | Random | Lat : 13.8196 | Lon : 100.04427 | TZ: Asia/Bangkok | Detected? : True " the detected = true, I guess it's because of proxies not because of the app? (linux)

I will get back to you on that. Its possible that it detects the browser as being automated which is not ideal, because youtube would be able to detect the views as bots. But that would indicate a problem with the undetected-chromedriver im using. I will look it over!

leaskeg commented 4 months ago

I have fixed the detection issue. I will attempt to fix the automatic chromedriver mentioned above before releasing. And thank you for all the feedbacks. It really helps, you can only test so much locally 👍

leaskeg commented 4 months ago

This version should hopefully fix the issues people are mentioning here in the comments. I tested locally and it downloads the chromedriver automatically, and its also undetected. Test it out and let me know

knofte commented 4 months ago

It works, ( undetected False) however it started triggering a few other issues :)

inside chrome window: "Check if there is a typo in user-agent=mozilla"

From the python: [08-Jul-2024 16:24:47] | 7.1% | Worker 5 | Line : 643 | error | Error -3 while decompressing data: invalid stored block lengths [08-Jul-2024 16:24:48] | 7.6% | Worker 6 | Line : 643 | FileNotFoundError | 2 [08-Jul-2024 16:24:51] | 9.2% | Worker 9 | Line : 643 | BadZipFile | Bad CRC-32 for file 'chromedriver-linux64/chromedriver' [08-Jul-2024 16:26:16] | 16.3% | Worker 10 | Line : 681 | NoSuchElementException | <- I guess this is a valid one, and could mean it can't find the video? [08-Jul-2024 16:26:48] | 10.9% | Worker 7 | Line : 643 | error | Error -3 while decompressing data: invalid stored block lengths

I'll continue test though :)

leaskeg commented 4 months ago

image This is the analytics while i was simply testing a few things. Seems to work as intended. Will look into the errors above.

zaid404 commented 3 months ago

Hi @leaskeg,

I really appreciate your update. It works fine on Windows, but I’m having issues with Linux. When testing using Google Colab, it’s not working as expected. its say [18-Aug-2024 06:26:36] | 2.5% | Worker 2 | 5.189.184.6:80 | HTTP | Good Proxy | Opening a new driver... [18-Aug-2024 06:26:40] | 25.0% | Worker 2 | Line : 706 | SessionNotCreatedException | Do you have any insights on why this might be happening?

Thanks! some log.. !./chromedriver --version !google-chrome-stable --version !./patched_drivers/chromedriver_0 --version !lsb_release -a

ChromeDriver 126.0.6478.126 (d36ace6122e0a59570e258d82441395206d60e1c-refs/branch-heads/6478@{#1591}) Google Chrome for Testing 126.0.6478.126 ChromeDriver 126.0.6478.126 (d36ace6122e0a59570e258d82441395206d60e1c-refs/branch-heads/6478@{#1591}) No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy