mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

injectBrowserKeyDown injectBrowserKeyUp for YouTube TV

Open MrSol0 opened this issue 4 years ago • 10 comments

Is your feature request related to a problem? Please describe. Youtube TV has added a feature where you need to click Enter in order to watch a video with resume, however in my TV script, only the person with keys to the house can watch the TV and when Syncing the TV this issue happens as the script triggers a link with resume watch so everyone sees the same thing inside the house or Cinema, and both injectBrowserMouseDown and Up don't work in my case as the only key that works to press yes is Enter

Describe the solution you'd like I want to be able to inject a key pressing for example injectBrowserKeyDown(browser,"Enter") or injectBrowserKeyUp(browser,"Enter")

Describe alternatives you've considered i have tried both injectBrowserMouseDown, InjectBrowserMouseUp, i also tried navigateBrowserForward but it doesn't work.

Additional context dialog

MrSol0 avatar Oct 23 '20 10:10 MrSol0

Such a coincidence.. i've been breaking my head over this today. YouTube/Google really has no idea of what they are doing to certain applications using CEF and such technologies, every time they make some redundant little change.. It's not like you can set up stuff and never look back, it's high maintenance. It will always regularly break.

in this case, it's flagging CEF browser traffic as potentially automated, unusual. "Not a normal web user".

First it happened only to the classic YouTube interface (.com) and using .TV would bypass the dialog. But even more recently (perhaps a week or so?), they added it to .TV as well. Now there is no way to playback without the dialog if you're in CEF.

If we can somehow let MTA automatically submit "Yes", it would be much better, for all servers.

Also, that wouldn't be unusual - keeping YouTube working through all their changes is a pastime for MTA.. examples are e549fec, dd3931e, fa82ee7 so what I meant to say is that through history, MTA team has sort of decided to try and keep YouTube working out of the box.

Back on-topic, and to my intro words "i've been breaking my head over this today" - since I realized that injectBrowser functions weren't going to cut it, i intended to use https://wiki.multitheftauto.com/wiki/ExecuteBrowserJavascript by finding the element (perhaps involving Xpath) which is the "Yes" button in that dialog and crafting auto-submit javascript code. So then you'd have to execute that string every time a player is about to stream a new YT video.

That means it's probably not impossible to work around it with scripting, @MrSol0. But, back to my suggestion to fix it with MTA - how about injecting that javascript string using MTA CEF, so we can keep YouTube working as expected out of the box, the line of action we've already set course to like described.

Dutchman101 avatar Oct 23 '20 11:10 Dutchman101

After checking and testing, i found this solution: local width,height = 854,480 browser:injectMouseMove(width*.851,height*.375) browser:injectMouseUp('left') "The numbers change depending on your browser's dimensions in createBrowser" This works fine for me and solves the issue, i only had to put a 2 second timer before it gets excuted and that solved it. However i still believe this feature to be a great feature.

MrSol0 avatar Oct 23 '20 15:10 MrSol0

Hacking this to work out of the box seems reasonable to me 👍

qaisjp avatar Oct 23 '20 15:10 qaisjp

I agree that we should support this out of the box, but really... I couldn't agree more with @Dutchman101's point about Google making breaking changes like this. It feels like MTA will keep playing a cat and mouse game forever. Would it be possible to get in touch with Google somehow so they stop flagging MTA traffic like "unusual" and potentially related with obscure behaviors?

AlexTMjugador avatar Oct 23 '20 23:10 AlexTMjugador

No, they don't even trust CEF as a whole, let alone individual CEF projects.

Woovie avatar Oct 23 '20 23:10 Woovie

I don't think they are specifically flagging MTA traffic. Their YouTube TV service is not intended to be used this way, and I strongly suspect that contacting them could cause problems.

qaisjp avatar Oct 23 '20 23:10 qaisjp

Any idea what conditions need to be met so that the dialog pops up? Perhaps spoofing the useragent is sufficient.

jushar avatar Oct 28 '20 08:10 jushar

Im using cinema (cinemaexperience) script.. and i got this error and im changed s-main.lua:16 before: local url = "https://www.youtube.com/tv#/watch?v="..id.."&resume" after: local url = "https://www.youtube.com/embed/"..id.."?modestbranding=1&autohide=1&showinfo=0&controls=0&autoplay=1&volume=0" its working like this.

and you need change c-main.lua:248 like this: loadBrowserURL(Screen,tostring(url).."&start="..atTime)

mahlukat5 avatar Oct 29 '20 19:10 mahlukat5

well this ticket is for https://www.youtube.com/tv#/ not embed, as much as i understand it but i want the original youtube TV view instead of creating a custom one where the player has to insert video id. but thanks

MrSol0 avatar Oct 29 '20 20:10 MrSol0

Currently youtube has changed to "Are you watching now?" and i solved it by doing setTimer(function() browser:injectMouseMove(width*0.9,height*0.9) browser:injectMouseUp('left') end,500,1)

MrSol0 avatar May 21 '22 22:05 MrSol0