}
public static void main(String[] args)
{
final DownloadReport report = new DownloadReport();
Configuration conf = new Configuration();
if (parseArgs(args, conf))
{
try
{
/* Parse the configuration xml file */
conf.loadFile((String) conf.get("config_file"));
/* Load the plugins */
PluginLoader loader = new PluginLoader((String)(conf.get(Configuration.PLUGIN_FOLDER_TAG)));
loader.load();
/* Get the subreddits */
List<String> subreddits = (List<String>)conf.get(Configuration.SUBREDDITS_ALLOWED_TAG);
/* Get number of download threads and create the thread pool */
String downloadThreads = (String)conf.get(Configuration.PARALLEL_DOWNLOAD_TAG);
int numberOfThreads = downloadThreads == null ? 10 : Integer.valueOf(downloadThreads);
ExecutorService threadPool = Executors.newFixedThreadPool(numberOfThreads);
/* Connect to reddit and get the content from the source given */
System.out.println("Connecting to reddit");
RedditRequest reddit = new RedditRequest((String) conf.get("reddit_token"));
System.out.println("Fetching results");
String sourceUrl = (String) conf.get("source_url");
String countStr = (String) conf.get("count");
int count = countStr == null ? 25 : Integer.valueOf(countStr);
int numberOfBatchs = count / 100 + 1;
String lastFetched = null;
for (int i = 0; i < numberOfBatchs; ++i)