Ejemplo n.º 1
0
 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();
                 }
             }
         }
     });
 }