alexlaverty / python-reddit-youtube-bot

Automated Reddit Youtube Video Bot
https://www.youtube.com/channel/UCzIwW92D_rM5_yvWBsquSbw
83 stars 19 forks source link

playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded #42

Open becauseimnoob opened 1 year ago

becauseimnoob commented 1 year ago

test page : https://www.reddit.com/r/Turkey/comments/y8rhm1/sezgin_tanr%C4%B1kulunun_tweeti/

Downloading screenshots of reddit posts...
Launching Headless Browser...
Traceback (most recent call last):
  File "C:\Users\xsd\Desktop\ttsvibelounge\app.py", line 288, in <module>
    process_submissions(submissions)
  File "C:\Users\xsd\Desktop\ttsvibelounge\app.py", line 49, in process_submissions
    process_submission(submission)
  File "C:\Users\xsd\Desktop\ttsvibelounge\app.py", line 92, in process_submission
    vid.create(video_directory=video.folder_path,
  File "C:\Users\xsd\Desktop\ttsvibelounge\video_generation\video.py", line 357, in create
    download_screenshots_of_reddit_posts(
  File "C:\Users\xsd\Desktop\ttsvibelounge\comments\screenshot.py", line 69, in download_screenshots_of_reddit_posts
    page.locator('[data-test-id="post-content"]').screenshot(
  File "C:\Users\xsd\Desktop\ttsvibelounge\venv\lib\site-packages\playwright\sync_api\_generated.py", line 13139, in screenshot
    self._sync(
  File "C:\Users\xsd\Desktop\ttsvibelounge\venv\lib\site-packages\playwright\_impl\_sync_base.py", line 89, in _sync
    return task.result()
  File "C:\Users\xsd\Desktop\ttsvibelounge\venv\lib\site-packages\playwright\_impl\_locator.py", line 394, in screenshot
    return await self._with_element(
  File "C:\Users\xsd\Desktop\ttsvibelounge\venv\lib\site-packages\playwright\_impl\_locator.py", line 99, in _with_element
    handle = await self.element_handle(timeout=timeout)
  File "C:\Users\xsd\Desktop\ttsvibelounge\venv\lib\site-packages\playwright\_impl\_locator.py", line 219, in element_handle
    handle = await self._frame.wait_for_selector(
  File "C:\Users\xsd\Desktop\ttsvibelounge\venv\lib\site-packages\playwright\_impl\_frame.py", line 307, in wait_for_selector
    await self._channel.send("waitForSelector", locals_to_params(locals()))
  File "C:\Users\xsd\Desktop\ttsvibelounge\venv\lib\site-packages\playwright\_impl\_connection.py", line 43, in send
    return await self._connection.wrap_api_call(
  File "C:\Users\xsd\Desktop\ttsvibelounge\venv\lib\site-packages\playwright\_impl\_connection.py", line 370, in _
    return await result
  File "C:\Users\xsd\Desktop\ttsvibelounge\venv\lib\site-packages\playwright\_impl\_connection.py", line 78, in inner_send
    result = next(iter(done)).result()
playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "[data-test-id="post-content"]"
============================================================
alexlaverty commented 1 year ago

Other users are having this issue too I will look into it

alexlaverty commented 1 year ago

I've pushed a code change to make the screenshot timeouts configurable which you can change in settings.py :

Try increasing the timeout value and see if that helps at all, maybe set it to 100000 :

comment_screenshot_timeout = 30000

https://github.com/alexlaverty/ttsvibelounge/blob/main/config/settings.py#L47

Also if you want to debug more you can change headless mode to False :

        browser = p.chromium.launch(headless=False)

https://github.com/alexlaverty/ttsvibelounge/blob/main/comments/screenshot.py#L36

If you change to false, when you run the script the browser will be visible and you can watch it and see if it's getting stuck on something.

Also @anhdodotnet you might want to test this out as well

becauseimnoob commented 1 year ago

I've pushed a code change to make the screenshot timeouts configurable which you can change in settings.py :

Try increasing the timeout value and see if that helps at all, maybe set it to 100000 :

comment_screenshot_timeout = 30000

https://github.com/alexlaverty/ttsvibelounge/blob/main/config/settings.py#L47

Also if you want to debug more you can change headless mode to False :

        browser = p.chromium.launch(headless=False)

https://github.com/alexlaverty/ttsvibelounge/blob/main/comments/screenshot.py#L36

If you change to false, when you run the script the browser will be visible and you can watch it and see if it's getting stuck on something.

Also @anhdodotnet you might want to test this out as well

test page : https://www.reddit.com/r/Turkey/comments/y8rhm1/sezgin_tanr%C4%B1kulunun_tweeti/

The reason for the error is opening the picture on this topic, so it does not find the comments, for example, the link I gave above opens this link and stays there, which causes an error https://i.redd.it/44f6wgzexwu91.png

I haven't tried your last commit. I found where the error came from before, but I did not have the opportunity to write to you. I will try your latest update now I'm a little busy these days, I'll edit my comment again when I try

sebbourgeois commented 1 year ago

I do have the same issue, with repo pulled today.

Downloading screenshots of reddit posts...
Launching Headless Browser...
Traceback (most recent call last):
  File "/home/sb/videos-creation/python-reddit-youtube-bot/app.py", line 321, in <module>
    process_submissions(submissions)
  File "/home/sb/videos-creation/python-reddit-youtube-bot/app.py", line 49, in process_submissions
    process_submission(submission)
  File "/home/sb/videos-creation/python-reddit-youtube-bot/app.py", line 92, in process_submission
    vid.create(video_directory=video.folder_path,
  File "/home/sb/videos-creation/python-reddit-youtube-bot/video_generation/video.py", line 399, in create
    download_screenshots_of_reddit_posts(
  File "/home/sb/videos-creation/python-reddit-youtube-bot/comments/screenshot.py", line 70, in download_screenshots_of_reddit_posts
    page.locator('[data-test-id="post-content"]').screenshot(
  File "/home/sb/.local/lib/python3.10/site-packages/playwright/sync_api/_generated.py", line 13139, in screenshot
    self._sync(
  File "/home/sb/.local/lib/python3.10/site-packages/playwright/_impl/_sync_base.py", line 89, in _sync
    return task.result()
  File "/home/sb/.local/lib/python3.10/site-packages/playwright/_impl/_locator.py", line 394, in screenshot
    return await self._with_element(
  File "/home/sb/.local/lib/python3.10/site-packages/playwright/_impl/_locator.py", line 99, in _with_element
    handle = await self.element_handle(timeout=timeout)
  File "/home/sb/.local/lib/python3.10/site-packages/playwright/_impl/_locator.py", line 219, in element_handle
    handle = await self._frame.wait_for_selector(
  File "/home/sb/.local/lib/python3.10/site-packages/playwright/_impl/_frame.py", line 307, in wait_for_selector
    await self._channel.send("waitForSelector", locals_to_params(locals()))
  File "/home/sb/.local/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 43, in send
    return await self._connection.wrap_api_call(
  File "/home/sb/.local/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 370, in _
    return await result
  File "/home/sb/.local/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 78, in inner_send
    result = next(iter(done)).result()
playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "[data-test-id="post-content"]"
============================================================

I did change the timeout setting in the conf/settings,py file, made it to 100000, but I still have the Timeout 30000ms message.

johnnyvng commented 1 year ago

I got the same error here.

sebbourgeois commented 1 year ago

@alexlaverty I usually run this script on a Linux server, so headless. To try to understand what was happening, I started running it on my Windows computer, without headless.

From what I saw, from time to time, the pages are displayed without the dark mode, and that's what is causing the issue. So I went back on my Linux server, switched the theme from dark to None, and it was able to generate the video.

Hope this helps !

johnnyvng commented 1 year ago

I pulled the latest version as he fixed the error timeout on Linux but good to know.