public static string getNameOfTvEpisode(int idSerie, int SeasonNumber, int EpisodeNumber) { // TvEpisode MyEpisode = client.GetTvEpisodeAsync(getIDofSerie(SerieName), SeasonNumber, EpisodeNumber, language: "fr_FR").Result; TvEpisode MyEpisode = client.GetTvEpisodeAsync(idSerie, SeasonNumber, EpisodeNumber, language: "fr_FR").Result; return(MyEpisode.Name); }
public static TvEpisode Defaults(this TvEpisode result) { result.SeasonNumber = Helpers.InvalidSeasonNumber; result.EpisodeNumber = Helpers.InvalidEpisodeNumber; return(result); }
public EpisodeEditorWindow(TvEpisode episode) { InitializeComponent(); viewModel = new EpisodeEditorWindowViewModel(episode); viewModel.ResultsSet += vm_ResultsSet; this.DataContext = viewModel; }
/// <summary> /// Permet de créer un nouveau ShowModel. /// </summary> /// <param name="serie"></param> /// <returns></returns> private async Task <ShowModel> CreateNewShowModel(ShowInformation serie) { ShowModel showModel = new ShowModel(); var temp = await ClientTmDb.SearchTvShowAsync(serie.Titre); await Task.Delay(500); if (temp.Results.Count > 0) { var tempSerieTrouve = temp.Results[0]; // Récupération des informations de TmDb. TvShow tvShow = await ClientTmDb.GetTvShowAsync(tempSerieTrouve.Id); await Task.Delay(500); TvSeason saison = await ClientTmDb.GetTvSeasonAsync(tempSerieTrouve.Id, serie.Saison); await Task.Delay(500); TvEpisode episode = await ClientTmDb.GetTvEpisodeAsync(tempSerieTrouve.Id, serie.Saison, serie.Episode); showModel.TvShow = tvShow; showModel.TvSeasons.Add(saison); showModel.TvEpisodes.Add(episode); showModel.ShowInformation.Add(serie); } return(showModel); }
private void RemoveEpisodes() { if (this.show == null) { return; } string didNotRemove = ""; for (int i = this.SelectedEpisodes.Count - 1; i >= 0; i--) { TvEpisode ep = (this.SelectedEpisodes[i] as TvEpisode); if (ep.UserDefined) { this.show.Episodes.Remove(ep); } else { ep.Ignored = true; didNotRemove += Environment.NewLine + "\t" + ep.ToString(); } } if (!string.IsNullOrEmpty(didNotRemove)) { MessageBox.Show("Only custom added episodes can be removed. The following episode are defined in the online database, so were set to ignored instead:" + didNotRemove); } Organization.Shows.Save(); }
/// <summary> /// Convert a <see cref="TvEpisode"/> into a <see cref="Episode"/>. /// </summary> /// <param name="episode">The episode to convert.</param> /// <param name="showID">The ID of the show inside TheMovieDb.</param> /// <param name="provider">The provider representing TheMovieDb.</param> /// <returns>The converted episode as a <see cref="Episode"/>.</returns> public static Episode ToEpisode(this TvEpisode episode, int showID, Provider provider) { return(new Episode { SeasonNumber = episode.SeasonNumber, EpisodeNumber = episode.EpisodeNumber, Title = episode.Name, Overview = episode.Overview, ReleaseDate = episode.AirDate, Images = new Dictionary <int, string> { [Images.Thumbnail] = episode.StillPath != null ? $"https://image.tmdb.org/t/p/original{episode.StillPath}" : null }, ExternalIDs = new[] { new MetadataID { Provider = provider, Link = $"https://www.themoviedb.org/tv/{showID}" + $"/season/{episode.SeasonNumber}/episode/{episode.EpisodeNumber}", DataID = episode.Id.ToString() } } }); }
private async Task GetSeasonAndEpisodeInformation(Guid idShow, ShowInformation serieLocal) { // Si la saison est connu. if (_serieCollection.HaveSeason(idShow, serieLocal.Saison)) { // Si Episode est non connu. if (!_serieCollection.HaveEpisode(idShow, serieLocal.Saison, serieLocal.Episode)) { int idSerie = _serieCollection.GetIdSerieTmDb(idShow); TvEpisode episode = await ClientTmDb.GetTvEpisodeAsync(idSerie, serieLocal.Saison, serieLocal.Episode); lock (_objetToLock) { _serieCollection.AddEpisode(idShow, episode, serieLocal); } } } else { // Cas ou il ne connait pas la saison. int idSerie = _serieCollection.GetIdSerieTmDb(idShow); TvSeason saison = await ClientTmDb.GetTvSeasonAsync(idSerie, serieLocal.Saison); await Task.Delay(500); TvEpisode episode = await ClientTmDb.GetTvEpisodeAsync(idSerie, serieLocal.Saison, serieLocal.Episode); lock (_objetToLock) { _serieCollection.AddSaison(idShow, saison, episode, serieLocal); } } }
private void TestBreakingBadSeasonOneEpisodeOneBaseProperties(TvEpisode tvEpisode) { Assert.AreEqual(62085, tvEpisode.Id); Assert.AreEqual(new DateTime(2008, 1, 19), tvEpisode.AirDate.Date); Assert.AreEqual(1, tvEpisode.EpisodeNumber); Assert.AreEqual("Pilot", tvEpisode.Name); Assert.IsNotNull(tvEpisode.Overview); Assert.IsNull(tvEpisode.ProductionCode); Assert.AreEqual(1, tvEpisode.SeasonNumber); Assert.IsNotNull(tvEpisode.StillPath); Assert.IsNotNull(tvEpisode.Crew); Crew crew = tvEpisode.Crew.SingleOrDefault(s => s.CreditId == "52542275760ee313280006ce"); Assert.IsNotNull(crew); Assert.AreEqual(66633, crew.Id); Assert.AreEqual("52542275760ee313280006ce", crew.CreditId); Assert.AreEqual("Vince Gilligan", crew.Name); Assert.AreEqual("Writing", crew.Department); Assert.AreEqual("Writer", crew.Job); Assert.AreEqual("/rLSUjr725ez1cK7SKVxC9udO03Y.jpg", crew.ProfilePath); Assert.IsNotNull(tvEpisode.GuestStars); Cast star = tvEpisode.GuestStars.SingleOrDefault(s => s.CreditId == "52542273760ee3132800068e"); Assert.IsNotNull(star); Assert.AreEqual(92495, star.Id); Assert.AreEqual("John Koyama", star.Name); Assert.AreEqual("52542273760ee3132800068e", star.CreditId); Assert.AreEqual("Emilio Koyama", star.Character); Assert.AreEqual(1, star.Order); Assert.AreEqual("/uh4g85qbQGZZ0HH6IQI9fM9VUGS.jpg", star.ProfilePath); }
public void ProcessFile() { _log = new LoggerConfiguration() .WriteTo.File($"logs\\{DateTime.UtcNow.ToString("yyyyMMdd-HHmm")}-{_inputVideoFileName}.log") .WriteTo.Console() .CreateLogger(); _attributes = GetAttributes(); _log.Information("Media attributes:{@attributes}", _attributes); _metadata = GetMetadata(); _log.Information("Media tags:{@metadata}", _metadata.Text); _episode = new TvEpisode() .Defaults() .FromFileName(_inputVideoFileName) .FromJsonMetadata(_metadata) .FromMediaCenterAttributes(_attributes) .FromDescription() .FixTitleAndShowName() .MapShowName(_appContext.ShowNameMap) .SetSafeShowName().Log(_log, "Episode"); _outputFileName = _episode.GetOutputFileName(); _log.Information("Output file name:\"{OutputFileName}\"", _outputFileName); var outputFile = GetOutputFile(_inputVideoFileExtension); _log.Information("Output file:\"{OutputFile}\"", outputFile); if (File.Exists(outputFile) == false) { _log.Information("Copying input file \"{Input}\" to \"{Output}\"", _inputVideoFile, outputFile); if (_appContext.WhatIf == false) { if (_appContext.CreateSymbolicLink) { NativeHelpers.CreateSymbolicFileLink(_inputVideoFile, outputFile); } else { File.Copy(_inputVideoFile, outputFile); } _log.Information("Finished copying input file \"{Input}\" to \"{Output}\"", _inputVideoFile, outputFile); } var thumbnailFile = GetOutputFile(".jpg"); if (TryCreateThumbnailFile(thumbnailFile)) { _episode.ThumbnailFile = thumbnailFile; } NfoFileHandler(); } else { _log.Information("Not processing input file because the output file already exists"); } }
public void TestTvEpisodeGetTvEpisodeWithImageLanguage() { IgnoreMissingJson(" / account_states", " / alternative_titles", " / changes", " / credits", " / content_ratings", " / genre_ids", "images / id", " / keywords", " / lists", " / release_dates", " / releases", " / reviews", " / show_id", " / similar", " / translations", " / videos", " / recommendations", " / external_ids"); TvEpisode resp = Config.Client.GetTvEpisodeAsync(IdHelper.BreakingBad, 1, 1, language: "en-US", includeImageLanguage: "en", extraMethods: TvEpisodeMethods.Images).Result; Assert.True(resp.Images.Stills.Count > 0); }
public void TestTvSeasonExtrasAll() { TvEpisodeMethods combinedEnum = _methods.Keys.Aggregate((methods, tvEpisodeMethods) => methods | tvEpisodeMethods); TvEpisode tvEpisode = _config.Client.GetTvEpisode(BreakingBad, 1, 1, combinedEnum); TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode); TestMethodsHelper.TestAllNotNull(_methods, tvEpisode); }
/// <summary> /// Ajoute un épisode à la série donnée par l'id. /// </summary> /// <param name="idShow"></param> /// <param name="episode"></param> /// <param name="serieLocal"></param> public void AddEpisode(Guid idShow, TvEpisode episode, ShowInformation serieLocal) { ShowModel showModel = GetShowModel(idShow); showModel.TvEpisodes.Add(episode); showModel.ShowInformation.Add(serieLocal); AddNouveaute(showModel.TvSeasons.Where(x => x.SeasonNumber == episode.SeasonNumber).First(), episode); }
private async Task RefreshEpisode(TMDbClient client, EpisodeSql episodeSql, int showId) { TvEpisode tvEpisode = await client.GetTvEpisodeAsync(showId, episodeSql.Season.SeasonNumber, episodeSql.EpisodeNumber, TvEpisodeMethods.ExternalIds, "fr-FR").ConfigureAwait(false); if (tvEpisode != null) { episodeSql.Update(client.Config, tvEpisode); } }
/// <summary> /// Ajoute la saison et un épisode à la série donnée par l'id. /// </summary> /// <param name="idShow"></param> /// <param name="saison"></param> /// <param name="episode"></param> /// <param name="serieLocal"></param> public void AddSaison(Guid idShow, TvSeason saison, TvEpisode episode, ShowInformation serieLocal) { ShowModel showModel = GetShowModel(idShow); showModel.TvSeasons.Add(saison); showModel.TvEpisodes.Add(episode); showModel.ShowInformation.Add(serieLocal); AddNouveaute(saison, episode); }
public void MatchingEpisodesCopiedToDestinationFolder() { var files = new[] { "DownloadFolder\\The.Walking.Dead.S05E12.720p.HDTV.x264-KILLERS.mp4" }; var source = new Mock <IDirectory>(); source.Setup(s => s.EnumerateFiles("*", true)).Returns(files); source.SetupGet(s => s.Path).Returns("DownloadFolder"); var destination = new Mock <IDirectory>(); destination.SetupGet(s => s.Path).Returns("TvLibFolder"); var seriesDestinationFolder = new Mock <IDirectory>(); seriesDestinationFolder.Setup(sdf => sdf.EnumerateFiles(It.IsAny <string>(), It.IsAny <bool>())).Returns(Enumerable.Empty <string>()); seriesDestinationFolder.Setup(sdf => sdf.Exists()).Returns(true); var episodeFile = new Mock <IFile>(); episodeFile.Setup(ef => ef.Extension).Returns(".mp4"); episodeFile.Setup(ef => ef.DirectoryName).Returns("DownloadFolder"); var fileSystemFactory = GetFileSystemFactory(source, destination, seriesDestinationFolder, "DownloadFolder\\The.Walking.Dead.S05E12.720p.HDTV.x264-KILLERS.mp4", episodeFile); var episode = new TvEpisode() { Season = 5, EpisodeNumber = 12, Title = "Some Title", SeriesName = "The Walking Dead" }; var tvService = new Mock <ITvService>(); tvService.Setup(ts => ts.GetEpisodeBySeriesName(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), true)) .Returns(episode); var analyticService = new Mock <IAnalyticsService>(); var processor = new EpisodeProcessor(_settings, tvService.Object, fileSystemFactory.Object, analyticService.Object); processor.ProcessDownloadedEpisodes(); source.Verify(s => s.EnumerateFiles(It.IsAny <string>(), true), Times.AtLeastOnce); seriesDestinationFolder.Verify(sdf => sdf.Exists(), Times.Once); //Validate Source File was copied episodeFile.Verify(ef => ef.Copy(It.IsAny <string>()), Times.Once); //Validate Episode was updated in database tvService.Verify(c => c.SaveChanges(), Times.Once); episodeFile.Verify(ef => ef.Delete(), Times.Once); }
public string BuildSearchQuery(TvEpisode episode) { var query = $"{episode.SeriesName} s{episode.Season:D2}e{episode.EpisodeNumber:D2} 720".ToLower(); _logger.Debug($"Search Query before stripping characters {query}"); query = new Regex("[^a-zA-Z0-9 -]").Replace(query, ""); _logger.Debug($"Search Query after stripping characters {query}"); return(query); }
public string BuildSearchQuery(TvEpisode episode) { var query = $"{episode.SeriesName} s{episode.Season:D2}e{episode.EpisodeNumber:D2} 720".ToLower(); _logger.Debug($"Search Query before stripping characters {query}"); query = new Regex("[^a-zA-Z0-9 -]").Replace(query, ""); _logger.Debug($"Search Query after stripping characters {query}"); return query; }
private void TestBreakingBadSeasonOneEpisodeOneBaseProperties(TvEpisode tvEpisode) { Assert.AreEqual(62085, tvEpisode.Id); Assert.AreEqual("2008-01-20", tvEpisode.AirDate.ToString("yyyy-MM-dd")); Assert.AreEqual(1, tvEpisode.EpisodeNumber); Assert.AreEqual("Pilot", tvEpisode.Name); Assert.IsNotNull(tvEpisode.Overview); Assert.IsNull(tvEpisode.ProductionCode); Assert.AreEqual(1, tvEpisode.SeasonNumber); Assert.IsNotNull(tvEpisode.StillPath); }
private void TestBreakingBadSeasonOneEpisodeOneBaseProperties(TvEpisode tvEpisode) { Assert.AreEqual(62085, tvEpisode.Id); Assert.AreEqual(new DateTime(2008, 1, 19), tvEpisode.AirDate.Date); Assert.AreEqual(1, tvEpisode.EpisodeNumber); Assert.AreEqual("Pilot", tvEpisode.Name); Assert.IsNotNull(tvEpisode.Overview); Assert.IsNull(tvEpisode.ProductionCode); Assert.AreEqual(1, tvEpisode.SeasonNumber); Assert.IsNotNull(tvEpisode.StillPath); }
public static void Update(this EpisodeSql episodeBdd, TMDbConfig config, TvEpisode item) { episodeBdd.PosterUrl = config.Images.SecureBaseUrl + "w300" + item.StillPath; episodeBdd.Name = item.Name; episodeBdd.AirDate = item.AirDate; if (item.ExternalIds != null) { episodeBdd.Providers[ProviderSql.Imdb] = item.ExternalIds.ImdbId; } }
public void TestTvEpisodeExtrasNone() { TvEpisode tvEpisode = _config.Client.GetTvEpisode(BreakingBad, 1, 1); TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode); // Test all extras, ensure none of them are populated foreach (Func <TvEpisode, object> selector in _methods.Values) { Assert.IsNull(selector(tvEpisode)); } }
public async Task TestTvEpisodeExtrasNoneAsync() { TvEpisode tvEpisode = await TMDbClient.GetTvEpisodeAsync(IdHelper.BreakingBad, 1, 1); await Verify(tvEpisode); // Test all extras, ensure none of them are populated foreach (Func <TvEpisode, object> selector in Methods.Values) { Assert.Null(selector(tvEpisode)); } }
public void GetEpisodeBySeriesName_ReturnsEpisode() { var episode = new TvEpisode() { Season = 5, EpisodeNumber = 12, Title = "Some Title" }; var series = new TvSeries() { Name = "The Walking Dead" }; series.Episodes.Add(episode); var episodeQueryable = new List <TvEpisode> { episode }.AsQueryable(); var seriesList = new List <TvSeries> { series }; var seriesSet = new Mock <MockableDbSetWithExtensions <TvSeries> >(); seriesSet.Setup(ss => ss.SqlQuery(It.IsAny <string>(), It.IsAny <object[]>())) .Returns <string, object[]>((sql, param) => { var sqlQueryMock = new Mock <DbSqlQuery <TvSeries> >(); sqlQueryMock.Setup(m => m.AsNoTracking()) .Returns(sqlQueryMock.Object); sqlQueryMock.Setup(m => m.GetEnumerator()) .Returns(seriesList.GetEnumerator()); return(sqlQueryMock.Object); }); var episodeSet = new Mock <MockableDbSetWithExtensions <TvEpisode> >(); episodeSet.As <IQueryable <TvEpisode> >().Setup(m => m.Provider).Returns(episodeQueryable.Provider); episodeSet.As <IQueryable <TvEpisode> >().Setup(m => m.Expression).Returns(episodeQueryable.Expression); episodeSet.As <IQueryable <TvEpisode> >().Setup(m => m.ElementType).Returns(episodeQueryable.ElementType); episodeSet.As <IQueryable <TvEpisode> >().Setup(m => m.GetEnumerator()).Returns(episodeQueryable.GetEnumerator()); var context = new Mock <ITvContext>(); context.Setup(c => c.Set <TvSeries>()).Returns(seriesSet.Object); context.Setup(c => c.TvEpisodes).Returns(episodeSet.Object); var tvService = new TvService(context.Object); var result = tvService.GetEpisodeBySeriesName("The Walking Dead", 5, 12, false); Assert.That(result, Is.Not.Null); Assert.That(result.Title, Is.EqualTo("Some Title")); }
public void TestTvEpisodeExtrasAll() { TvEpisodeMethods combinedEnum = _methods.Keys.Aggregate((methods, tvEpisodeMethods) => methods | tvEpisodeMethods); TvEpisode tvEpisode = _config.Client.GetTvEpisode(BreakingBad, 1, 1, combinedEnum); TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode); Assert.IsNotNull(tvEpisode.Images); Assert.IsNotNull(tvEpisode.Images.Stills); Assert.IsTrue(tvEpisode.Images.Stills.Count > 0); TestMethodsHelper.TestAllNotNull(_methods, tvEpisode); }
private void EditEpisode() { TvEpisode ep = this.SelectedEpisodes[0] as TvEpisode; EpisodeEditorWindow editor = new EpisodeEditorWindow(ep); editor.ShowDialog(); if (editor.Results != null) { ep.Clone(editor.Results); Organization.Shows.Save(); } }
private bool FilterEpisode(object obj) { TvEpisode ep = obj as TvEpisode; if (this.SelectedEpisodeFilter != null) { if (!this.SelectedEpisodeFilter.FilterEpisode(ep)) { return(false); } } return(true); }
public void TestTvEpisodeExtrasNone() { // We will intentionally ignore errors reg. missing JSON as we do not request it IgnoreMissingJson(" / account_states", " / credits", " / external_ids", " / images", " / videos"); TvEpisode tvEpisode = Config.Client.GetTvEpisodeAsync(IdHelper.BreakingBad, 1, 1).Result; TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode); // Test all extras, ensure none of them are populated foreach (Func <TvEpisode, object> selector in _methods.Values) { Assert.Null(selector(tvEpisode)); } }
public bool DestinationFileExists(TvEpisode episode) { var seriesDestinationFolderPath = $"{_destinationFolder.Path}\\{episode.SeriesName}\\Season {episode.Season:D2}\\"; var seriesDestinationFolder = _fileSystem.GetDirectory(seriesDestinationFolderPath); if (!seriesDestinationFolder.Exists()) { return(false); } var episodeSearchPattern = $"S{episode.Season:D2}E{episode.EpisodeNumber:D2}*"; var files = seriesDestinationFolder.EnumerateFiles(episodeSearchPattern, false); return(files.Any()); }
public void MatchingEpisodesCopiedToDestinationFolder() { var files = new[] { "DownloadFolder\\The.Walking.Dead.S05E12.720p.HDTV.x264-KILLERS.mp4" }; var source = new Mock<IDirectory>(); source.Setup(s => s.EnumerateFiles("*", true)).Returns(files); source.SetupGet(s => s.Path).Returns("DownloadFolder"); var destination = new Mock<IDirectory>(); destination.SetupGet(s => s.Path).Returns("TvLibFolder"); var seriesDestinationFolder = new Mock<IDirectory>(); seriesDestinationFolder.Setup(sdf => sdf.EnumerateFiles(It.IsAny<string>(), It.IsAny<bool>())).Returns(Enumerable.Empty<string>()); seriesDestinationFolder.Setup(sdf => sdf.Exists()).Returns(true); var episodeFile = new Mock<IFile>(); episodeFile.Setup(ef => ef.Extension).Returns(".mp4"); episodeFile.Setup(ef => ef.DirectoryName).Returns("DownloadFolder"); var fileSystemFactory = GetFileSystemFactory(source, destination, seriesDestinationFolder, "DownloadFolder\\The.Walking.Dead.S05E12.720p.HDTV.x264-KILLERS.mp4", episodeFile); var episode = new TvEpisode() {Season = 5, EpisodeNumber = 12, Title = "Some Title", SeriesName = "The Walking Dead"}; var tvService = new Mock<ITvService>(); tvService.Setup(ts => ts.GetEpisodeBySeriesName(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>(), true)) .Returns(episode); var analyticService = new Mock<IAnalyticsService>(); var processor = new EpisodeProcessor(_settings, tvService.Object, fileSystemFactory.Object, analyticService.Object); processor.ProcessDownloadedEpisodes(); source.Verify(s => s.EnumerateFiles(It.IsAny<string>(), true), Times.AtLeastOnce); seriesDestinationFolder.Verify(sdf => sdf.Exists(), Times.Once); //Validate Source File was copied episodeFile.Verify(ef => ef.Copy(It.IsAny<string>()), Times.Once); //Validate Episode was updated in database tvService.Verify(c => c.SaveChanges(), Times.Once); episodeFile.Verify(ef => ef.Delete(), Times.Once); }
public void HandleDoubleClick() { if (this.SelectedEpisodes == null || this.SelectedEpisodes.Count != 1) { return; } TvEpisode ep = this.SelectedEpisodes[0] as TvEpisode; if (ep.Missing == MissingStatus.Missing) { GetTorrent(); } else { PlayEpisode(); } }
public void TestTvEpisodeExtrasAll() { _config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession); // Account states will only show up if we've done something _config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Wait(); TvEpisodeMethods combinedEnum = _methods.Keys.Aggregate((methods, tvEpisodeMethods) => methods | tvEpisodeMethods); TvEpisode tvEpisode = _config.Client.GetTvEpisodeAsync(IdHelper.BreakingBad, 1, 1, combinedEnum).Result; TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode); Assert.IsNotNull(tvEpisode.Images); Assert.IsNotNull(tvEpisode.Images.Stills); Assert.IsTrue(tvEpisode.Images.Stills.Count > 0); TestMethodsHelper.TestAllNotNull(_methods, tvEpisode); }
public async Task TestTvEpisodeExtrasAccountState() { // Test the custom parsing code for Account State rating await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession); TvEpisode episode = await TMDbClient.GetTvEpisodeAsync(IdHelper.BigBangTheory, 1, 1, TvEpisodeMethods.AccountStates); if (episode.AccountStates == null || !episode.AccountStates.Rating.HasValue) { await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 5); // Allow TMDb to update cache await Task.Delay(2000); episode = await TMDbClient.GetTvEpisodeAsync(IdHelper.BigBangTheory, 1, 1, TvEpisodeMethods.AccountStates); } await Verify(episode); }
/// <summary> /// Loads instance from XML. /// </summary> /// <param name="itemNode">Node to load XML from</param> /// <returns>true if sucessfully loaded from XML</returns> public bool Load(XmlNode seasonNode) { if (seasonNode.Name != ROOT_XML) return false; foreach (XmlNode propNode in seasonNode.ChildNodes) { XmlElements element = XmlElements.Number; if (!Enum.TryParse<XmlElements>(propNode.Name, out element)) continue; string value = propNode.InnerText; switch (element) { case XmlElements.Number: int number; if (int.TryParse(value, out number)) this.Number = number; break; case XmlElements.Episodes: this.Episodes = new List<TvEpisode>(); foreach(XmlNode epNode in propNode.ChildNodes) { TvEpisode episode = new TvEpisode(); episode.Load(epNode); Episodes.Add(episode); } Episodes.Sort(); break; } } return true; }
public void AddOrUpdate(TvEpisode episode) { _context.TvEpisodes.AddOrUpdate(e => e.Id, episode); }
public bool DestinationFileExists(TvEpisode episode) { var seriesDestinationFolderPath = $"{_destinationFolder.Path}\\{episode.SeriesName}\\Season {episode.Season:D2}\\"; var seriesDestinationFolder = _fileSystem.GetDirectory(seriesDestinationFolderPath); if (!seriesDestinationFolder.Exists()) return false; var episodeSearchPattern = $"S{episode.Season:D2}E{episode.EpisodeNumber:D2}*"; var files = seriesDestinationFolder.EnumerateFiles(episodeSearchPattern, false); return files.Any(); }
public TvSeries GetTvSeries(string id) { var url = $"http://thetvdb.com/api/{_TvDbApiKey}/series/{id}/all/en.zip"; var temporaryFilePath = Path.GetTempFileName(); TvSeries tvSeries = null; var client = new System.Net.WebClient(); client.DownloadFile(url, temporaryFilePath); if (!File.Exists(temporaryFilePath)) return tvSeries; var extractFolder = temporaryFilePath + "_extract\\"; ZipFile.ExtractToDirectory(temporaryFilePath, extractFolder); var xmlDoc = new XmlDocument(); xmlDoc.Load(extractFolder + "en.xml"); var seriesNode = xmlDoc.SelectSingleNode("Data/Series"); var overview = seriesNode["Overview"]?.InnerText ?? string.Empty; tvSeries = new TvSeries() { TvDbSeriesId = seriesNode["id"].InnerText, Name = seriesNode["SeriesName"].InnerText, FirstAired = Convert.ToDateTime(seriesNode["FirstAired"].InnerText), Status = seriesNode["Status"].InnerText, Summary = overview, AirsTimeOfDay = seriesNode["Airs_Time"]?.InnerText ?? string.Empty, Network = seriesNode["Network"]?.InnerText ?? string.Empty, Rating = seriesNode["ContentRating"]?.InnerText ?? string.Empty, }; if (seriesNode["Airs_DayOfWeek"] != null) { DayOfWeek airDate; Enum.TryParse<DayOfWeek>(seriesNode["Airs_DayOfWeek"].InnerText, out airDate); tvSeries.AirsDayOfWeek = airDate; } tvSeries.LastUpdated = seriesNode["LastUpdated"] != null ? Convert.ToInt64(seriesNode["LastUpdated"]?.InnerText).FromEpochTime() : DateTime.Now; if (seriesNode["Genre"] != null) tvSeries.Genres = GetGenres(seriesNode["Genre"].InnerText); var episodeNodes = xmlDoc.SelectNodes("Data/Episode"); if (episodeNodes != null) { foreach (XmlNode node in episodeNodes) { if (string.IsNullOrEmpty(node["FirstAired"]?.InnerText)) continue; var episode = new TvEpisode(); episode.EpisodeNumber = Convert.ToInt32(node["EpisodeNumber"].InnerText); episode.Season = Convert.ToInt32(node["SeasonNumber"].InnerText); episode.Title = node["EpisodeName"].InnerText; episode.FirstAired = Convert.ToDateTime(node["FirstAired"].InnerText); //TODO Make initial download status configurable episode.DownloadStatus = "WANT"; overview = node["Overview"]?.InnerText ?? string.Empty; episode.Summary = overview; tvSeries.Episodes.Add(episode); } } File.Delete(temporaryFilePath); Directory.Delete(extractFolder, recursive: true); return tvSeries; }