示例#1
0
        void Run(bool cleanRun)
        {
            _dispatcher = Dispatcher.CurrentDispatcher;
            _context = new DataContext();

            var profiles = _context.GetProfiles();
            foreach (var profile in profiles)
            {
                if (cleanRun)
                {
                    foreach (var series in profile.Series.ToArray())
                    {
                        _context.RemoveSeries(series);
                    }
                    profile.Series.Clear();

                }
                new ApiParser(profile).ReadSeries();

                _context.Save();

                Parallel.ForEach(profile.Series.SelectMany(s => s.Episodes).Select(e=>e.EpisodeId), ProcessEpisode);

                _context.Save();
            }
        }
示例#2
0
        private void ProcessEpisode(long episodeId)
        {
            DataContext context = new DataContext();
            var episode = context.GetEpisodeById(episodeId);

            if ((episode.LastUpdate - episode.AirDate).Days > 2) return;
            if (DateTime.Now - episode.LastUpdate < _updateTime) return;

            var series = episode.Series;

            var result = _tpb.Search(series, episode).Take(3);

            foreach (var torrent in episode.Torrents.ToArray())
            {
                context.RemoveTorrent(torrent);
            }

            foreach (var r in result)
            {
                episode.Torrents.Add(r);
                _logger.Info("{0} [{2}] {1}", r.Title, r.Magnet.Substring(0, 10), r.Seed);
            }
            var subs = _podnapisi.Search(series, episode);

            foreach (var subtitles in episode.Subtitles.ToArray())
            {
                context.RemoveSubtitles(subtitles);
            }

            foreach (var s in subs)
            {
                 episode.Subtitles.Add(s);
                _logger.Info("{0} {1}", s.Title, s.File.Length);
            }

            episode.LastUpdate = DateTime.Now;
            context.Save();
        }
示例#3
0
 public ProfileViewModel()
 {
     _dataContext = new DataContext();
     Series = new BindableCollection<SeriesViewModel>(_dataContext.GetUnwatchedSeries(0).Select(s => new SeriesViewModel(s)));
 }