Beispiel #1
0
        public static void InitTvShow(TvShow tvShow, INovaromaEngine engine)
        {
            var episodes = tvShow.Seasons.SelectMany(s => s.Episodes).ToList();

            episodes.ForEach(e => {
                if (!string.IsNullOrEmpty(e.FilePath) && !File.Exists(e.FilePath))
                {
                    e.FilePath           = string.Empty;
                    e.SubtitleDownloaded = false;
                }
                if (e.IsWatched)
                {
                    return;
                }

                e.BackgroundDownload         = true;
                e.BackgroundSubtitleDownload = engine.SubtitlesNeeded(tvShow.Language);
                e.SubtitleDownloaded         = false;
            });

            if (string.IsNullOrWhiteSpace(tvShow.Directory) || !Directory.Exists(tvShow.Directory))
            {
                return;
            }

            var files      = new DirectoryInfo(tvShow.Directory).GetFiles("*", SearchOption.AllDirectories).ToList();
            var videoFiles = files.Where(IsVideoFile).ToList();

            foreach (var videoFile in videoFiles)
            {
                int?season, episode;
                DetectEpisodeInfo(videoFile.NameWithoutExtension(), tvShow.Title, out season, out episode, videoFile, tvShow.Seasons.Max(s => s.Season));
                if (!season.HasValue || !episode.HasValue)
                {
                    continue;
                }

                var tvEpisode = episodes.FirstOrDefault(e => e.TvShowSeason.Season == season && e.Episode == episode.Value);
                if (tvEpisode == null)
                {
                    continue;
                }

                tvEpisode.BackgroundDownload = false;
                tvEpisode.NotFound           = false;
                tvEpisode.FilePath           = videoFile.FullName;
                var subtitleFilePath = GetSubtitleFilePath(videoFile);
                if (!string.IsNullOrEmpty(subtitleFilePath))
                {
                    tvEpisode.BackgroundSubtitleDownload = false;
                    tvEpisode.SubtitleNotFound           = false;
                    tvEpisode.SubtitleDownloaded         = true;
                }
            }
        }
Beispiel #2
0
        internal static void MovieDownloadCheck(object prm, INovaromaEngine engine)
        {
            var movie = prm as Movie;

            if (movie == null)
            {
                return;
            }

            movie.BackgroundSubtitleDownload = movie.BackgroundDownload && engine.SubtitlesNeeded(movie.Language);
        }
Beispiel #3
0
        internal static void EpisodeDownloadCheck(object prm, INovaromaEngine engine)
        {
            var episode = prm as TvShowEpisode;

            if (episode == null)
            {
                return;
            }

            var tvShow = episode.TvShowSeason.TvShow;

            episode.BackgroundSubtitleDownload = episode.BackgroundDownload && engine.SubtitlesNeeded(tvShow.Language);
        }
Beispiel #4
0
        public static void InitMovie(Movie movie, INovaromaEngine engine)
        {
            FileInfo firstVideoFile = null;

            if (!string.IsNullOrWhiteSpace(movie.Directory) && Directory.Exists(movie.Directory))
            {
                var files = new DirectoryInfo(movie.Directory).GetFiles("*", SearchOption.AllDirectories).ToList();
                firstVideoFile = files.FirstOrDefault(IsVideoFile);
            }

            if (firstVideoFile != null)
            {
                movie.BackgroundDownload = false;
                movie.NotFound           = false;
                movie.FilePath           = firstVideoFile.FullName;
                var subtitleFilePath = GetSubtitleFilePath(firstVideoFile);
                if (!string.IsNullOrEmpty(subtitleFilePath))
                {
                    movie.BackgroundSubtitleDownload = false;
                    movie.SubtitleNotFound           = false;
                    movie.SubtitleDownloaded         = true;
                }
                else
                {
                    movie.BackgroundSubtitleDownload = engine.SubtitlesNeeded(movie.Language);
                    movie.SubtitleDownloaded         = false;
                }
            }
            else
            {
                movie.BackgroundDownload         = true;
                movie.FilePath                   = string.Empty;
                movie.BackgroundSubtitleDownload = engine.SubtitlesNeeded(movie.Language);
                movie.SubtitleDownloaded         = false;
            }
        }
Beispiel #5
0
        internal static void AllSeasonDownloadCheck(object prm, INovaromaEngine engine)
        {
            var season = prm as TvShowSeason;

            if (season == null || !season.AllBackgroundDownload.HasValue)
            {
                return;
            }

            var tvShow = season.TvShow;

            season.AllBackgroundSubtitleDownload = season.AllBackgroundDownload.Value && engine.SubtitlesNeeded(tvShow.Language);
        }
Beispiel #6
0
        internal static void AllTvDownloadCheck(object prm, INovaromaEngine engine)
        {
            var tvShow = prm as TvShow;

            if (tvShow == null || !tvShow.AllBackgroundDownload.HasValue)
            {
                return;
            }

            tvShow.AllBackgroundSubtitleDownload = tvShow.AllBackgroundDownload.Value && engine.SubtitlesNeeded(tvShow.Language);
        }
Beispiel #7
0
        internal static void MovieDownloadCheck(object prm, INovaromaEngine engine) {
            var movie = prm as Movie;
            if (movie == null) return;

            movie.BackgroundSubtitleDownload = movie.BackgroundDownload && engine.SubtitlesNeeded(movie.Language);
        }
Beispiel #8
0
        internal static void EpisodeDownloadCheck(object prm, INovaromaEngine engine) {
            var episode = prm as TvShowEpisode;
            if (episode == null) return;

            var tvShow = episode.TvShowSeason.TvShow;
            episode.BackgroundSubtitleDownload = episode.BackgroundDownload && engine.SubtitlesNeeded(tvShow.Language);
        }
Beispiel #9
0
        internal static void AllSeasonDownloadCheck(object prm, INovaromaEngine engine) {
            var season = prm as TvShowSeason;
            if (season == null || !season.AllBackgroundDownload.HasValue) return;

            var tvShow = season.TvShow;
            season.AllBackgroundSubtitleDownload = season.AllBackgroundDownload.Value && engine.SubtitlesNeeded(tvShow.Language);
        }
Beispiel #10
0
        internal static void AllTvDownloadCheck(object prm, INovaromaEngine engine) {
            var tvShow = prm as TvShow;
            if (tvShow == null || !tvShow.AllBackgroundDownload.HasValue) return;

            tvShow.AllBackgroundSubtitleDownload = tvShow.AllBackgroundDownload.Value && engine.SubtitlesNeeded(tvShow.Language);
        }