What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » How to download

How to download
Author: Message:
ArkaneArkade
Full Member
***

Avatar
The One and Only

Posts: 193
Reputation: 5
39 / Male / Flag
Joined: Mar 2007
O.P. How to download
Hey all,

Working on a little extra, to automatically download an image from a site.  Probelm is, one of the images inst a png.
- OK, not very good at explaining - the image specifically is http://www.bungie.net/Stats/halo2emblem.ashx?s=70...=26&bi=36&fl=1&m=1

Because its an ashx page (presumably) the downloadfile doesn't seem to work,  Is there a possible method to do it, or is it just impossible?
[Image: adsig.jpg]
11-20-2008 11:05 PM
Profile E-Mail PM Web Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: How to download
Apparently, downloading from dynamic pages is not possible.

You'll have to save the file manually, host it somewhere else and download it from there.
11-24-2008 07:31 AM
Profile PM Find Quote Report
ArkaneArkade
Full Member
***

Avatar
The One and Only

Posts: 193
Reputation: 5
39 / Male / Flag
Joined: Mar 2007
O.P. RE: How to download
OK, cheers Smokie.  I'll have to figure something else out for that later on.  May find some other way to steal the image.
[Image: adsig.jpg]
11-24-2008 08:42 AM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: How to download
The mimetype is image/jpg.

You can use the Win32 API URLDownloadToFile.

Your code would look something like this:
code:
function URLDownloadToFile (sUrl, sFile) {
    Interop.Call('wininet.dll', 'DeleteUrlCacheEntryW', sUrl);
    Interop.Call('urlmon.dll', 'URLDownloadToFileW', 0, sUrl, sFile, 0, Interop.GetInterfacePtr('OnProgress'));
}

function OnProgress (ulProgress, ulProgressMax, ulStatusCode, szStatusText) {
    if (ulProgress == ulProgressMax) Debug.Trace('Download Complete');
}

Now I cannot guarantee that the callback function for this works because Plus! had to handwrite all of the function callbacks and he may have missed this one. If this is the case then you can do this:

code:
function URLDownloadToFile (sUrl, sFile) {
    Interop.Call('wininet.dll', 'DeleteUrlCacheEntryW', sUrl);
    Interop.Call('urlmon.dll', 'URLDownloadToFileW', 0, sUrl, sFile, 0, 0);
}

This post was edited on 11-24-2008 at 01:59 PM by matty.
11-24-2008 01:55 PM
Profile E-Mail PM Find Quote Report
ArkaneArkade
Full Member
***

Avatar
The One and Only

Posts: 193
Reputation: 5
39 / Male / Flag
Joined: Mar 2007
O.P. RE: How to download
Cheers matty.  I have that working... at least for the download.  I get object doesnt support method errors, so I guess that the callback was missed.  Shouldn't matter though... I'll just need to figure out some other way to detect it, so that I don't set my image to an incomplete file.
cheers dude
[Image: adsig.jpg]
11-25-2008 05:25 AM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: How to download
quote:
Originally posted by Leroux
I'll just need to figure out some other way to detect it, so that I don't set my image to an incomplete file.

Is it possible to compare file sizes?

or md5 hashes if you really wanna go nuts :p
<Eljay> "Problems encountered: shit blew up" :zippy:
11-25-2008 11:58 AM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: How to download
URLDownloadToFile I do believe is a synchronous call meaning when it returns 0 for success the file is done.
11-25-2008 12:35 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: How to download
quote:
Originally posted by matty
URLDownloadToFile I do believe is a synchronous call meaning when it returns 0 for success the file is done.
Unfortunately, it's not.
quote:
Returns one of the following values.
S_OK - The download started successfully.
That means: it returns as soon as its started, from there you're supposed to monitor the progress through the callback function - which we can't do unfortunately.

Ugh, how I hate the lack of asynchronous callback support. :(
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
11-25-2008 05:46 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: How to download
quote:
Originally posted by Matti
quote:
Originally posted by matty
URLDownloadToFile I do believe is a synchronous call meaning when it returns 0 for success the file is done.
Unfortunately, it's not.

That means: it returns as soon as its started, from there you're supposed to monitor the progress through the callback function - which we can't do unfortunately.

Ugh, how I hate the lack of asynchronous callback support. :(
Oops I didn't actually read the MSDN article ahaha!

And why didn't MsgPlus.DownloadFile work? It should process the url like any other.

This post was edited on 11-25-2008 at 06:17 PM by matty.
11-25-2008 06:05 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On