DLFile - 2022/02/27

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

DLFile - 2022/02/27

Post by TheArkive » 27 Feb 2022, 10:09

AHK v2 version is here.

DLFile is a class for downloading a file. It's meant to be a simple replacement for the DownloadFile command with the following improvements:
  • Get live stats: file size, bytes downloaded, Bps, file name, percent complete, and a few more things.
  • Specify a callback func to get and display the live stats.
  • The ability to abort the download by setting obj.cancel := true
  • File downloads as file.ext.temp, and is renamed to specified file.ext on completion.
  • Optionally delete a partial download by setting obj.del_on_cancel := true before calling Obj.Start()
  • Supports resume.
  • Supports batch downloading.

To-Do List:
  • ... thinking of what direction to take this ...
==================================================
Updates
==================================================

:arrow: Download on GitHub

==================================================

I could use some help with testing the resume feature. I'll be trying to test this of course, but several different servers / downloads need to be tested to make sure at least the basic expected implementation has been covered.
Last edited by TheArkive on 27 Feb 2022, 23:20, edited 5 times in total.

User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: DLFile - 2022/02/27

Post by TheArkive » 27 Feb 2022, 10:10

@BoBo

This seems to work ok on V1 so far. I cheated on the UI for pause/cancel/resume :P but the main idea still holds up.

User avatar
haichen
Posts: 631
Joined: 09 Feb 2014, 08:24

Re: DLFile - 2022/02/27

Post by haichen » 27 Feb 2022, 12:37

That's great. I managed to start several downloads in a row for v2. Maybe you could include processing a list or array. No matter if for v1 or v2.

User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: DLFile - 2022/02/27

Post by TheArkive » 27 Feb 2022, 12:46

@haichen

Built into the class? Or as an example?

User avatar
haichen
Posts: 631
Joined: 09 Feb 2014, 08:24

Re: DLFile - 2022/02/27

Post by haichen » 27 Feb 2022, 13:02

My computer just crashed with a "system_service_exception".... Runs again.
Basically I don't care. You have created this great tool. I would love an example for V1. If you want to include it in the class, I would find this also wonderful.

User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: DLFile - 2022/02/27

Post by TheArkive » 27 Feb 2022, 13:13

haichen wrote:
27 Feb 2022, 13:02
My computer just crashed with a "system_service_exception".... Runs again.

Yikes! If you can confirm it is from this script, or at least maybe it is likely this script, please let me know. I'll try to replicate.

haichen wrote:
27 Feb 2022, 13:02
Basically I don't care. You have created this great tool. I would love an example for V1. If you want to include it in the class, I would find this also wonderful.

As for including the functionality, that shouldn't be a problem. I'll make it work as an array for batch input, or a string for single input.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: DLFile - 2022/02/27

Post by BoBo » 27 Feb 2022, 14:11

@TheArkive - Nice! :thumbup:
I've played a little with that (G)UI stuff, hope you don't mind :)
DLFileGui
.
TheArkive - DLFileGui.png
TheArkive - DLFileGui.png (70.49 KiB) Viewed 1649 times

User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: DLFile - 2022/02/27

Post by TheArkive » 27 Feb 2022, 14:13

@BoBo

I don't mind at all :thumbup:

I'm about to post an update for batch downloads (built-in functionality).

EDIT: I'll add your code to the v1 script eventually (if you don't mind :D)

User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: DLFile - 2022/02/27

Post by TheArkive » 27 Feb 2022, 14:22

2022/02/27
  • now supports batch downloading (an array of URLs)
  • still supports a single download (url param is a single URL string)
  • updated docs
  • commented out CheckPartial() method for now

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: DLFile - 2022/02/27

Post by BoBo » 27 Feb 2022, 14:30

@TheArkive - AFAICS, the "cancel"-Button/option is suspending (therefore I'd opt to label it 'Suspend') the download bc the progress bar is stopping, not collapsing, OTOH the "resume"-Button/option looks like restarting the DL, instead of going on where it has been suspended? If I'm wrong and 'cancel' means stopping the download I'd opt for 'Exit DL' instead of 'Cancel', bc it's hard to distinguish between 'Cancel' and 'ESC'!? :think:

User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: DLFile - 2022/02/27

Post by TheArkive » 27 Feb 2022, 14:38

@BoBo

Crud, I didn't thoroughly test it.

Back to the drawing board :facepalm: I thought it was easier than that!

User avatar
haichen
Posts: 631
Joined: 09 Feb 2014, 08:24

Re: DLFile - 2022/02/27

Post by haichen » 27 Feb 2022, 15:20

"Yikes! If you can confirm it is from this script"
Oh I'm sorry, I didn't mean to imply that in any way. There's no connection whatsoever.

User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: DLFile - 2022/02/27

Post by TheArkive » 27 Feb 2022, 23:10

@haichen

No worries, I was just checking.

@BoBo

BoBo wrote:
27 Feb 2022, 14:30
@TheArkive - AFAICS, the "cancel"-Button/option is suspending (therefore I'd opt to label it 'Suspend') the download bc the progress bar is stopping, not collapsing, OTOH the "resume"-Button/option looks like restarting the DL, instead of going on where it has been suspended? If I'm wrong and 'cancel' means stopping the download I'd opt for 'Exit DL' instead of 'Cancel', bc it's hard to distinguish between 'Cancel' and 'ESC'!? :think:

The resume should be behaving properly now. As for 'Cancel' vs 'Suspend', I think in this context aren't they the same? If the user wishes to truly cancel the download, they can simply not resume.

If you want to design the UI for the example in the v1 version I'm ok with that :thumbup: I'll post whatever you come up with. (I find gui scripting in v1 to be headache inducing now that I've been spoiled by ahk v2.)
Last edited by TheArkive on 27 Feb 2022, 23:17, edited 1 time in total.

User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: DLFile - 2022/02/27

Post by TheArkive » 27 Feb 2022, 23:11

2022/02/28
  • fixed batch download logic to behave as expected

Post Reply

Return to “Scripts and Functions (v1)”