private async Task Build(IMovieBuilder builder, Uri uri) { var html = await WebHttp.GetHtmlDocument(uri); var entryContent = html.DocumentNode.SelectSingleNode("//div[@class='entry entry-content']") .ThrowExceptionIfNotExists("Unable to find the movie details element"); var img = entryContent.SelectSingleNode("a[@class='entry-thumb']/img").ThrowExceptionIfNotExists("Movie thumbnail element"); var categories = entryContent.SelectNodes("a[@rel='category tag']/text()") .ThrowExceptionIfNotExists("Unable to find the categories element") .Select(li => HttpUtility.HtmlDecode(li.InnerText)); var movieInfo = builder.MovieInfo; movieInfo.LoadGenresFrom(categories); movieInfo.CoverImage = new Uri(img.GetAttributeValue("src", null)); var description = entryContent.SelectSingleNode("p").ThrowExceptionIfNotExists("Unable to find description element"); movieInfo.Description = HttpUtility.HtmlDecode(description.InnerText); foreach (var entry in html.DocumentNode.SelectNodes("//div[@class='entry-embed']/iframe") .ThrowExceptionIfNotExists("Unable to find the movie streams")) { builder.Enqueue(this, HtmlHelpers.GetEmbededUri(entry)); } }
private async Task GetMovieInfoAsync(IMovieBuilder builder, Uri uri) { var html = await WebHttp.GetHtmlDocument(uri); var coverImage = html.DocumentNode.SelectSingleNode("//div[@class='single_port']/img") .ThrowExceptionIfCoverImageNotExists() .GetAttributeValue("src", null); var descriptionInput = HttpUtility.HtmlDecode(html.DocumentNode.SelectSingleNode("//div[@class='single_entry']") .ThrowExceptionIfMovieInfoNotExists().InnerText); var movieInfo = builder.MovieInfo; using (var sr = new StringReader(descriptionInput)) { for (int i = 0; i < 3; i++) { sr.ReadLine(); } movieInfo.Description = sr.ReadToEnd(); } var regexInput = HttpUtility.HtmlDecode(html.DocumentNode.SelectSingleNode("//div[@class='single_date_box']") .ThrowExceptionIfMovieInfoNotExists().InnerText); var match = MovieInfoRegex.Match(regexInput); if (match.Success) { movieInfo.LoadGenresFrom(match.Groups[1].Value); } foreach (var video in html.DocumentNode.SelectNodes("//div[@class='block-container']/center/div/iframe") .ThrowExceptionIfNotExists("Unable to find the movie root")) { builder.Enqueue(this, HtmlHelpers.GetEmbededUri(video)); } }
public Task AddToBuilder(IMovieBuilder builder, BasicMovieInfo movie) { var movieInfo = movie as SummaryMovieInfo; if (movieInfo == null) { throw new InvalidOperationException(""); } return(GetMovieInfoAsync(builder, movie.Link)); }
public Task AddToBuilder(IMovieBuilder builder, BasicMovieInfo movie) { var movieInfo = movie as SummaryMovieInfo; if (movieInfo == null) { throw new ArgumentException(""); } return(Build(builder, movie.Link)); }
public static IMovieBuilder UseEFCoreStores(this IMovieBuilder builder, Action <DbContextOptionsBuilder> optionsAction) { builder.Services .AddInstallerStep <Migrate>() .AddDbContext <DataContext>(optionsAction) .AddDataStore <DataStore, DataContext>() .AddStore <IFilmingLocationStore, FilmingLocationStore>() .AddStore <IMovieStore, MovieStore>(); return(builder); }
private static async Task ParseMovieInfoAsync(IMovieBuilder builder, Uri uri) { var html = await WebHttp.GetHtmlDocument(uri); var movieRootElement = html.DocumentNode.SelectSingleNode("//div[@class='filmcontent']/div[@class='filmalti']") .ThrowExceptionIfNotExists("Unable to find the movie root element"); var imgElement = movieRootElement.SelectSingleNode("div[@class='filmaltiimg']/img").ThrowExceptionIfNotExists("Unable to find the 'img' tag element"); var movieDetailsElement = movieRootElement.SelectSingleNode("div[@class='filmaltiaciklama']") .ThrowExceptionIfNotExists("Unable to find the movie details element"); var categories = movieDetailsElement.SelectNodes("p[1]/a/text()") .ThrowExceptionIfNotExists("Unable to find the categories elements") .Select(li => HttpUtility.HtmlDecode(li.InnerText)); var movieInfo = new MovieInfo(new BasicMovieInfo(imgElement.GetAttributeValue("alt", null), uri)); movieInfo.CoverImage = new Uri(imgElement.GetAttributeValue("src", null)); var description = movieDetailsElement.SelectSingleNode("//p[last()]").ThrowExceptionIfNotExists("Unable to find the movie description element").InnerText; int idx = description.IndexOf(':'); if (idx > 0) { movieInfo.Description = HttpUtility.HtmlDecode(description.Substring(idx + 1).Trim()); } foreach (var embeddedMovies in html.DocumentNode.SelectNodes("//object[@type='application/x-shockwave-flash']/param[@name='flashvars']")) { var query = HttpUtility.ParseQueryString(HttpUtility.HtmlDecode(embeddedMovies.GetAttributeValue("value", null))); string captionFile = query.Get("captions.file"); var avstream = HttpUtility.UrlDecode(query.Get("streamer")); if (string.IsNullOrEmpty(captionFile) || string.IsNullOrEmpty(avstream)) { continue; } var streamSet = new MovieStream(); streamSet.Captions.Add(new Caption { Language = "Romanian", Address = captionFile }); streamSet.VideoStreams.Add(new VideoStream { AVStream = avstream }); movieInfo.Streams.Add(streamSet); } }
public void AppendTo(IMovieBuilder builder) { // TODO: here we have the URI and the builder and we should add a stream //movieBuilder.Enqueue(this, uri); }
/// <inheritdoc /> public EventSourcedMoviesController(ICommitService commitService, IMovieBuilder movieBuilder, IMapper mapper) { _commitService = commitService; _movieBuilder = movieBuilder; _mapper = mapper; }
public Task AddToBuilder(IMovieBuilder builder, BasicMovieInfo movie) { throw new NotImplementedException(); }
public void AppendTo(IMovieBuilder builder) { throw new NotImplementedException(); }
public MoviesShowingService(IMovieBuilder movieBuilder) { _jss = new JavaScriptSerializer(); _jss.RegisterConverters(new JavaScriptConverter[] { new DynamicJsonConverter() }); _movieBuilder = movieBuilder; }