How to get youtube direct flv url from giving youtube url
Hi all. Could any one show me how i can get youtube direct flv url using youtube url ? I know there programs that do that but i need to do it for a project that i work with. I found a php example but don't know how to convert it to vb6 so i be happy if some one help me convert it to vb6.Thanks
Re: How to get youtube direct flv url from giving youtube url
chris thanks for you reply. But my intention is not to download the flv file . I want to get exact url of flv file using vb6 so i be able to use it remotely!!
For example for the youtube url that you provided the direct link will be :
The php code is doing exactly what i want . But since i want to convert like 60 urls automatically php is not that fast and gives me maximum execution time reached error!!
If i be able to get header for one before last url of yours then that would be the direct url that i want.
Hope i get some help in making this converting process automatic.
Last edited by tony007; Oct 19th, 2007 at 01:26 PM.
Re: How to get youtube direct flv url from giving youtube url
tony 007, i find cris001 post is usufull. i did not get whats the problem with cris001's code. i advice you to put that php code in to VBF php forum, there you probably get translated
Re: How to get youtube direct flv url from giving youtube url
The disadvantage of my way is that the link only works for a short period of time. The "video_id=" parameter is always the same, but the "t=" parameter changes frequently.
If you click on the last link in my first post you'll see that it gives you a 410 message (page gone) now.
My solution works fine if you want to download the video right away, but you can't post the final link on an other webpage, because the link expires.
Re: How to get youtube direct flv url from giving youtube url
Got it, but the code is very messy. Somebody needs to clean it up and perhaps change it a bit. I had to connect to the Youtube website twice or else I got an error that Winsock wasn't in the correct state to send data a second time. I used a socket class, because Winsock froze VB every time I wanted to close the connection.
Also, this doesn't work for every clip. Some clips are apparently taken from google video and the returned url is something like this:
Of course you can check if the url is from google video and then use different extraction code, but you'll have to do that yourself. It's late and I'm off to bed.
Last edited by Chris001; Oct 21st, 2007 at 01:17 AM.
Re: How to get youtube direct flv url from giving youtube url
Originally Posted by Chris001
I have no idea, it works fine for me.
Try it without "WithEvents"
When i loaded it for the first time i got the error shown in the pic. i wonder why you had to connect to youtube first . couldn't your connect to giving url directly using winsock?
I even tried it without "withEvents" but got same error!!
Last edited by tony007; Oct 20th, 2007 at 10:22 PM.
Re: How to get youtube direct flv url from giving youtube url
I'm so sorry, it's my fault... I added a class and module from another project, but I forgot to include them with the upload
The reason you have to connect twice to the youtube website, is because after you've sent the first link to get the header, the server closes the connection. Then you'll have to connect to the youtube website again to send the second link in order to get the direct video link from the header.
Here's the project with the class and module..
Last edited by Chris001; Oct 24th, 2007 at 09:18 AM.
Re: How to get youtube direct flv url from giving youtube url
chris thanks now it is working. since i try to process a list of youtube urls . I made listbox and populated it will all my youtube urls and i added a button so it takes each url and place it in textbox and process it.
But unfortunately when i click that button the listbox urls gets placed in text box so fast without allowing them to get processed!!
Could you look at my code and let me how i can solve this problem?Thanks
Re: How to get youtube direct flv url from giving youtube url
You can do something like this, but I'm not sure if it works.
Code:
Private iCount As Integer '// Top of the form
Code:
Private Sub Command1_Click()
List2.Selected(iCount) = True
GetYoutubeUrl List2.List(iCount)
End Sub
Put this at the end of the GetYoutubeUrl sub and make txtFinalURL mutiline in the properties.
Code:
'// Put the direct link in the textbox
txtFinalURL.Text = txtFinalURL.Text & ReturnURL & vbCrLf
If iCount = (List 2.ListCount - 1) Then
MsgBox "Done !", vbInformation
Exit Sub
End If
iCount = iCount + 1
List2.Selected(iCount) = True
GetYoutubeUrl List2.List(iCount)
Re: How to get youtube direct flv url from giving youtube url
The "Exit Sub" is correct.
Change
Code:
Private Function GetYoutubeUrl(strURL As String)
to
Code:
Private Sub GetYoutubeUrl(strURL As String)
because it's not returning anything.
Also, keep in mind I wrote that project last night at 4am only to show you how to get the direct video link. It wasn't written to be used in an automated process with a Listbox. The code is messy, it barely has any error handling and it can probably be improved quite a lot.
Last edited by Chris001; Oct 21st, 2007 at 06:49 PM.
Re: How to get youtube direct flv url from giving youtube url
chris thanks . This time no error but the highlight in listbox is moving so fast not giving enough time for the program to process the urls!!
In some of my projects i used this line of code and it was working well in slowing down listbox but in this project it keeps giving me eror:
Re: How to get youtube direct flv url from giving youtube url
I have no idea what you're trying to do, but Inet is not going to work.
The reason why Inet slows it down is because the code is halted until "Inet1.OpenURL" is finished retrieving the HTML source code of a webpage. You're getting a compile error because "icByteData" doesn't exist. It should be "icByteArray" and "icByteArray" should normally be used with binary files. The data should be stored in a byte array, not in a Textbox (assuming Text1 is a Textbox). To show HTML source code in a Textbox use "icString".
But like I said Inet is not going to work. You need the header and not the HTML source code of a webpage and as far as I know that can't be done with Inet. Inet automatically handles redirections and "Inet1.URL" never gets updated to the page you get redirected to.
Last edited by Chris001; Oct 21st, 2007 at 08:19 PM.
Re: How to get youtube direct flv url from giving youtube url
Here is what i want to achive. I pull youtube urls from mysql and populate listbox or listview. Then convert these urls to direct flv files autmatically and then create an xml playlist for so i be able to use it with my flash video player.
Re: How to get youtube direct flv url from giving youtube url
I've made a YouTube video playlist. It saves the video id's of the wanted videos, then puts it into a file. Reads it again, and put's them into a listbox, so whenever you click the name of the video you want to watch, it plays it using the ID and the method I showed you.
Re: How to get youtube direct flv url from giving youtube url
Originally Posted by Vanasha
I've made a YouTube video playlist. It saves the video id's of the wanted videos, then puts it into a file. Reads it again, and put's them into a listbox, so whenever you click the name of the video you want to watch, it plays it using the ID and the method I showed you.
It would be nice if you share it. Does it play more the one video(playlist) one after another without clicking ?
Re: How to get youtube direct flv url from giving youtube url
Originally Posted by Vanasha
I've attached the main form of the project, please keep in mind that I coded it, do not distribruite or claim as your own.
I'm sure you could code the playing after one and other.
Thanks for sharing it. I had to comment out your help form since it didn't exist. I added 2 videos but it never playes the second one when the first one finishes!! I wish it could play the added songs one after anotehr with me having to clicking them. Also the first video doesn't start automatically!!
Last edited by tony007; Oct 23rd, 2007 at 11:31 AM.
Re: How to get youtube direct flv url from giving youtube url
Then code it in, Tony. Study the code and learn how it works. You can't always expect everbody to give you code that works 100% the way you want it. Sometimes it needs to be modified a bit to suit your needs. Vanasha gave you most of the code, playing it automatically and after one and other is not a real big step.
I spent 1 hour in the middle of the night trying to figure out how to get the direct youtube video url, created a sample project to show you how it can be done and gave you code to loop through a Listbox to automatically extract the urls, which works fine for me, but you simply dismiss it because it does't work 100% out of the box for you.