I am using Inet but it seems it fails to download file which has some redirects
for example
file : http://youtube.com/get_video?video_i...cwXazKqj_xj5Yf
it has some redirects so how to download that kind of files using vb?
Printable View
I am using Inet but it seems it fails to download file which has some redirects
for example
file : http://youtube.com/get_video?video_i...cwXazKqj_xj5Yf
it has some redirects so how to download that kind of files using vb?
"Seems it fails" - what does that mean?
I meant that it doesn't accomplish the task or may be I am using it wrong.Quote:
Originally Posted by Hack
Following is code
and size is returned ZERO... so I think its because of redirects.Code:Inet1.Execute Trim(Link), "GET"
Do While Inet1.StillExecuting
DoEvents
Loop
size = Inet1.GetHeader("Content-Length")
and Link variable contains the url
http://youtube.com/get_video?video_i...cwXazKqj_xj5Yf
There are quite a few threads in here and alot of them are very recent about doing what you are trying to do.
Try using another link. It appears that the page no longer exists.
I have used search function but none of the address come up with the redirects issue solution.. I give it another try.Quote:
Originally Posted by jmsrickland
for me that link is working and offering get_video page to download which is infact a flv file.Quote:
Originally Posted by jmsrickland
When I click on that link I get this:
The page does not exist
The page you are looking for has been removed.
Quote:
Originally Posted by jmsrickland
Well, It happens because rotate the parameters every few hours. Anyhow.. I have changed the urls now they open.
Add reference to WinHTTP.dll in systems32. (Browse to it, if Microsoft WinHTTP services doesn't show on the references list.)
Note this simple example doesn't do anything fancy, just dumps the downloaded bytes to disk.
OnResponseStart when you can safely access the headers.
OnResponseDataAvailable which returns a byte array of downloaded data for each chunk.
OnResponseEnd which ends the download.
Code:Option Explicit
Private WithEvents http As WinHttpRequest
Private mContentLength As Long
Private mProgress As Long
Private Sub Command1_Click()
' Create the WinHTTPRequest ActiveX Object.
Set http = New WinHttpRequest
' Open an HTTP connection.
http.open "GET", "http://home.in.tum.de/~paula/mpeg/wg_gdo_1.mpg", True 'True means asynch.
' Send the HTTP Request.
http.send
End Sub
Private Sub http_OnResponseDataAvailable(Data() As Byte)
mProgress = mProgress + UBound(Data) + 1
ProgressBar1.Value = mProgress
Put #1, , Data
End Sub
Private Sub http_OnResponseFinished()
Close #1
MsgBox "done"
End Sub
Private Sub http_OnResponseStart(ByVal Status As Long, ByVal ContentType As String)
Text1.Text = http.getAllResponseHeaders()
mProgress = 0
mContentLength = CLng(http.getResponseHeader("Content-Length"))
ProgressBar1.Max = mContentLength
Open "C:\twg_gdo_1.mpg" For Binary As #1
End Sub
It worked superb...Quote:
Originally Posted by isnoend07
just a new thought in my mind..
Is it possible to download only specific part of file?
Suppose file size is 1024 KB.
First file is downloaded 1KB to 100KB.
Then resuming it from 101KB to 1024KB.
I have achieved this functionality in php but still not successful with doing this in vb.
Seems to me you could stop it at a certain byte. Don't know about resuming at the next byte. You may want to post this as a new question.Quote:
Originally Posted by Peon
Is there something wrong with that code? I use it and everything I download is missing the sound from the file. I downloaded that example mpg (exactly as shown in the post) and I get the video but no sound. So I changed the URL to something else (a You Tube video) and also got the video but again no sound. I know it is not my sound card cause I can play music on my PC and it is audiable.
Been using the code for a year. I use it like this:Quote:
Originally Posted by jmsrickland
It downloads a real small text file that holds a version number. This version number is compared to the users exe version number and if its higher then they can then download the exe. The exe is 14980kb and i gotta say it has always worked. Here is a working example:
http://www.planet-source-code.com/vb...xtCodeId=69060, it also uses WinHttpRequest
Don't know what could be wrong other than downloading the file with your browser to make sure it's valid.
I just don't think the file has sound to it.
What does that link do? I don't see where it has anything to do with the code and link you posted.
It downloads files. I have posted a valid wav file that works on my website for you to test here: http://roofgenius.com/wahoo.wavQuote:
Originally Posted by jmsrickland
Hope this helps
It returns Page Cannot Be Found. I even tried http://www.roofgenius.com/wahoo.wav
The URL http://www.roofgenius.com seems to be OK; so it must be the wahoo.wav that it can't find.
WhoopsQuote:
Originally Posted by jmsrickland
It's Whoo.wav
sorry
OK, now using the code you posted in #8 and the following statement:
http.Open "GET", "http://www.roofgenius.com/Whoo.wav", True
It downloads the file and there is sound. But when I download this....
http.Open "GET", "http://home.in.tum.de/~paula/mpeg/wg_gdo_1.mpg
I get the video but no sound.
So, I am assuming the file does not contain sound in it.
I downloaded the file in your link with my browser and it does not contain soundQuote:
Originally Posted by jmsrickland
I downloaded the file in your link with my browser and it does not contain sound
Not my link; it was the link in your code from your post #8
That file was just an old example, don't know if it ever existed. Think I copied it from somewhere I expected you to supply your own fileQuote:
Originally Posted by jmsrickland