private async void Download_MouseUp(object sender, MouseButtonEventArgs e)
        {
            MainWindow.AddPage(new PleaseWait());
            var     ser     = Database.GetSeries((int)episode.seriesId);
            Torrent torrent = await Torrent.SearchSingle(ser, episode, Settings.DownloadQuality);

            if (torrent != null)
            {
                TorrentDownloader downloader = new TorrentDownloader(torrent);
                await downloader.Download();

                NotificationSender se = new NotificationSender("Download started", Helper.GenerateName(Database.GetSeries((int)episode.seriesId), episode));
                se.ClickedEvent += (s, ev) => {
                    Dispatcher.Invoke(() => {
                        MainWindow.RemoveAllPages();
                        MainWindow.SetPage(new DownloadsView());
                    }, DispatcherPriority.Send);
                };
                se.Show();
            }
            else
            {
                await MessageBox.Show("Sorry, torrent not found");
            }
            MainWindow.RemovePage();
        }
        private async void Stream_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            MainWindow.AddPage(new PleaseWait());
            Torrent tor = await Torrent.SearchSingle(Database.GetSeries((int)episode.seriesId), episode, Settings.StreamQuality);

            MainWindow.RemovePage();
            TorrentDownloader td = new TorrentDownloader(tor);
            await td.Stream();
        }
Пример #3
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();
                 }
             }
         }
     });
 }