Created
January 17, 2019 19:09
-
-
Save bdw429s/47c8422a176e9a6b86acfbee9574d86c to your computer and use it in GitHub Desktop.
CommandBox Task Runner to download packages from RiaForge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Scrape all the binaries from RiaForge | |
*/ | |
component { | |
property name="progressableDownloader" inject="ProgressableDownloader"; | |
property name="progressBar" inject="ProgressBar"; | |
function run() { | |
directoryCreate( resolvePath( 'downloads' ), true, true ); | |
var projects = deserializeJSON( fileRead( 'http://riaforge.org/index.cfm?event=json.projects' ) ); | |
var slugs = projects.data.urlname; | |
slugs.each( function( slug ) { | |
var downloadURL = 'http://#slug#.riaforge.org/index.cfm?event=action.download&doit=true'; | |
var localPath = resolvePath( 'downloads/#slug#.zip' ); | |
if( !fileExists( localPath ) ) { | |
print.greenLine( "Downloading #downloadURL#..." ).toConsole(); | |
try{ | |
progressableDownloader.download( | |
downloadURL, | |
localPath, | |
function( status ) { | |
progressBar.update( argumentCollection = status ); | |
}, | |
function( newURL ) { | |
// RiaForge packages with no download link redirect to this dead page with no zip file on the end | |
if( newURL.endsWith( '.riaforge.org/downloads/' ) ) { | |
throw( 'No Download URL present on RIAForge' ); | |
} | |
print.yellowIndentedLine( newURL ).toConsole(); | |
} | |
); | |
} catch( any var e ) { | |
if( e.message == 'UserInterruptException' ) { rethrow; } | |
print.redIndentedLine( "#e.message# #e.detail#" ).toConsole(); | |
} | |
checkInterrupted(); | |
} | |
} ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment