Downloading with the default downloaders in Firefox or Chrome never was my favourite way of archiving things away. You lose two metadata information – the modification time of the downloaded file is set to the download time and the URL path is stripped, you only see the filename in your download folder.
Therefore I usually copied and pasted the URLs into a terminal and prefixed the URLs with “wget -m”. Before that I had to create a matching folder and cd into it.
This grew cumbersome, but the real reason for searching for a solution within the graphical browsers was the fact that more and more sites have download protectors installed that require a sane referrer, or maybe even session cookies.
I searched the net for a solution and stumbled over a Chrome extension created by Google, called Chrome Download Assistant. There are several other solutions, but this was the simplest and still widely used solution that suited my needs.
The default setup has a wget download handler, which preserves the downloaded file’s timestamp (if provided by the server), but loses the URL path. The wget command called looks effectively like (this is with version 4.0.7):
wget -c --referer="$REFERER" -O $FILE_NAME "$URL"
The extensions allows to add you own download handler, but there isn’t much documentation besides the source as to what variables are available. As of 4.0.7 the following variables can be used:
|$URL||The URL of the object that is to be downloaded|
|$REFERER||The referring URL to the object to download (the misspelling is historical and required)|
|$FILE_NAME||The full path to the object on the local storage (as envisioned by chrome)|
|$DOWNLOAD_PATH||The directory components of $FILE_NAME|
I constructed a custom downloader like
wget -mc --referer="$REFERER" -P "$DOWNLOAD_PATH" "$URL"
Unfortunately this didn’t work as there was a bug ignoring all but the first argument, but this is fixed now.
There is another smallish issue remaining in that $DOWNLOAD_PATH is only set for certain predefined downloaders. So the above line effectively uses $HOME as a download root. Until this is addressed one can explicitely hardwire a download location or just use $HOME.