I've just seen " - Static download URLs for aria2 download utility updated" in last changelog.
But myself, I long time ago written script for unattendedly downloading something from sourceforge, using "recommended" url. Actually this is multiple scripts, but they're not that complex. Most useful part of this is, probably, wget arguments in first script
Hope they'll help avoid updating download URL manually.
download.cmd
- Code: Select all
@REM coding:OEM
SET srcpath=%~dp0
SET distcleanup=1
IF NOT DEFINED baseScripts SET baseScripts=\Scripts
CALL "_DistDownload.cmd" "http://sourceforge.net/projects/aria2/files/latest/download" aria2-*.zip -m -l 1 -A.zip -nd -H -D downloads.sourceforge.net -e "robots=off" -p --user-agent="Mozilla/5.0 (Windows NT 5.1; rv:0.0)"
_DistDownload.cmd
- Code: Select all
@REM coding:OEM
@REM Automated software update scripts
@REM by logicdaemon@gmail.com
@REM logicdaemon.ru
@REM usage: %0 URL [distmask|""]
@REM input:
ECHO Arguments: %*
@REM %1 URL of page with links / or of file, in latter case use -N switch for wget
@REM %2 file mask of distributive
@REM if not set, %~nx1 is used (filename from URL)
@REM if distfmask is set, %2 is skipped (next argument is %2)
@REM %3*
@REM arguments for wget. First is unquoted before passing to wget, others are passed "as is"
@REM (disabled) if %3 begins with -N, "logfname=%~nx2.log" is added to wget arguments
@REM default: "-m -l 1 -nd -e robots=off --no-check-certificate"
ECHO srcpath=%srcpath%
@REM mandatory, it's destination for distributive file
ECHO distcleanup=%distcleanup%
@REM if set to 1, distcleanup procedures are executed
ECHO AddtoSUScripts=%AddtoSUScripts%, SUScripts=%SUScripts%
@REM whatever to call "%%SUScripts%%\..\templates\_add_withVer.cmd" or not. SUScripts must also be defined.
ECHO findpath=%findpath%
@REM relative path for unix find, which performed when seeking %distfmask% for files to link
ECHO findargs=%findargs%
@REM arguments for find. Default: -name %distfmask%
ECHO dstrename=%dstrename%
@REM new name for downloaded file. WARNING: distcleanup is done with source mask anyway! Default: %distfname%
ECHO logfname=%logfname%
@REM or determined from other args if not set
ECHO dstrename=%dstrename%
@REM new name for distributive file
@REM
ECHO baseDistUpdateScripts=%baseDistUpdateScripts%
@REM and
ECHO baseDistributives=%baseDistributives%
@REM determine relpath from srcpath and redirection of srcpath, and
ECHO baseWorkdir=%baseWorkdir%
@REM and
ECHO baseLogsDir=%baseLogsDir%
@REM are used with relpath for default values of workdir and logsDir
SETLOCAL ENABLEEXTENSIONS
IF NOT DEFINED srcpath EXIT /B 32767
CALL "%~dp0_GetWorkPaths.cmd"
rem srcpath with baseDistUpdateScripts replaced to baseDistributives
rem relpath is srcpath relatively to baseDistributives (no trailing backslash)
rem workdir - baseWorkdir with relpath (or %srcpath%temp if baseWorkdir isn't defined)
rem logsDir - baseLogsDir with relpath (or nothing)
IF "%~1%"=="" (
ECHO Not enough arguments.
ECHO Usage:
ECHO %0 URL [disributiveFileMask ["wget parameters"] ]
EXIT /B 32767
)
(
SET rdistpath=%~1
@REM skiptokens: default suggestion is 1 argument for URL, and distmask is defined as env var (or distmask is "" on command line).
@REM even in worst scenario, if distmask will become one of arguments for wget, we'll just get one more query to non-existing host
SET skiptokens=1
)
@REM skiptokens: but if distmast wasn't specified with variable, probably it's on command line
IF "%distfmask%"=="" (
@REM skiptokens: if distmask isn't determined till here, distmask wasn't defined as env var, and we've got one of cases:
@REM * on the command line there was one argument only
@REM * second argument on the command line was ""
@REM in either case, we're going to skip second argument (to not feed wget with quoted empty string "")
SET skiptokens=2
IF "%~2"=="" (
SET "distfmask=%~nx1"
) ELSE (
SET "distfmask=%~2"
)
)
@REM If there were no distfmask defined, no 2nd arg, and extension, just get any file
IF "%distfmask%"=="" SET distfmask=*
IF NOT "%~2"=="" (
@REM everything after skiptokens are arguments for wget, we'll feed them to wget
FOR /F "usebackq tokens=%skiptokens%*" %%I IN ('%*') DO SET "wgetparm=%%J"
)
IF NOT DEFINED wgetparm SET "wgetparm=-m -l 1 -nd -e robots=off --no-check-certificate"
IF NOT DEFINED logfname IF "%wgetparm:~,2%"=="-N" SET "logfname=%logsDir%%~nx2.log"
SET checklogfname=%logfname:^*=%
SET checklogfname=%checklogfname:?=%
IF NOT "%checklogfname%"=="%logfname%" SET logfname=
IF NOT DEFINED logfname SET "logfname=%logsDir%%~nx1.log"
IF NOT EXIST "%workdir%" MKDIR "%workdir%"
ECHO wget -o "%logfname%" --progress=dot:giga %wgetparm% %rdistpath%
START "" /B /WAIT /D"%workdir%" wget -o "%logfname%" --progress=dot:giga %wgetparm% %rdistpath%
SET wgeterrorlevel=%ERRORLEVEL%
IF DEFINED findpath (
CALL :CheckFindPath
) ELSE SET findpath=.
IF NOT DEFINED findargs SET findargs=-name "%distfmask%"
CALL :InitRemembering
@REM In FOR's, use "%%~I" because Win2K and XP differently set quotes around iterator variable:
@REM 2K always outputs without quotes, but XP's 'FOR' double-quotes argument if it contains spaces.
FOR /F "usebackq delims=" %%I IN (`%SystemDrive%\SysUtils\UnxUtils\find "%workdir%%findpath%" %findargs%`) DO CALL :RememberIfLatest dstfname "%%~fI"
(
IF DEFINED dstfname CALL :linkdst "%dstfname%"
IF DEFINED SUScripts IF "%AddtoSUScripts%"=="1" CALL "%SUScripts%\..\templates\_add_withVer.cmd" "%dstfname%"
EXIT /B %wgeterrorlevel%
)
:linkdst
(
SET dstfname=%~nx1
IF DEFINED dstrename SET dstfname=%dstrename%
)
IF "%distcleanup%"=="1" IF EXIST "%srcpath%%dstfname%" (
SET cleanup_action=DEL /Q /A-R-H-S
CALL distcleanup.cmd "%~dp1%distfmask%" %1
SET cleanup_action=CALL mvold
CALL distcleanup.cmd "%srcpath%%distfmask%" "%srcpath%%dstfname%"
)
xln %1 "%srcpath%%dstfname%"||COPY /B /Y %1 "%srcpath%%dstfname%"
EXIT /B
:InitRemembering
(
SET LatestFile=
SET LatestDate=0000000000:00
EXIT /B
)
:RememberIfLatest
(
SET CurrentFile=%~2
SET CurrentDate=%~t2
)
(
@rem 01.12.2011 21:29
SET CurrentDate=%CurrentDate:~6,4%%CurrentDate:~3,2%%CurrentDate:~0,2%%CurrentDate:~11%
)
IF "%CurrentDate%" GEQ "%LatestDate%" (
SET LatestFile=%CurrentFile%
SET LatestDate=%CurrentDate%
)
SET %1=%LatestFile%
EXIT /B
:CheckFindPath
IF "%findpath:~-1%"=="\" SET findpath=%findpath:0,-1%
IF "%findpath:~0,1%"=="\" SET findpath=%findpath:1%
EXIT /B
DistCleanup.cmd
- Code: Select all
@REM coding:OEM
REM procedure cleans up directory excluding first argument
REM If only argument is given, whole directory except one file cleaned up
REM If two or more aruments, first is mask, and others are exclusion
REM
REM by logicdaemon@gmail.com
REM logicdaemon.ru
REM may be distributed under LGPL
SETLOCAL ENABLEEXTENSIONS
IF NOT DEFINED cleanup_action SET cleanup_action=ECHO
IF NOT DEFINED cleanup_checkMoveCMD SET cleanup_checkMoveCMD="%temp%\cleanup_checkMove.cmd"
SET excl=
SET exclN=0
IF "%~2"=="" (
SET mask=%~dp1*%~x1
SET excl=%~f1
SET exclN=1
) ELSE (
SET mask=%~1
REM setting excl for case when there will be no %3
SET excl=%~f2
GOTO :cleanup_assembleExclusions
)
:cleanup_maincycle
IF %exclN% GTR 1 GOTO :cleanup_multipleExclusions
REM only exclusion
FOR %%I IN ("%mask%") DO IF NOT "%%~fI"=="%excl%" %cleanup_action% "%%~I"
ENDLOCAL
EXIT /B
:cleanup_multipleExclusions
SET findmask=%mask:\=\\%
FOR /F "usebackq delims=" %%I IN (`%SystemDrive%\SysUtils\UnxUtils\find %mask%`) DO CALL %cleanup_checkMoveCMD% "%%~I"
ENDLOCAL
EXIT /B
:cleanup_assembleExclusions
ECHO.>%cleanup_checkMoveCMD%
:cleanup_ae_cycle
SHIFT
IF "%~1"=="" GOTO :cleanup_assembleEnd
ECHO IF "%%~1"=="%~1" EXIT /B 1>>%cleanup_checkMoveCMD%
SET /A exclN+=1
GOTO :cleanup_ae_cycle
:cleanup_assembleEnd
REM If only one exclusion, do not use %cleanup_checkMoveCMD%
ECHO DEL "%%~1">>%cleanup_checkMoveCMD%
IF %exclN%==1 DEL %cleanup_checkMoveCMD%
GOTO :cleanup_maincycle
This work by LogicDaemon is licensed under a Creative Commons Attribution 3.0 Unported License.