|
-
Nov 3rd, 2008, 05:30 AM
#1
Thread Starter
Addicted Member
Best way to download file
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?
Last edited by Peon; Nov 3rd, 2008 at 01:21 PM.
-
Nov 3rd, 2008, 08:09 AM
#2
Re: Best way to download file
"Seems it fails" - what does that mean?
-
Nov 3rd, 2008, 08:17 AM
#3
Thread Starter
Addicted Member
Re: Best way to download file
 Originally Posted by Hack
"Seems it fails" - what does that mean?
I meant that it doesn't accomplish the task or may be I am using it wrong.
Following is code
Code:
Inet1.Execute Trim(Link), "GET"
Do While Inet1.StillExecuting
DoEvents
Loop
size = Inet1.GetHeader("Content-Length")
and size is returned ZERO... so I think its because of redirects.
and Link variable contains the url
http://youtube.com/get_video?video_i...cwXazKqj_xj5Yf
Last edited by Peon; Nov 3rd, 2008 at 01:21 PM.
-
Nov 3rd, 2008, 09:44 AM
#4
Re: Best way to download file
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.
Last edited by jmsrickland; Nov 3rd, 2008 at 11:47 AM.
-
Nov 3rd, 2008, 12:33 PM
#5
Thread Starter
Addicted Member
Re: Best way to download file
 Originally Posted by jmsrickland
There are quite a few threads in here and alot of them are very recent about doing what you are trying to do.
I have used search function but none of the address come up with the redirects issue solution.. I give it another try.
 Originally Posted by jmsrickland
Try using another link. It appears that the page no longer exists.
for me that link is working and offering get_video page to download which is infact a flv file.
-
Nov 3rd, 2008, 12:38 PM
#6
Re: Best way to download file
When I click on that link I get this:
The page does not exist
The page you are looking for has been removed.
-
Nov 3rd, 2008, 01:23 PM
#7
Thread Starter
Addicted Member
Re: Best way to download file
 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.
Well, It happens because rotate the parameters every few hours. Anyhow.. I have changed the urls now they open.
-
Nov 3rd, 2008, 06:58 PM
#8
Re: Best way to download file
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
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Nov 5th, 2008, 09:54 AM
#9
Thread Starter
Addicted Member
Re: Best way to download file
 Originally Posted by isnoend07
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...
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.
-
Nov 5th, 2008, 10:59 AM
#10
Re: Best way to download file
 Originally Posted by Peon
It worked superb...
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.
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Nov 5th, 2008, 03:09 PM
#11
Re: Best way to download file
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.
-
Nov 5th, 2008, 04:26 PM
#12
Re: Best way to download file
 Originally Posted by jmsrickland
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:
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.
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Nov 6th, 2008, 01:09 AM
#13
Re: Best way to download file
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.
-
Nov 6th, 2008, 01:29 AM
#14
Re: Best way to download file
 Originally Posted by jmsrickland
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.wav
Hope this helps
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Nov 6th, 2008, 11:48 AM
#15
Re: Best way to download file
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.
-
Nov 6th, 2008, 12:03 PM
#16
Re: Best way to download file
 Originally Posted by jmsrickland
Whoops
It's Whoo.wav
sorry
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Nov 6th, 2008, 02:18 PM
#17
Re: Best way to download file
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.
-
Nov 6th, 2008, 02:25 PM
#18
Re: Best way to download file
 Originally Posted by jmsrickland
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 sound
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Nov 6th, 2008, 03:40 PM
#19
Re: Best way to download file
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
-
Nov 6th, 2008, 03:53 PM
#20
Re: Best way to download file
 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 file
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|