Exemple #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            YTDLUpdater updater = new YTDLUpdater();

            updater.UpdatingDownloader += Updater_UpdatingDownloader;
            updater.UpdateYTDL();
            if (ProgramConfigReader.GetCurrentConfigData().IsAutoCheckUpdate)
            {
                VersionInfo info = ProgramConfigReader.GetLatestVersion();
                if ((info.NewVersion != "NOT AVAILABLE") && (info.NewVersion != ProgramConfigReader.GetCurrentConfigData().CurrentVersion))
                {
                    MessageBoxResult result = MessageBox.Show("New version available, " + info.NewVersion + " from " + info.VersionDate + Environment.NewLine + "Would you like to update?", "Update Available", MessageBoxButton.YesNo, MessageBoxImage.Information);
                    if (result == MessageBoxResult.Yes)
                    {
                        Mainframe.Navigate(new Uri("OptionsPage.xaml", UriKind.Relative));
                        return;
                    }
                }
            }
            Mainframe.Navigate(new Uri("DownloadPage.xaml", UriKind.Relative));
        }
Exemple #2
0
        public void TimerCallBack(object o)
        {
            Log.WriteLog(LogType.Info, "Starting maintainance...");
            if (!File.Exists(folderPath + "\\maintainance.lck"))
            {
                File.Create(folderPath + "\\maintainance.lck").Dispose();
            }
            Log.WriteLog(LogType.Info, "Checking for youtube-dl updates...");
            YTDLUpdater updater = new YTDLUpdater();

            updater.UpdatingDownloader    += Updater_UpdatingDownloader;
            updater.DownloaderUpdateError += Updater_DownloaderUpdateError;
            updater.CheckYTDLUpdates();
            Log.WriteLog(LogType.Info, "Checking and deleting any old files...");
            string[] webmFiles = Directory.GetFiles(folderPath, "*.webm");
            foreach (string eachFile in webmFiles)
            {
                DateTime lastModified = File.GetLastWriteTime(eachFile);
                TimeSpan difference   = DateTime.Now.Subtract(lastModified);
                if (difference.Hours > 4)
                {
                    Log.WriteLog(LogType.Info, "Deleting " + eachFile + " as the time diff is more than 4 hours (" + difference.ToString() + ")");
                    File.Delete(eachFile);
                }
            }
            string[] mp4Files = Directory.GetFiles(folderPath, "*.mp4");
            foreach (string eachFile in mp4Files)
            {
                DateTime lastModified = File.GetLastWriteTime(eachFile);
                TimeSpan difference   = DateTime.Now.Subtract(lastModified);
                if (difference.Hours > 4)
                {
                    Log.WriteLog(LogType.Info, "Deleting " + eachFile + " as the time diff is more than 4 hours (" + difference.ToString() + ")");
                    File.Delete(eachFile);
                }
            }
            string[] mkvFiles = Directory.GetFiles(folderPath, "*.mkv");
            foreach (string eachFile in mkvFiles)
            {
                DateTime lastModified = File.GetLastWriteTime(eachFile);
                TimeSpan difference   = DateTime.Now.Subtract(lastModified);
                if (difference.Hours > 4)
                {
                    Log.WriteLog(LogType.Info, "Deleting " + eachFile + " as the time diff is more than 4 hours (" + difference.ToString() + ")");
                    File.Delete(eachFile);
                }
            }
            string[] jpgFiles = Directory.GetFiles(folderPath, "*.jpg");
            foreach (string eachFile in jpgFiles)
            {
                DateTime lastModified = File.GetLastWriteTime(eachFile);
                TimeSpan difference   = DateTime.Now.Subtract(lastModified);
                if (difference.Hours > 4)
                {
                    Log.WriteLog(LogType.Info, "Deleting " + eachFile + " as the time diff is more than 4 hours (" + difference.ToString() + ")");
                    File.Delete(eachFile);
                }
            }
            string[] mp3Files = Directory.GetFiles(folderPath, "*.mp3");
            foreach (string eachFile in mp3Files)
            {
                DateTime lastModified = File.GetLastWriteTime(eachFile);
                TimeSpan difference   = DateTime.Now.Subtract(lastModified);
                if (difference.Hours > 4)
                {
                    Log.WriteLog(LogType.Info, "Deleting " + eachFile + " as the time diff is more than 4 hours (" + difference.ToString() + ")");
                    File.Delete(eachFile);
                }
            }
            Log.WriteLog(LogType.Info, "Maintainance complete, deleting maintainance.lck...");
            File.Delete(folderPath + "\\maintainance.lck");
            Log.WriteLog(LogType.Info, "Next maintainance after 4 hours");
        }