alexlaverty / python-reddit-youtube-bot

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

screenshot.py not working #60

Open itsRaffaR opened 1 year ago

itsRaffaR commented 1 year ago

I've been using this code for a while no with no issues. Suddenly the code always trips with the error:

playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded. =========================== logs =========================== waiting for locator("[data-test-id=\"post-content\"]")

I've read the previous issues commenting on not using dark, and troubleshooting by running headless=False.

From what I can see when the browser opens the post, its opening not signed into reddit. This means that the 'post-content' its trying to find doesnt exist on the page, and you get the timeout error above. I tested logged in and that element does exist within the html, but not when logged out.

I've tried my best to troubleshoot this myself, but am a little out of my depth (still learning python).

Any assistance you can give would be awesome.

Thanks :)

itsRaffaR commented 1 year ago

I tried a fresh install of all code, and now its running however its still not taking screenshots. Not sure what I'm doing wrong here.

image

itsRaffaR commented 1 year ago

I've found if you login when the browser opens the screenshots then work correctly. Might attempt to add a login function to the screenshot.py code

sebbourgeois commented 1 year ago

Got the same issue here. I did not pay attention first, then I saw the videos length, they were all very short. After checking them, I saw that it was only displaying the thumbnail, reading the title of the subreddit and then it wasn't processing the comments.

I did try to increase the timeout, change theme, nothing is working so far. I've also tried with a new API key, in case the previous one wasn't working for whatever reason -> no change. I also tried to put a dummy API id/secret just to see if it was being used properly, got a 404 when I do that. I tried on both Windows (W11 / python 3.10.11) and Linux (Ubuntu 22.04 / python 3.10.6), same result on both.

EDIT : To give a bit more context, I've made a test with this subreddit : https://www.reddit.com/r/TooAfraidToAsk/comments/12i52os/how_many_of_us_can_barely_afford_to_exist_at_this/

I was able to create a video out of it some days ago, no error at all. Now, it doesn't work.

I've made a GDrive with the result from the Linux server that you can find here. No change in the config, it was running headless, dark theme, 30000 as timeout value. You can find it here : https://drive.google.com/drive/folders/1tSgT6YUqyiE7XpCx17hHecgDuOFpY-md?usp=sharing

It contains the assets/work_dir, videos/output_of_the_subreddit and the debug log.

@alexlaverty in case you already read my comment, I've added extra information + debug files that may help you out.

alexlaverty commented 1 year ago

I think you're onto something, I think Reddit has made some changes lately which has broken the code, I can see Logged in vs Not Logging In, Reddit looks completely different, will have a look and see what I can do : image

sebbourgeois commented 1 year ago

Ah, my bad, just saw your post, I had the answer opened while I was doing my tests !

alexlaverty commented 1 year ago

Have had a look tonight and added in code to perform a reddit login before attempting to screenshot the comments, build has succeeded and new video has been published onto the TTSVibeLounge youtube channel, only issue was now it's not honouring the dark theme but will look into that another time, PR with the changes is here : https://github.com/alexlaverty/python-reddit-youtube-bot/pull/63

It's been merged into the main branch so git pull will get the latest changes, see how you go, hopefully it works for you.