I spent hours debugging my code after ending up with the same error. Then, as I was running my script in headless mode, I didn't see how the Youtube page I was visiting for my test setup looked like. It turned out that since I was behind VPN, YouTube showed a different view for the video player with no buttons at all but only telling me to "sign in to prove I am not a bot."
I disabled the VPN, then YouTube no longer thought I was a bot, and everything worked again. I know this is not a solution to the problem, but I share it as one might bump into the same issue, although nothing is wrong with the code itself.