private void RenderOnFinished() { Task.Run(() => { bool isLoaded = true; Dispatcher.Invoke(() => { isLoaded = IsLoaded; }); while (isLoaded) { var list = TorrentDatabase.Load().Where(x => x.HasFinished).ToList(); list.Reverse(); if (list.Count > uielements.Count) { var torrents = new List <Torrent>(); uielements.Values.ToList().ForEach(x => torrents.Add(x)); List <Torrent> changes = list.Where(x => !torrents.Contains(x)).ToList(); foreach (var item in changes) { Dispatcher.Invoke(() => { FinishedTorrentUserControl tcu = new FinishedTorrentUserControl(item); tcu.Height = 65; tcu.Margin = new Thickness(10, 0, 10, 0); tcu.Opacity = 0; SecondPanel.Children.Add(tcu); var sb = (Storyboard)FindResource("OpacityUp"); sb.Begin(tcu); uielements.Add(tcu, item); }); } } Thread.Sleep(2000); Dispatcher.Invoke(() => { isLoaded = IsLoaded; }); } }); }
/// <summary> /// Continues all unifinished torrents /// </summary> public async static void ContinueUnfinished() { var torrents = TorrentDatabase.Load(); torrents = torrents.Where(x => x.HasFinished == false).ToList(); foreach (var item in torrents) { TorrentDatabase.Remove(item.Magnet); TorrentDownloader downloader = new TorrentDownloader(item); await downloader.Download(); } }
private async static Task DownloadLastWeek() { await Task.Run(async() => { var series = Database.GetSeries().Where(x => x.autoDownload); var episodes = new Dictionary <Series, List <Episode> >(); foreach (var se in series) { //adds episodes that dont have files and have been released in last week episodes.Add(se, Database.GetEpisodes(se.id).Where(x => x.files.Count == 0 && !String.IsNullOrEmpty(x.firstAired) && Helper.ParseAirDate(x.firstAired) > DateTime.Now.AddDays(-7) && Helper.ParseAirDate(x.firstAired).AddDays(1) < DateTime.Now).ToList()); } foreach (var combination in episodes) { foreach (var episode in combination.Value) { if (TorrentDatabase.Load().Where(x => x.Episode.id == episode.id).ToList().Count == 0) { TorrentDownloader downloader = new TorrentDownloader(await Torrent.SearchSingle(combination.Key, episode, Settings.DownloadQuality)); await downloader.Download(); } } } }); }