Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: How to access a YouTube web page?

Tags:

python

browser

I am opening a YouTube web page using the 'webbrowser' module:

controller = webbrowser.get()
controller.open("http://www.youtube.com/watch?v=SMwZsFKIXa8&feature=fvst")

The video begins to play, and I would like my Python application to resume as soon as the video ends or the browser is closed.

Now, I cannot use time.sleep for that, because it will force me to wait until the song is over (the app will not continue if I "fast-forward" the video, or if I simply close the browser).

So I basically need to get some indication from the web page, regarding the status of the video, and another indication in case the web page is suddenly closed.

Can I use the handle I have created using webbrowser.get, in order to do that?

Thanks

like image 436
barak manos Avatar asked Feb 21 '23 13:02

barak manos


1 Answers

You can't at all. The webbrowser module hands it over to a browser over which it has no control whatsoever.

You'd need to host your own browser control through something like QtWebkit in PySide or an equivalent in pygtk/wxPython. Then you could interact with it as you would own it.

like image 99
Chris Morgan Avatar answered Mar 05 '23 10:03

Chris Morgan