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();
        }
示例#2
0
        private async void Download_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            TorrentDownloader td = new TorrentDownloader(torrent);

            MainWindow.AddPage(new PleaseWait());
            await td.Download();

            await Task.Run(() => Thread.Sleep(500));

            MainWindow.RemovePage();
        }
示例#3
0
        /// <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();
                 }
             }
         }
     });
 }