Skip to content

Instantly share code, notes, and snippets.

@bdw429s
Created January 17, 2019 19:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bdw429s/47c8422a176e9a6b86acfbee9574d86c to your computer and use it in GitHub Desktop.
Save bdw429s/47c8422a176e9a6b86acfbee9574d86c to your computer and use it in GitHub Desktop.
CommandBox Task Runner to download packages from RiaForge
/**
* 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