private static int Execute(CommandArgs commandArgs, IOutput output) { Logger.Log.Info("Enter Download Select command."); int[] selectIndex = commandArgs.GetParameter <int[]>(SelectIndex); string name = commandArgs.GetParameter <string>(PodcastName); Logger.Log.Info($"Input podcast name is {name}."); Logger.Log.Info($"Input select index are {string.Join(";", selectIndex)}."); output.WriteLine("Building downloading file..."); if (!Directory.Exists(ProgramConfiguration.DownloadConfigurations.DownloadPodcastPath)) { Logger.Log.Info($"Create directory, is {ProgramConfiguration.DownloadConfigurations.DownloadPodcastPath}."); Directory.CreateDirectory(ProgramConfiguration.DownloadConfigurations.DownloadPodcastPath); } int res = Opml.DownloadPodcastSelectRelease(name, selectIndex, ProgramConfiguration.DownloadConfigurations.DownloadPodcastPath, false, ProgramConfiguration.DownloadConfigurations.DownloadProgram); if (res != 0) { Logger.Log.Warn("The input name is NOT in the library."); output.WriteLine("Error. Input of Name does not contain in the library."); return(0); } output.WriteLine("Building done"); Logger.Log.Info("Finish build download file."); output.WriteLine("Downloading..."); if (ProgramConfiguration.DownloadConfigurations.DownloadProgram == DownloadTools.Aria2Name) { Logger.Log.Info("Start download newly release use aria2."); DownloadTools.DownloadAria2(ProgramConfiguration.DownloadConfigurations.DownloadProgramPathName, ProgramConfiguration.DownloadFileName, output); } else if (ProgramConfiguration.DownloadConfigurations.DownloadProgram == DownloadTools.IdmName) { Logger.Log.Info("Start download newly release use idm."); DownloadTools.DownloadIdm(ProgramConfiguration.DownloadConfigurations.DownloadProgramPathName, ProgramConfiguration.DownloadFileName, output); } Logger.Log.Info("Finish download."); output.WriteLine("Done."); return(0); }
private static int Execute(CommandArgs commandArgs, IOutput output) { Logger.Log.Info("Enter Upgrade command."); if (File.GetLastWriteTimeUtc(ProgramConfiguration.PodcastNewlyReleaseInfo) - DateTime.Now > TimeSpan.FromDays(1)) { Logger.Log.Info("Need Upgrade first."); output.WriteLine("Updating..."); Opml.UpdateAllPodcasts(ref output); output.WriteLine("Update done."); } output.WriteLine("Upgrading..."); if (File.Exists(ProgramConfiguration.PodcastNewlyReleaseInfo)) { if (ProgramConfiguration.DownloadConfigurations.DownloadProgram == DownloadTools.Aria2Name) { Logger.Log.Info("Start download newly release use aria2."); output.WriteLine("Start download newly release use aria2."); DownloadTools.DownloadAria2(ProgramConfiguration.DownloadConfigurations.DownloadProgramPathName, ProgramConfiguration.PodcastNewlyReleaseInfo, output); } else if (ProgramConfiguration.DownloadConfigurations.DownloadProgram == DownloadTools.IdmName) { Logger.Log.Info("Start download newly release use idm."); output.WriteLine("Start download newly release use idm."); DownloadTools.DownloadIdm(ProgramConfiguration.DownloadConfigurations.DownloadProgramPathName, ProgramConfiguration.PodcastNewlyReleaseInfo, output); } File.Delete(ProgramConfiguration.PodcastNewlyReleaseInfo); Logger.Log.Info("Finish download newly release."); File.Delete(ProgramConfiguration.PodcastNewlyReleaseInfo); output.WriteLine("Done."); } else { Logger.Log.Info("Nothing upgrade."); output.WriteLine("All up-to-date. Nothing download."); } return(0); }
private static int Execute(CommandArgs commandArgs, IOutput output) { Logger.Log.Info("Enter Download command."); string podcastsDownloadDirectory = commandArgs.GetOption <string>(DownloadDirectory); Logger.Log.Info($"Download directory is {podcastsDownloadDirectory}."); if (!Directory.Exists(podcastsDownloadDirectory)) { Logger.Log.Info("Create download directory."); try { Directory.CreateDirectory(podcastsDownloadDirectory); } catch { Logger.Log.Info($"Directory \"{podcastsDownloadDirectory}\" is not valid."); output.WriteLine("Error. Input of 'dir' is illegal."); return(0); } } bool isSimpleFile = commandArgs.GetFlag(SimpleFile); Logger.Log.Info($"Download simple file is {isSimpleFile}."); string date = commandArgs.GetParameter <string>(Date); DateTime dt; try { dt = DateTime.ParseExact(date, "yyyyMMdd", new CultureInfo("en-US")); Logger.Log.Info($"Download date is {dt.ToString("G")}."); } catch { Logger.Log.Warn($"Download date is not valid."); output.WriteLine("Error. Input of 'date' is illegal."); return(0); } output.WriteLine("Building downloading file..."); Logger.Log.Info("Build download file."); Opml.DownloadPodcastAfterDate(dt, podcastsDownloadDirectory, isSimpleFile, ProgramConfiguration.DownloadConfigurations.DownloadProgram); Logger.Log.Info("Finish build download file."); output.WriteLine("Building done"); if (!isSimpleFile) { output.WriteLine("Downloading..."); if (ProgramConfiguration.DownloadConfigurations.DownloadProgram == DownloadTools.Aria2Name) { Logger.Log.Info("Start download newly release use aria2."); DownloadTools.DownloadAria2(ProgramConfiguration.DownloadConfigurations.DownloadProgramPathName, ProgramConfiguration.DownloadFileName, output); } else if (ProgramConfiguration.DownloadConfigurations.DownloadProgram == DownloadTools.IdmName) { Logger.Log.Info("Start download newly release use idm."); DownloadTools.DownloadIdm(ProgramConfiguration.DownloadConfigurations.DownloadProgramPathName, ProgramConfiguration.DownloadFileName, output); } Logger.Log.Info("Finish download."); output.WriteLine("Done."); } return(0); }