Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

leaskeg
Copy link

@leaskeg leaskeg commented Jul 6, 2024

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

  • Updated the version number
  • Updated download_driver to support the new version of undetected_chromedriver
  • Converts major_version to an int so it doesnt cause an issue
  • ChromeOptions updated
  • Removed the loggingPrefs capability from the WebDriver initialization since it was causing an issue with the new version.
  • The loggingPrefs capability was causing an invalid argument: unrecognized capability error. Removing this capability resolves the issue and allows multiple workers to initialize correctly.
  • Updated Requirements.txt

Testing

  • Tested locally by running the script with multiple workers to ensure that the error no longer occurs and that the script functions as expected.

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

Please review and merge this to fix the application

leaskeg and others added 5 commits July 7, 2024 01:51
… loggingPrefs and improved error handling. Working as of 07-07-2024 by Leaske
Should be its original values
should be its orignal value, this was used for testing
Removed proxies, was used for testing
Copy link
Author

@leaskeg leaskeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leaskeg leaskeg changed the title Fixed chromedriver not working with the new version. Fixed issue with… Fixed entire application. Should work as intended now. Jul 7, 2024
@AminDhouib
Copy link

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
Copy link
Author

leaskeg commented Jul 7, 2024

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
Copy link
Author

leaskeg commented Jul 7, 2024

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

@AminDhouib
Copy link

AminDhouib commented Jul 7, 2024

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
Copy link
Author

leaskeg commented Jul 7, 2024

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
Copy link

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
Copy link
Author

leaskeg commented Jul 7, 2024

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
Copy link

knofte commented Jul 7, 2024

@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
Copy link
Author

leaskeg commented Jul 7, 2024

@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
Copy link
Author

leaskeg commented Jul 7, 2024

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
Copy link
Author

leaskeg commented Jul 8, 2024

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
Copy link

knofte commented Jul 8, 2024

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
Copy link
Author

leaskeg commented Jul 8, 2024

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
Copy link

zaid404 commented Aug 18, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants