Esempio n. 1
0
        public void ShouldParseEpisodeCorrectly()
        {
            SubtitleServiceResponseDeserializer subtitlesServiceResponseParser = CreateSubtitlesServiceResponseParser();
            TvShowEpisode episode = subtitlesServiceResponseParser.GetTvShowEpisode(TestResources.GetEpisodeByIdNotCached);

            Assert.AreEqual(418319, episode.episodeId);
        }
Esempio n. 2
0
        private async Task GetTvShowDetailsImpl()
        {
            if (SelectedMediaElement == null)
            {
                return;
            }

            TvShowEpisode gotEpisode = (TvShowEpisode)SelectedMediaElement;

            if (!gotEpisode.Season.TvShowEpisodes.Any())
            {
                await _tvShowService.GetEpisodesBy(gotEpisode.TvShow, gotEpisode.Season);
            }
            else
            {
                foreach (TvShowEpisode episode in gotEpisode.Season.TvShowEpisodes)
                {
                    if (SelectedSeasonEpisodes.Any(q => q.Id == episode.Id))
                    {
                        continue;
                    }

                    SelectedSeasonEpisodes.Add(episode);
                }
            }

            if (gotEpisode.PlaybackInformation == null)
            {
                gotEpisode.PlaybackInformation = await _playbackInfoService.GetPlaybackInformation(gotEpisode.Id);
            }
        }
Esempio n. 3
0
        public static void RenameEpisodeFile(TvShowEpisode episode, string template)
        {
            if (string.IsNullOrEmpty(template) || string.IsNullOrEmpty(episode.FilePath))
            {
                return;
            }
            var fileInfo = new FileInfo(episode.FilePath);

            if (!fileInfo.Exists)
            {
                return;
            }

            var season = episode.TvShowSeason;
            var tvShow = season.TvShow;

            template = Regex.Replace(template, "%showName%", tvShow.Title, RegexOptions.IgnoreCase);
            template = Regex.Replace(template, "%season%", season.Season.ToString("D2"), RegexOptions.IgnoreCase);
            template = Regex.Replace(template, "%episode%", episode.Episode.ToString("D2"), RegexOptions.IgnoreCase);
            template = Regex.Replace(template, "%episodeName%", episode.Name, RegexOptions.IgnoreCase);
            template = Regex.Replace(template, "%year%", episode.AirDate.HasValue ? episode.AirDate.Value.Year.ToString(CultureInfo.InvariantCulture) : string.Empty, RegexOptions.IgnoreCase);
            template = Regex.Replace(template, "%rating%", tvShow.Rating.ToString(), RegexOptions.IgnoreCase);
            template = Regex.Replace(template, "%genres%", string.Join(", ", tvShow.Genres.Select(g => g.Name)), RegexOptions.IgnoreCase);
            template = Regex.Replace(template, "%voteCount%", tvShow.VoteCount.ToString(), RegexOptions.IgnoreCase);
            template = Regex.Replace(template, "%runtime%", tvShow.Runtime.ToString(), RegexOptions.IgnoreCase);
            var videQuality = tvShow.VideoQuality;

            if (videQuality != VideoQuality.Any)
            {
                var videoQualityStr = videQuality == VideoQuality.P720 ? Resources.P720 : Resources.P1080;
                template = Regex.Replace(template, "%videoQuality%", videoQualityStr, RegexOptions.IgnoreCase);
            }

            episode.FilePath = RenameVideoFile(fileInfo, template);
        }
Esempio n. 4
0
        private void DownloadSubtitleForEpisode(TvShowEpisode showEpisode, string language)
        {
            List <TvShowEpisodeSubtitle> episodeSubtitles = this.showService.GetAllSubsForEpisode(showEpisode.episodeId, language);

            using (var webClient = new WebClient())
            {
                foreach (TvShowEpisodeSubtitle episodeSubtitle in episodeSubtitles)
                {
                    if (!Directory.Exists(configuration.DownloadFolder))
                    {
                        Directory.CreateDirectory(configuration.DownloadFolder);
                    }

                    string subTitlePath = Path.Combine(configuration.DownloadFolder, episodeSubtitle.fileName) + ".srt";
                    if (!File.Exists(subTitlePath))
                    {
                        webClient.DownloadFile(episodeSubtitle.downloadLink, subTitlePath);
                    }
                    else
                    {
                        logger.WriteLine("Skipping file {0}, the file was already downloaded.", episodeSubtitle.fileName);
                    }
                }
            }
        }
Esempio n. 5
0
        public static string PopulateTvShowEpisodeSearchQuery(TvShowEpisode episode, string query = Constants.DefaultTvShowEpisodeSearchPattern)
        {
            var season        = episode.TvShowSeason;
            var tvShow        = episode.TvShowSeason.TvShow;
            var extraKeywords = ((IDownloadable)episode).ExtraKeywords;

            return(PopulateTvShowEpisodeSearchQuery(query, tvShow.OriginalTitle, season.Season, episode.Episode, tvShow.ImdbId, extraKeywords));
        }
Esempio n. 6
0
        private async void DeleteTvShowEpisode(TvShowEpisode episode)
        {
            var result = await DialogService.Confirm(Resources.MontyNi, Resources.AreYouSure);

            if (!result)
            {
                return;
            }

            Novaroma.Helper.DeleteTvShowEpisode(episode, _exceptionHandler);
        }
Esempio n. 7
0
        public static string GetTvShowSeasonDirectory(string template, TvShowEpisode episode)
        {
            var season = episode.TvShowSeason;
            var show   = season.TvShow;

            if (!string.IsNullOrEmpty(template))
            {
                var seasonFolder = Regex.Replace(template, "%season%", season.Season.ToString("D2"), RegexOptions.IgnoreCase);
                return(Path.Combine(show.Directory, seasonFolder));
            }

            return(show.Directory);
        }
Esempio n. 8
0
        private async void DeleteTvShowEpisode(TvShowEpisode episode)
        {
            PinTvShowFlyout = true;

            var result = await DialogService.Confirm(Resources.MontyNi, Resources.AreYouSure);

            if (result)
            {
                Novaroma.Helper.DeleteTvShowEpisode(episode, _exceptionHandler);
            }

            PinTvShowFlyout = false;
        }
        protected async Task <MediaElementBase> GetNextMediaElement(TvShowEpisode episode)
        {
            var episodes = episode.Season.TvShowEpisodes.OrderBy(q => q.IndexNumber).ToList();

            int epNumber = 0;

            for (; epNumber < episode.Season.TvShowEpisodes.Count; epNumber++)
            {
                TvShowEpisode episodeCheck = episode.Season.TvShowEpisodes[epNumber];
                if (episode.Id == episodeCheck.Id)
                {
                    break;
                }
            }

            if (epNumber == episodes.Count)
            {
                var season  = episode.Season;
                var seasons = episode.TvShow.Seasons;

                int seasonNumber = 0;
                for (; seasonNumber < episode.TvShow.Seasons.Count; seasonNumber++)
                {
                    TvShowSeason seasonCheck = episode.TvShow.Seasons[seasonNumber];
                    if (season.Id == seasonCheck.Id)
                    {
                        break;
                    }
                }

                if (seasonNumber == seasons.Count)
                {
                    return(null);
                }

                var             nextSeason         = seasons[seasonNumber + 1];
                IUnityContainer container          = Globals.Instance.Container;
                var             tvShowService      = container.Resolve <ITvShowService>();
                var             nextSeasonEpisodes = await tvShowService.GetEpisodesBy(episode.TvShow, nextSeason);

                return(nextSeasonEpisodes.FirstOrDefault());
            }

            return(episodes[epNumber + 1]);
        }
Esempio n. 10
0
 private void DownloadSubtitleForEpisode(TvShowEpisode tvShowEpisode, string pathToStoreSubtitle, string language)
 {
     List<TvShowEpisodeSubtitle> episodeSubtitles = subtitleService.GetAllSubsForEpisode(tvShowEpisode.episodeId, language);
      using (WebClient webClient = new WebClient())
      {
     foreach (TvShowEpisodeSubtitle tvShowEpisodeSubtitle in episodeSubtitles)
     {
        string subTitlePath = Path.Combine(pathToStoreSubtitle, tvShowEpisodeSubtitle.fileName) + ".srt";
        if (!File.Exists(subTitlePath))
        {
           webClient.DownloadFile(tvShowEpisodeSubtitle.downloadLink, subTitlePath);
        }
        else
        {
           Console.WriteLine("Skipping file {0}, the file was already downloaded.", tvShowEpisodeSubtitle.fileName);
        }
     }
      }
 }
Esempio n. 11
0
        public static void DeleteTvShowEpisode(TvShowEpisode episode, IExceptionHandler exceptionHandler)
        {
            try {
                var fileInfo = new FileInfo(episode.FilePath);

                var subtitleFilePath = GetSubtitleFilePath(fileInfo);
                if (!string.IsNullOrEmpty(subtitleFilePath))
                {
                    DeleteFile(subtitleFilePath);
                }

                DeleteFile(fileInfo);

                episode.FilePath           = string.Empty;
                episode.SubtitleDownloaded = false;
            }
            catch (Exception ex) {
                exceptionHandler.HandleException(ex);
            }
        }
Esempio n. 12
0
 private static bool CanDeleteTvShowEpisode(TvShowEpisode episode)
 {
     return(episode != null && !string.IsNullOrEmpty(episode.FilePath) && File.Exists(episode.FilePath));
 }
Esempio n. 13
0
 private async Task DownloadTvShowEpisodeSubtitle(TvShowEpisode tvShowEpisode)
 {
     await Helper.ManualSubtitleDownload(_engine, _exceptionHandler, DialogService, tvShowEpisode);
 }
Esempio n. 14
0
 private static void PlayTvShowEpisode(TvShowEpisode episode)
 {
     Process.Start(episode.FilePath);
 }
Esempio n. 15
0
        public static Task ManualDownload(INovaromaEngine engine, IExceptionHandler exceptionHandler, IDialogService dialogService, TvShowEpisode episode)
        {
            var downloadable = (IDownloadable)episode;
            var directory    = Novaroma.Helper.GetTvShowSeasonDirectory(engine.TvShowSeasonDirectoryTemplate, episode);

            return(ManualDownload(engine, exceptionHandler, dialogService, episode, downloadable.GetSearchQuery(),
                                  downloadable.VideoQuality, downloadable.ExcludeKeywords, downloadable.MinSize, downloadable.MaxSize, directory));
        }
Esempio n. 16
0
 public void TvShowEpisodeSubtitleDownloaded(TvShowEpisode episode)
 {
     MkvPackage(episode);
 }
Esempio n. 17
0
 public void TvShowEpisodeDownloaded(TvShowEpisode episode)
 {
 }
Esempio n. 18
0
 private static bool CanPlayTvShowEpisode(TvShowEpisode episode)
 {
     return(episode != null && !string.IsNullOrWhiteSpace(episode.FilePath) && File.Exists(episode.FilePath));
 }
Esempio n. 19
0
 public TvShowEpisodeDownloadCompletedEventArgs(TvShowEpisode tvShowEpisode)
 {
     _tvShowEpisode = tvShowEpisode;
 }