Verify successful download ...

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
otan1298
Posts: 4
Joined: Tue Mar 24, 2020 1:04 pm

Verify successful download ...

Post by otan1298 » Tue Mar 31, 2020 1:44 pm

Hello everyone.

I am new to Imacros and this tool is incredible. I managed to make my macro work with what I needed.
However, I am facing a problem.

I use it to download a file every day at 20:40 and save it with a specific name in a folder.
My problem is that the site where I download the file is very unstable, sometimes the error occurs due to the website being offline and sometimes it starts to download and stops in the middle of the file and remains stopped until iMacros TimeOut ends.
I would like a command to check if the download was successful, if not, repeat the command until you get it. It's possible?

Use iMacros Browser V11.5.498.2403 on Win10 triggered by the windows task scheduler at 20:40.
Below the code I use:

Code: Select all

VERSION BUILD=11.5.498.2403
TAB T=1
TAB CLOSEALLOTHERS
SET !PLAYBACKDELAY 0.2
SET !TIMEOUT_PAGE 900
URL GOTO=https://redenacionalderadio.com.br/
ONDOWNLOAD FOLDER=F:\teste FILE=VB60.mp3 WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Download<SP>em<SP>MP3:*
WAIT SECONDS=10
Thank you very much for any help.
Ps .: Sorry my english, I used Google Translate.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Verify successful download ...

Post by chivracq » Tue Mar 31, 2020 3:02 pm

otan1298 wrote:
Tue Mar 31, 2020 1:44 pm
Hello everyone.

I am new to Imacros and this tool is incredible. I managed to make my macro work with what I needed.
However, I am facing a problem.

I use it to download a file every day at 20:40 and save it with a specific name in a folder.
My problem is that the site where I download the file is very unstable, sometimes the error occurs due to the website being offline and sometimes it starts to download and stops in the middle of the file and remains stopped until iMacros TimeOut ends.
I would like a command to check if the download was successful, if not, repeat the command until you get it. It's possible?

Use

Code: Select all

iMacros Browser V11.5.498.2403 on Win10
triggered by the windows task scheduler at 20:40.

Below the code I use:

Code: Select all

VERSION BUILD=11.5.498.2403
TAB T=1
TAB CLOSEALLOTHERS
SET !PLAYBACKDELAY 0.2
SET !TIMEOUT_PAGE 900
URL GOTO=https://redenacionalderadio.com.br/
ONDOWNLOAD FOLDER=F:\teste FILE=VB60.mp3 WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Download<SP>em<SP>MP3:*
WAIT SECONDS=10
Thank you very much for any help.
Ps .: Sorry my english, I used Google Translate.

Your Thread/Issue is not "really" related/specific to the Task Scheduler and therefore the 'Command Line' Sub-Forum was not "exactly" the correct Sub-Forum to choose to open your Thread, but I still approved your Thread as the Quality for the rest of your Post is very correct... (But try to select the "correct" Sub-Forum when you open a Thread, I don't react otherwise... :!: )
... And the Forum Admin will be able to move your Thread to the 'General' Sub-Forum if he "feels" like me... :|

>>>

Hum, "new to iMacros" and using iMB v11.5, then you are probably using a pirated Version, I guess, ah-ah...! :shock: , so I don't think @TechSupport will be trying to help you, oops..., but "lucky for you", the Forum is about (Advanced) Users helping Users, so we/I don't really care about License and such... :wink:

>>>

Alright, about your Scenario, well-well-well..., yep, I understand what you want, and yep it is possible, but you will need to add a bit of "Intelligence" to your Script/Implementation... :twisted:

First the 'ONDOWNLOAD' Command has a 'SIZE' Parameter that you might be able to use, but it requires that you know "in advance" the exact expected Size, but if I'm correct, the File you want to download on your Site is the "VOZ DO BRAZIL - Download em MP3" File/Link on the Page, and I don't see any Info about the Size of that File on the Site itself... Only once the Download has started, the Browser displays the Total Size, but iMacros won't be able to grab that Info, I would think... So this won't work...!
+ The Check on this 'SIZE' Param (same with 'CHECKSUM' also) is only useful/usable when using the 'Scripting Interface' (or a '.js' Script with iMacros for FF v8.9.7), you can't do anything "useful" with it in pure '.iim'... :cry:

More usable might be to use the '!DOWNLOADED_SIZE' Var/Value, which will probably be different every day, but if you expect "on Average" a File of, say 30-40 Mb everyday, if you get a Size of 18Mb for example when you check, then you'll already know that "stg" went wrong with the Download, and you can try again...!

For that Implementation to work, you will need to loop your Script, and if the Download typically finishes in, say 2 Minutes, check for the Size after maybe 180 Sec (=3 Min), to conditionally abort the Script if the Download was "successful", or let it run again and try again with the next Loop until you get a downloaded File with Size > 30Mb.
You might need to add some Unique Identifier to each Download, by using the '!NOW' Var if you want to keep/compare the different Files for a same Day, as I'm not sure, but I think that when using the 'ONDOWNLOAD' Command, the File gets replaced each time if it already existed, at least on FF that I use myself, iMB might behave differently, I don't know for sure...

This Implementation won't give you 100% Assurance that the Download finished completely and correctly, but it will already improve quite a lot the Reliability of your Downloads compared to your current Situation...

Reaching 99.9%/100% Assurance would also be possible, ah-ah...! :twisted:

But I'll first let you react, and try to implement this "Scenario", and maybe you'll come up yourself with other Ideas, and might find yourself how to implement the 100% Reliability... (I already have 2 Solutions in mind... (for the 100%), one still using the '!DOWNLOADED_SIZE' Var I've already mentioned, and one using another "Technique", which I've already explained a few times in other Threads on the Forum...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
otan1298
Posts: 4
Joined: Tue Mar 24, 2020 1:04 pm

Re: Verify successful download ...

Post by otan1298 » Tue Mar 31, 2020 5:41 pm

Hey chivracq, thank you very much for the answer, you are quick on the trigger. :shock:

Sorry for posting in the wrong topic, in fact this was the most suitable place I found to post. If the administrator thinks it is better to move, I appreciate it.

As for the version of iMacros, I was doing my tests in the last trial version, but after 30 days it didn't allow me to use it anymore and I looked for an option (alternative :oops: ) that would work in the tests. With everything okay with the commands I will purchase the latest version. :D

Well, as for the code, I said, I don't know, I spent months trying (mistakes and successes) until I got to the one that worked (more or less).

I had read something about '! DOWNLOADED_SIZE ', however with my lack of knowledge I don't know how to implement it in the iMacros script :( .
Looking here at my files I was able to identify that the size of the mp3 file is always between 52mb to 57mb, I don't know if that helps.

I don't need 100% guarantees that work every time, but 99.9% would be great.

Programming is not my forte, although I quite appreciate the subject.

I really appreciate your help and if possible I would like more tips (or even better, already in code).

Thank chivracq
Tom, Tech Support
Posts: 3834
Joined: Mon May 31, 2010 4:59 pm

Re: Verify successful download ...

Post by Tom, Tech Support » Tue Mar 31, 2020 7:11 pm

otan1298 wrote:
Tue Mar 31, 2020 5:41 pm
Sorry for posting in the wrong topic, in fact this was the most suitable place I found to post. If the administrator thinks it is better to move, I appreciate it.
Actually, this is the correct sub-forum for this topic, so I will leave it here.
Regards,

Tom, iMacros Support
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Verify successful download ...

Post by chivracq » Wed Apr 01, 2020 12:49 pm

otan1298 wrote:
Tue Mar 31, 2020 5:41 pm
Hey chivracq, thank you very much for the answer, you are quick on the trigger. :shock:

Sorry for posting in the wrong topic, in fact this was the most suitable place I found to post. If the administrator thinks it is better to move, I appreciate it.

As for the version of iMacros, I was doing my tests in the last trial version, but after 30 days it didn't allow me to use it anymore and I looked for an option (alternative :oops: ) that would work in the tests. With everything okay with the commands I will purchase the latest version. :D

Well, as for the code, I said, I don't know, I spent months trying (mistakes and successes) until I got to the one that worked (more or less).

I had read something about '! DOWNLOADED_SIZE ', however with my lack of knowledge I don't know how to implement it in the iMacros script :( .
Looking here at my files I was able to identify that the size of the mp3 file is always between 52mb to 57mb, I don't know if that helps.

I don't need 100% guarantees that work every time, but 99.9% would be great.

Programming is not my forte, although I quite appreciate the subject.

I really appreciate your help and if possible I would like more tips (or even better, already in code).

Thank chivracq

Alright, again, don't worry about License for the Forum, I/we (Advanced Users) don't care... But you didn't mentioned you were using the 'Trial' Version, and current Version for iMB is v12.6, for which you can also download the 'Trial' Version from the 'Download' Page...
And hum, iMB the "Full" (= 'Pro') Version costs about 500USD I think, that sounds a bit expensive to me, if you only want to download a '.mp3' once a day, iMacros is also available as Add-on (for IE/FF/CR) in 'Free'/'PE' (= 'Personal Edition') Versions which are much cheaper ('PE' = 100USD) and would be good enough to simply download a File once a day...

Yeah well, "read stg" + "lack of knowledge" + "don't know how to implement", => tja, simply read the Documentation about that Command in the Wiki (and search for Examples on the Forum) and try to use it... :idea:
I've never used that '!DOWNLOADED_SIZE' Command myself either (I don't do any Downloads in my Scripts myself), I'm not even sure if it is supported in the Version(s) I use myself (v8.8.2 + v8.9.7 for FF), the Wiki is a bit Confusing about many Commands with the Icons for the 4 Browsers that regularly get added then removed then re-added again without mentioning (from) which Version per Browser a Command is supported or not, and as I use some "older" Version(s), I never know if a FF Icon (or no Icon) applies to my Version(s) also... :?
And I cannot test at the moment, I have a very limited metered Internet Connection, with about 100Mb left for the coming 3 Days, so I cannot do any Download now... :oops:
But, anyway, it's not complicated to add a "PROMPT {{!DOWNLOADED_SIZE}}" at the end of your Script, like documented in the Wiki... :idea:

Yeah well, about 100% / 99.9%, that was the same Case for me... The first Implementation with a Check on >50Mb would already give you 90% maybe...

About "more tips" and "already in code", well, try to implement that Functionality, I don't write Scripts for other Users, I let you find the/a Solution by yourself, that's much more "rewarding" for yourself, and you'll learn much quicker, ah-ah...! I only help Users who "really" get stuck after they've tried their Best... :wink:
Oh...!, but, ah-ah...!, maybe Interesting for you though, Users with an iMB 'Pro' (+ 'Enterprise') License have Direct Access to @TechSup, and they are much "nicer" and "easier" to help Licensed Customers writing their Scripts... 8)

But hum, about Looping the Script launched from the Task Scheduler, that's actually "a bit complicated", supposedly not possible without the 'Scripting Interface' or using a '.js' Script on FF with v8.9.7 for FF, even if I have a few Workarounds in pure '.iim', so in your Case, it will be maybe better to repeat the same Block of Code about 5 times for 5 Attempts to download that File, if it doesn't work after trying 5 times, that means there is really a Pb with the Site or the Internet Connection "at that moment", and 5 times is enough, and you could launch the Script again (through the Scheduler) maybe 1 or 2 hours later...

And about the 'PE' Versions I mentioned, launching a Script (without even trying to loop it) from iMacros v10.0.x for FF/CR is also a bit cumbersome, as 'CLI' (= "Command Line" + I'm not sure what the "I" stands for, => "Interface"/"Integration"/"Implementation"...?) is not supported in those Versions anymore... There is a Workaround, but it's a bit cumbersome...
Might be easier for you if you could use v8.9.7 for FF (which is completely Free, and completely Functional), works on FF v55.0.3 + Pale Moon v28 + Basilisk 2019/2020. :idea:
'CLI' is still supported though I think for v12.6 for IE 'Free'/'PE'.

>>>
Tom, Tech Support wrote:
Tue Mar 31, 2020 7:11 pm
otan1298 wrote:
Tue Mar 31, 2020 5:41 pm
Sorry for posting in the wrong topic, in fact this was the most suitable place I found to post. If the administrator thinks it is better to move, I appreciate it.
Actually, this is the correct sub-forum for this topic, so I will leave it here.

Hum..., OK..., I don't "completely" agree, even if some (Sub-)Parts of this Scenario happen to be related to the Task Scheduler, and would be "easier" to implement with the 'SI', but the "main" Issue is about "verifying that a Download went OK", which is pure '.iim' Functionality (or can be done in pure '.iim')..., but OK anyway, no big deal..., and "yer Da Boss...!", ah-ah...! :wink:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
otan1298
Posts: 4
Joined: Tue Mar 24, 2020 1:04 pm

Re: Verify successful download ...

Post by otan1298 » Wed Apr 01, 2020 1:23 pm

Hi chivracq, thanks again for the reply.

I didn't think about the possibility of using the iMacros add-on for FF, I will install and work on it from now on. Thanks for the tip.

I think the way is really the '! DOWNLOADED_SIZE ', I will point my research to this path on the Wiki.

More news and advances posted here.

Thank you chivracq !!!
:D :D :D
User avatar
The iMacros Guru
Posts: 25
Joined: Tue Mar 07, 2017 11:07 pm
Contact:

Re: Verify successful download ...

Post by The iMacros Guru » Wed Apr 15, 2020 3:53 pm

otan1298 wrote:
Tue Mar 31, 2020 1:44 pm
Hello everyone.

I am new to Imacros and this tool is incredible. I managed to make my macro work with what I needed.
However, I am facing a problem.

I use it to download a file every day at 20:40 and save it with a specific name in a folder.
My problem is that the site where I download the file is very unstable, sometimes the error occurs due to the website being offline and sometimes it starts to download and stops in the middle of the file and remains stopped until iMacros TimeOut ends.
I would like a command to check if the download was successful, if not, repeat the command until you get it. It's possible?

Use iMacros Browser V11.5.498.2403 on Win10 triggered by the windows task scheduler at 20:40.
Below the code I use:

Code: Select all

VERSION BUILD=11.5.498.2403
TAB T=1
TAB CLOSEALLOTHERS
SET !PLAYBACKDELAY 0.2
SET !TIMEOUT_PAGE 900
URL GOTO=https://redenacionalderadio.com.br/
ONDOWNLOAD FOLDER=F:\teste FILE=VB60.mp3 WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Download<SP>em<SP>MP3:*
WAIT SECONDS=10
Thank you very much for any help.
Ps .: Sorry my english, I used Google Translate.

Hi otan,

I would use a batch file to call your macro and check 1) if the file exists, and 2) if the downloaded file is a minimum size (per chivracq's suggetsion), and repeat the download if either of those two conditions are not met.

Here's an example batch file I whipped up with help from this Stack Overflow post for getting the size of the file:

DownloadFile.cmd

Code: Select all

@echo off
setlocal

set timestamp=%time::=%
set timestamp=%timestamp:.=%

set downloadFolder=F:\teste
set downloadFileName=VB60_%timestamp%.mp3
set downloadFileFullPath=%downloadFolder%\%downloadFileName%

:download
"C:\Program Files (x86)\Ipswitch\iMacros\iMacros.exe" -macro DownloadFile -var_downloadFolder %downloadFolder% -var_downloadFileName %downloadFileName%

:: repeat the download if the file does not exist
if not exist %downloadFileFullPath% goto download

:: repeat the download if the file is not the expected minimum size (in bytes)
set minbytesize=1000000
call :getFileSize %downloadFileFullPath%

set checksize=00000000000000000000%size%
set checkminbytesize=00000000000000000000%minbytesize%

if "%checksize:~-20%" lss "%checkminbytesize:~-20%" goto download
goto :eof

:getFileSize
set size=%~z1
goto :eof
I'm using a timestamp for the downloaded file name to make sure that we're always downloading a new file (and not overwriting an existing file). This requires a small change to your macro so that we can pass in the name of the file (and folder):

DownloadFile.iim

Code: Select all

VERSION BUILD=11.5.498.2403
TAB T=1
TAB CLOSEALLOTHERS
SET !PLAYBACKDELAY 0.2
SET !TIMEOUT_PAGE 900
URL GOTO=https://redenacionalderadio.com.br/
ONDOWNLOAD FOLDER={{downloadFolder}} FILE={{downloadFileName}} WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Download<SP>em<SP>MP3:*
WAIT SECONDS=10
Cheers!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Verify successful download ...

Post by chivracq » Wed Apr 15, 2020 4:18 pm

The iMacros Guru wrote:
Wed Apr 15, 2020 3:53 pm
Hi otan,

I would use a batch file to call your macro and check 1) if the file exists, and 2) if the downloaded file is a minimum size (per chivracq's suggetsion), and repeat the download if either of those two conditions are not met.

Here's an example batch file I whipped up with help from this Stack Overflow post for getting the size of the file:

DownloadFile.cmd

Code: Select all

@echo off
setlocal

set timestamp=%time::=%
set timestamp=%timestamp:.=%

set downloadFolder=F:\teste
set downloadFileName=VB60_%timestamp%.mp3
set downloadFileFullPath=%downloadFolder%\%downloadFileName%

:download
"C:\Program Files (x86)\Ipswitch\iMacros\iMacros.exe" -macro DownloadFile -var_downloadFolder %downloadFolder% -var_downloadFileName %downloadFileName%

:: repeat the download if the file does not exist
if not exist %downloadFileFullPath% goto download

:: repeat the download if the file is not the expected minimum size (in bytes)
set minbytesize=1000000
call :getFileSize %downloadFileFullPath%

set checksize=00000000000000000000%size%
set checkminbytesize=00000000000000000000%minbytesize%

if "%checksize:~-20%" lss "%checkminbytesize:~-20%" goto download
goto :eof

:getFileSize
set size=%~z1
goto :eof
I'm using a timestamp for the downloaded file name to make sure that we're always downloading a new file (and not overwriting an existing file). This requires a small change to your macro so that we can pass in the name of the file (and folder):

DownloadFile.iim

Code: Select all

VERSION BUILD=11.5.498.2403
TAB T=1
TAB CLOSEALLOTHERS
SET !PLAYBACKDELAY 0.2
SET !TIMEOUT_PAGE 900
URL GOTO=https://redenacionalderadio.com.br/
ONDOWNLOAD FOLDER={{downloadFolder}} FILE={{downloadFileName}} WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Download<SP>em<SP>MP3:*
WAIT SECONDS=10
Cheers!

Oh...!?, nice to see you back @'The iMacros Guru', 's been a while since we last saw you on the Forum, ah-ah...! :wink:

OK, nice Work, I would have a few Remarks...: :D
- Hum, the 'goto' Mechanism in the '.bat' File is quite interesting actually, as it could be used for some Looping Functionality when launching an (iMacros) Script from a '.bat' File/Scheduler...

- Might need to add some 'timeout' Command in the '.bat' File, as I'm not sure (and I think it won't...!) the '.bat' File will "wait" for the Macro to run/finish before executing the next Line(s) in the '.bat' File...

- And I could be wrong as I don't use iMB myself, so I never did any Testing with it myself..., but I would think that your Implementation will only work with the iMacros 'Enterprise Edition' and the 'SI' ('Scripting Interface'), and that the "Standalone" iMB 'Pro Edition' won't support the Use of the '-var' Paramater(s) by itself without the 'SI'...? :?
... But I guess it would then be possible to use the OS Clipboard or writing to some mini-Temp File as another Mechanism to pass the Content of those Vars to the Macro then... :|
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
User avatar
The iMacros Guru
Posts: 25
Joined: Tue Mar 07, 2017 11:07 pm
Contact:

Re: Verify successful download ...

Post by The iMacros Guru » Wed Apr 15, 2020 5:34 pm

chivracq wrote:
Wed Apr 15, 2020 4:18 pm
Oh...!?, nice to see you back @'The iMacros Guru', 's been a while since we last saw you on the Forum, ah-ah...! :wink:

OK, nice Work, I would have a few Remarks...: :D
- Hum, the 'goto' Mechanism in the '.bat' File is quite interesting actually, as it could be used for some Looping Functionality when launching an (iMacros) Script from a '.bat' File/Scheduler...

- Might need to add some 'timeout' Command in the '.bat' File, as I'm not sure (and I think it won't...!) the '.bat' File will "wait" for the Macro to run/finish before executing the next Line(s) in the '.bat' File...

- And I could be wrong as I don't use iMB myself, so I never did any Testing with it myself..., but I would think that your Implementation will only work with the iMacros 'Enterprise Edition' and the 'SI' ('Scripting Interface'), and that the "Standalone" iMB 'Pro Edition' won't support the Use of the '-var' Paramater(s) by itself without the 'SI'...? :?
... But I guess it would then be possible to use the OS Clipboard or writing to some mini-Temp File as another Mechanism to pass the Content of those Vars to the Macro then... :|
Hi chivracq,

Thanks for the feedback! I tested the batch file using iMacros Pro Edition and it works as expected. No timeout is required because the batch file waits for iMacros.exe to exit before continuing with the next command. And passing macro variable values in via the command line has been supported for as long as I can remember.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Verify successful download ...

Post by chivracq » Wed Apr 15, 2020 5:43 pm

The iMacros Guru wrote:
Wed Apr 15, 2020 5:34 pm
Hi chivracq,

Thanks for the feedback! I tested the batch file using iMacros Pro Edition and it works as expected. No timeout is required because the batch file waits for iMacros.exe to exit before continuing with the next command. And passing macro variable values in via the command line has been supported for as long as I can remember.

Alright..., well..., good to hear then, and that sounds like the/a "perfect" Solution/Implementation then... :D

Like I mentioned, I've never used iMB myself, only the Free Add-on(s), and solely on FF/PM, so I wasn't "sure" about those Items... Thanks for the Testing and the Clarification/Confirmation... :D

Any New Video(s) about iMacros (or Web-Automation) in the Make...!? :wink:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
User avatar
The iMacros Guru
Posts: 25
Joined: Tue Mar 07, 2017 11:07 pm
Contact:

Re: Verify successful download ...

Post by The iMacros Guru » Thu Apr 16, 2020 7:14 am

chivracq wrote:
Wed Apr 15, 2020 5:43 pm
Any New Video(s) about iMacros (or Web-Automation) in the Make...!? :wink:

Glad you asked! Yes, actually, though not sure how soon before I can finish and post some.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Verify successful download ...

Post by chivracq » Thu Apr 16, 2020 11:49 am

The iMacros Guru wrote:
Thu Apr 16, 2020 7:14 am
chivracq wrote:
Wed Apr 15, 2020 5:43 pm
Any New Video(s) about iMacros (or Web-Automation) in the Make...!? :wink:

Glad you asked! Yes, actually, though not sure how soon before I can finish and post some.

Oh, good...!, I can't wait, ah-ah...! :P

If you need some "Subjects", I can list a few...: :idea:
- A Review of iMB v12.6 and its "New" Features, => 'Play Lists', etc...
- Listing Limitations and naming Enhancement Requests... I maintain a List of EnhReq's in this Thread for example...
- A Comparison with their respective Strong and Weak Points between different Web-Automation Tools, => iMacros, Selenium, Kantu, Katalon, etc...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
otan1298
Posts: 4
Joined: Tue Mar 24, 2020 1:04 pm

Re: Verify successful download ...

Post by otan1298 » Thu Apr 16, 2020 5:24 pm

The iMacros Guru wrote:
Wed Apr 15, 2020 3:53 pm
otan1298 wrote:
Tue Mar 31, 2020 1:44 pm
Hello everyone.

I am new to Imacros and this tool is incredible. I managed to make my macro work with what I needed.
However, I am facing a problem.

I use it to download a file every day at 20:40 and save it with a specific name in a folder.
My problem is that the site where I download the file is very unstable, sometimes the error occurs due to the website being offline and sometimes it starts to download and stops in the middle of the file and remains stopped until iMacros TimeOut ends.
I would like a command to check if the download was successful, if not, repeat the command until you get it. It's possible?

Use iMacros Browser V11.5.498.2403 on Win10 triggered by the windows task scheduler at 20:40.
Below the code I use:

Code: Select all

VERSION BUILD=11.5.498.2403
TAB T=1
TAB CLOSEALLOTHERS
SET !PLAYBACKDELAY 0.2
SET !TIMEOUT_PAGE 900
URL GOTO=https://redenacionalderadio.com.br/
ONDOWNLOAD FOLDER=F:\teste FILE=VB60.mp3 WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Download<SP>em<SP>MP3:*
WAIT SECONDS=10
Thank you very much for any help.
Ps .: Sorry my english, I used Google Translate.

Hi otan,

I would use a batch file to call your macro and check 1) if the file exists, and 2) if the downloaded file is a minimum size (per chivracq's suggetsion), and repeat the download if either of those two conditions are not met.

Here's an example batch file I whipped up with help from this Stack Overflow post for getting the size of the file:

DownloadFile.cmd

Code: Select all

@echo off
setlocal

set timestamp=%time::=%
set timestamp=%timestamp:.=%

set downloadFolder=F:\teste
set downloadFileName=VB60_%timestamp%.mp3
set downloadFileFullPath=%downloadFolder%\%downloadFileName%

:download
"C:\Program Files (x86)\Ipswitch\iMacros\iMacros.exe" -macro DownloadFile -var_downloadFolder %downloadFolder% -var_downloadFileName %downloadFileName%

:: repeat the download if the file does not exist
if not exist %downloadFileFullPath% goto download

:: repeat the download if the file is not the expected minimum size (in bytes)
set minbytesize=1000000
call :getFileSize %downloadFileFullPath%

set checksize=00000000000000000000%size%
set checkminbytesize=00000000000000000000%minbytesize%

if "%checksize:~-20%" lss "%checkminbytesize:~-20%" goto download
goto :eof

:getFileSize
set size=%~z1
goto :eof
I'm using a timestamp for the downloaded file name to make sure that we're always downloading a new file (and not overwriting an existing file). This requires a small change to your macro so that we can pass in the name of the file (and folder):

DownloadFile.iim

Code: Select all

VERSION BUILD=11.5.498.2403
TAB T=1
TAB CLOSEALLOTHERS
SET !PLAYBACKDELAY 0.2
SET !TIMEOUT_PAGE 900
URL GOTO=https://redenacionalderadio.com.br/
ONDOWNLOAD FOLDER={{downloadFolder}} FILE={{downloadFileName}} WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Download<SP>em<SP>MP3:*
WAIT SECONDS=10
Cheers!
Perfect. It works like a clock.
I did several tests and in all he responded as expected.
"chivracq" did not have to add timeout.

Thank you very much for the wonderful help "The iMacros Guru". :D
Post Reply