View Single Post
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#77
Originally Posted by MohammadAG View Post
I'd appreciate it if someone could provide help on how to get a direct link to a youtube video so I could pass it to a custom video widget (I know cutetube's source can help but I'm not that fluent in QML)
I use C++ code (QNetworkAccessManager etc) to get the url. I've attached a text file containing the methods. I basically use the get() method of QNetworkAccessManager and connect the finished() signal to a slot where the response html is parsed. You pass the YouTube link to the getVideoUrl() method. My YouTube class has a playbackFormat attribute which holds the stream format (5 or 18). This is used in the parseVideoPage() slot, but you could just hard-code a value if you prefer.

Note that it was necessary to create a new QNetworkAccessManager object each time the method is called, otherwise I would get a 403 response when attempting to play the stream (after the first video).
Attached Files
File Type: txt getyoutubeurl.txt (1.7 KB, 103 views)
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub

Last edited by marxian; 2011-05-08 at 03:07.
 

The Following 7 Users Say Thank You to marxian For This Useful Post: