public static TorrentMovieSource CreateInvalidTorrentMovieSource(TorrentEntry torrentEntry)
 {
     return new TorrentMovieSource
     {
         TorrentMovie = TorrentMovieFactory.CreateTorrentMovie(torrentEntry),
         State = TorrentMovieState.Invalid
     };
 }
 public static TorrentMovieSource CreateIncompleteTorrentMovieSource(TorrentEntry torrentEntry, TorrentImdbEntry torrentImdbEntry)
 {
     return new TorrentMovieSource
     {
         TorrentMovie = TorrentMovieFactory.CreateTorrentMovie(torrentEntry, torrentImdbEntry),
         State = TorrentMovieState.Incomplete
     };
 }
Esempio n. 3
0
 public static TorrentMovie CreateTorrentMovie(TorrentEntry torrentEntry)
 {
     return new TorrentMovie
     {
         TorrentLink = torrentEntry.TorrentUri,
         Movie = torrentEntry.TorrentPage.Split('/').LastOrDefault(),
         Quality = torrentEntry.Quality,
         LastUpdated = DateTime.Now
     };
 }
Esempio n. 4
0
 public static TorrentMovie CreateTorrentMovie(TorrentEntry torrentEntry, TorrentImdbEntry torrentImdbEntry)
 {
     return new TorrentMovie
     {
         Id = torrentImdbEntry.ImdbId,
         TorrentLink = torrentEntry.TorrentUri,
         ImdbLink = torrentImdbEntry.ImdbLink,
         Quality = torrentEntry.Quality,
         LastUpdated = DateTime.Now
     };
 }
Esempio n. 5
0
        private IObservable<TorrentMovieSource> GetMovie(TorrentEntry torrent, CancellationToken cancellationToken)
        {
            return Observable.FromAsync(async () =>
            {
                var imdbEntry = _torrentImdbEntryRepository.GetById(torrent.TorrentUri)
                    ?? await TorrentImdbEntryExtractor.ExtractImdbEntry(torrent.TorrentUri, cancellationToken);

                if (!imdbEntry.IsValid)
                {
                    return TorrentMovieSourceFactory.CreateInvalidTorrentMovieSource(torrent);
                }

                _torrentImdbEntryRepository.Add(imdbEntry);

                var cacheMovie = _torrentRepository.Get(imdbEntry.ImdbLink);
                if (cacheMovie != null)
                {
                    Console.WriteLine($"[from cache] {cacheMovie.Movie} IMDB rating: {cacheMovie.Rating}");
                    return TorrentMovieSourceFactory.CreateCompleteTorrentMovieSource(cacheMovie);
                }

                return TorrentMovieSourceFactory.CreateIncompleteTorrentMovieSource(torrent, imdbEntry);
            });
        }