public fileIndex(config settings) { fullPath = settings.getFullPathToFiles(); indexFileName = settings.getIndexFileName(); fileExtension = settings.getFileExtension(); checkForIndexFile(); }
public getFileInfo(config settings, int dayOffset) { string currentURL = (settings.getUrl()).Replace("$DATE", returnDate(dayOffset, settings.getDateFormat())); pageSource = getPageSource(currentURL); fileUrl = "http://" + findElement(pageSource, settings.getFileExtension(), "http://") + settings.getFileExtension(); title = (findElement(pageSource, settings.getTitleEnd(), settings.getTitleStart())).Trim(); episodeNumber = findElement(fileUrl, settings.getFileExtension(), "_"); fullTitle = "Episode " + episodeNumber + ": " + title; newFileName = episodeNumber + "#-" + title.Replace(" ", "_")+settings.getFileExtension(); }
public multiDownload(config settings, ref processFile downloadAndSave, int limit) { int counter = 0; bool runLoop = true; while (runLoop) { getFileInfo currentFile = new getFileInfo(settings, counter); if (currentFile.getFileUrl() != "" && counter < limit) { Console.WriteLine("Downloading: "+currentFile.getFullTitle()); downloadAndSave.download(currentFile); } else { runLoop = false; } counter++; } }
public processFile(config settings) { fullPath = settings.getFullPathToFiles(); indexFileName = settings.getIndexFileName(); }
static void Main(string[] args) { // get any arguments passed in at the commandline Arguments CommandLine = new Arguments(args); // load config file config settings = new config(); if (CommandLine["config"] != null) { settings.setConfigPath(Convert.ToString(CommandLine["config"])); } else { settings.setConfigPath("config.xml"); } // create or update index file fileIndex setIndex = new fileIndex(settings); // create file downloader processFile downloadAndSave = new processFile(settings); //*********************************************************** if (CommandLine["rebuild-index"] != null || CommandLine["build-index"] != null) { setIndex.rebuildIndex(); } if (CommandLine["defaults"] != null) { settings.setDefaults(); } if (CommandLine["write-defaults"] != null) { settings.createDefaultConfig(); } if (CommandLine["help"] != null || CommandLine["?"] != null) { showHelp(); } else if (CommandLine["c"] != null) { if (CommandLine["c"] == "1") { //download just today getFileInfo todaysFile = new getFileInfo(settings, 0); downloadAndSave.download(todaysFile); } else if (Convert.ToInt16(CommandLine["c"]) > 1) { multiDownload download = new multiDownload(settings, ref downloadAndSave, Convert.ToInt16(CommandLine["c"])); } else { showHelp(); Console.WriteLine("\nYou must enter enter a valid number for count 'c'."); } } else if (CommandLine["all"] != null) { // 35 does whole three weeks multiDownload download35 = new multiDownload(settings, ref downloadAndSave, 35); } else { // normal mode multiDownload downloadNormal = new multiDownload(settings, ref downloadAndSave, settings.getNormalMode()); } }