public async Task <IEnumerable <SearchResult> > SearchAsync(string searchText) { if (string.IsNullOrEmpty(searchText)) { return(null); } var result = new List <SearchResult>(); // Encode the search text... var encodedSearchText = WebStringHelper.UrlEncodeSpecialCharacters(searchText); // Search movie characters (aka persons) ... result = (await _personRepo.SearchAsync(searchText)).ToList(); // Search movies... var movieResult = (await _movieRepo.SearchAsync(searchText)).ToList(); if (movieResult.Count > 0) { result.AddRange(movieResult); } // Search movie companies... var companyResult = (await _companyRepo.SearchAsync(searchText)).ToList(); if (companyResult.Count > 0) { result.AddRange(companyResult); } // Order search result by name... result = result.OrderBy(x => x.Name).ToList(); return(result); }
private IEnumerable <MovieTrailer> GetMovieTrailers(Stream stream) { var rss = XDocument.Load(stream); try { if (rss.Root == null) { return(null); } var doc = XDocument.Parse(rss.Root.Value); var query = doc.Descendants("slide").Select(slide => { var titleElement = slide.Element("title"); var textElement = slide.Element("text"); var linkElement = slide.Element("link"); var mediaElement = slide.Element("media"); var firstFrameElement = slide.Element("firstframe"); if (firstFrameElement == null) { return(null); } if (titleElement == null) { titleElement = new XElement("", ""); } if (textElement == null) { textElement = new XElement("", ""); } if (linkElement == null) { linkElement = new XElement("", ""); } if (mediaElement == null) { mediaElement = new XElement("", ""); } return(new MovieTrailer { Title = titleElement.Value, Comment = textElement.Value, ImageUrl = WebStringHelper.UrlEncode(firstFrameElement.Value), MovieUrl = WebStringHelper.UrlEncode(linkElement.Value), VideoUrl = WebStringHelper.UrlEncode(mediaElement.Value) }); }); return(query); } catch (Exception ex) { Debug.WriteLine($"GetMovieTrailers() failed with exception:\n{ex.Message}"); } return(null); }
/// <summary> /// Handles the Error event of the Instance control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.IO.ErrorEventArgs"/> instance containing the event data.</param> private void Instance_Error(object sender, ErrorEventArgs e) { _messages.Add(WebStringHelper.EncodeForWebString(e.Message)); ErrorMessages.DataSource = _messages; ErrorMessages.DataBind(); Visible = _messages != null && _messages.Count > 0; }
protected string GetDisplayName(NodeContent content) { if (content == null) { return(string.Empty); } return(WebStringHelper.EncodeForWebString(content.DisplayName ?? content.Name)); }
/// <summary> /// Gets the display name. /// </summary> /// <param name="node">The node.</param> /// <returns>The display name of the node</returns> public static string GetDisplayName(this CatalogNode node) { if (node == null || node.ItemAttributes == null) { return(string.Empty); } return(WebStringHelper.EncodeForWebString((node.ItemAttributes["DisplayName"] != null && !string.IsNullOrEmpty(node.ItemAttributes["DisplayName"].ToString())) ? node.ItemAttributes["DisplayName"].ToString() : node.Name)); }
protected string GetDisplayName(NodeContent content, bool toUpper) { if (content == null) { return(string.Empty); } var displayName = content.DisplayName ?? content.Name; if (!toUpper) { return(WebStringHelper.EncodeForWebString(displayName)); } return(WebStringHelper.EncodeForWebString(displayName.ToUpper())); }
public async Task <PersonInfo> GetInfoAsync(int id) { // Prepare the url... var personInfoUrl = PERSON_INFO_ENDPOINT.Replace("{id}", id.ToString()); // Get the data... var personInfo = await GetAsync <PersonInfo>(personInfoUrl); // Trim text data... if (personInfo != null) { personInfo.Description = !string.IsNullOrEmpty(personInfo.Description) ? WebStringHelper.StripHtml(personInfo.Description) : string.Empty; } // Return the result. return(personInfo); }
public async Task <CompanyInfo> GetInfoAsync(int id) { // Prepare the url... var companyInfoUrl = COMPANY_INFO_STRING.Replace("{id}", id.ToString()); // Get the data... var companyInfo = await GetAsync <CompanyInfo>(companyInfoUrl); // Trim text data... if (companyInfo != null) { companyInfo.Description = !string.IsNullOrEmpty(companyInfo.Description) ? WebStringHelper.StripHtml(companyInfo.Description) : string.Empty; companyInfo.ImagesUrl = $"https://api.dfi.dk/v1/images/{companyInfo.Id}"; } // Return the result. return(companyInfo); }
public async Task <MovieInfo> GetInfoAsync(int id) { // Prepare the url... var movieInfoUrl = MOVIE_INFO_STRING.Replace("{id}", id.ToString()); // Get the data... var movieInfo = await GetAsync <MovieInfo>(movieInfoUrl, enableContentCorrection : true); // Trim text data... if (movieInfo != null) { movieInfo.PremiereInfo = movieInfo.Premiere?.FirstOrDefault(x => x.PremiereType == "bp"); movieInfo.Description = !string.IsNullOrEmpty(movieInfo.Description) ? WebStringHelper.StripHtml(movieInfo.Description) : string.Empty; movieInfo.Comment = !string.IsNullOrEmpty(movieInfo.Comment) ? WebStringHelper.StripHtml(movieInfo.Comment) : string.Empty; } // Return the result. return(movieInfo); }
public override IEnumerable <MovieNews> GetMovieNews(Stream stream) { var result = new List <MovieNews>(); XDocument rss; try { rss = XDocument.Load(stream); // Danish news } catch (Exception ex) { Debug.WriteLine($"Unable to load news rss source!\nException:\n{ex.Message}"); return(result); } try { var query = rss.Descendants("item").Select(item => { // // Get raw element data... // var enclosureElement = item.Element("enclosure"); var titleElement = item.Element("title"); var descriptionElement = item.Element("description"); var publicationDateElement = item.Element("pubDate"); var linkElement = item.Element("link"); var authorElement = item.Element("author"); // // Validate element data... // if (titleElement == null) { return(null); } if (descriptionElement == null) { descriptionElement = new XElement("", ""); } if (publicationDateElement == null) { publicationDateElement = new XElement("", ""); } if (linkElement == null) { linkElement = new XElement("", ""); } if (authorElement == null) { authorElement = new XElement("", ""); } var urlAttribute = enclosureElement != null ? enclosureElement.Attribute("url") : new XAttribute("", ""); // // Prepare publication date using default if none exists... // DateTime publicationDate; if (!DateTime.TryParse(publicationDateElement.Value, out publicationDate)) { publicationDate = DateTime.UtcNow - new TimeSpan(300, 0, 0, 0); } // // Return a news object for Dfi... // var content = WebStringHelper .RemovePrefixFromText( "<!--50-->", descriptionElement.Value); content = WebStringHelper .RemoveSuffixFromText( "<br>", content); return(enclosureElement != null ? new MovieNews { Headline = titleElement.Value, Content = content, ImageUrl = urlAttribute != null ? urlAttribute.Value : "", PublicationDate = publicationDate, StoryUrl = linkElement.Value, Author = authorElement.Value, Source = MovieNewsProviderType.Dfi.ToString().ToUpper() } : new MovieNews { Headline = "n/a" }); }); return(query); } catch (Exception ex) { Debug.WriteLine($"Unable to parse news rss source!\nException:\n{ex.Message}"); return(result); } }
public override IEnumerable <MovieNews> GetMovieNews(Stream stream) { XDocument rss; try { rss = XDocument.Load(stream); // Danish news } catch (Exception) { return(null); } XNamespace dcNs = "http://purl.org/dc/elements/1.1/"; XNamespace contentNs = "http://purl.org/rss/1.0/modules/content/"; try { var query = rss.Descendants("item").Select(item => { // // Get raw element data... // var titleElement = item.Element("title"); var descriptionElement = item.Element(contentNs + "encoded"); var linkElement = item.Element("link"); var publicationDateElement = item.Element("pubDate"); var authorElement = item.Element(dcNs + "creator"); // // Validate element data... // if (titleElement == null) { return(null); } if (descriptionElement == null) { descriptionElement = new XElement("", ""); } if (linkElement == null) { linkElement = new XElement("", ""); } if (publicationDateElement == null) { publicationDateElement = new XElement("", ""); } if (authorElement == null) { authorElement = new XElement("", ""); } // // Prepare publication date using default if none exists... // DateTime publicationDate; if (!DateTime.TryParse(publicationDateElement.Value, out publicationDate)) { publicationDate = DateTime.UtcNow - new TimeSpan(300, 0, 0, 0); // Default is 300 days ago. } // // Prepare content with some special parsing to strip title from content... // var content = WebStringHelper.StripHtml(descriptionElement.Value); content = WebStringHelper.RemoveTag(content, titleElement.Value, "Film-nyt.dk.", true); // // Return a news object for FilmNyt... // return(new MovieNews { Headline = titleElement.Value, Content = content, ImageUrl = "filmnyt.png", PublicationDate = publicationDate, StoryUrl = linkElement.Value, Author = authorElement.Value, Source = MovieNewsProviderType.FilmNyt.ToString().ToUpper() }); }).Take(20); return(query); } catch (Exception) { return(null); } }
public override IEnumerable <MovieNews> GetMovieNews(Stream stream) { XDocument rss; try { rss = XDocument.Load(stream); // Danish news } catch (Exception) { return(null); } XNamespace media = "http://search.yahoo.com/mrss/"; try { var query = rss.Descendants("item").Select(item => { // // Get raw element data... // var titleElement = item.Element("title"); var descriptionElement = item.Element("description"); var linkElement = item.Element("link"); var publicationDateElement = item.Element("pubDate"); var enclosureElement = item.Element(media + "thumbnail"); // // Validate element data... // if (titleElement == null) { return(null); } if (descriptionElement == null) { descriptionElement = new XElement("", ""); } if (linkElement == null) { linkElement = new XElement("", ""); } if (publicationDateElement == null) { publicationDateElement = new XElement("", ""); } var urlAttribute = enclosureElement != null ? enclosureElement.Attribute("url") : new XAttribute("", ""); // // Prepare publication date using default if none exists... // DateTime publicationDate; if (!DateTime.TryParse(publicationDateElement.Value, out publicationDate)) { publicationDate = DateTime.UtcNow - new TimeSpan(300, 0, 0, 0); } // // Return a news object for Filmz... // return(new MovieNews { Headline = titleElement.Value, Content = WebStringHelper.StripHtml(descriptionElement.Value), ImageUrl = urlAttribute.Value, PublicationDate = publicationDate, StoryUrl = linkElement.Value, Author = "Filmz.dk", Source = MovieNewsProviderType.Filmz.ToString().ToUpper() }); }).Take(20); return(query); } catch (Exception) { return(null); } }
public override IEnumerable <MovieNews> GetMovieNews(Stream stream) { const string baseUrl = "http://www.nordiskfilm.com"; XDocument rss; try { rss = XDocument.Load(stream); // Danish news } catch (Exception) { return(null); } try { var query = rss.Descendants("item").Select(item => { // // Get raw element data... // var titleElement = item.Element("title"); var descriptionElement = item.Element("description"); var linkElement = item.Element("link"); // // Validate element data... // if (titleElement == null) { return(null); } if (descriptionElement == null) { descriptionElement = new XElement("", ""); } if (linkElement == null) { linkElement = new XElement("", ""); } var content = WebStringHelper .StripHtml(descriptionElement.Value); var imageUrl = WebStringHelper .RemovePrefixFromText( "<img src=\"", descriptionElement.Value); if (imageUrl == descriptionElement.Value) { imageUrl = string.Empty; } imageUrl = WebStringHelper .RemoveSuffixFromText( "\" alt=", imageUrl); imageUrl = string.IsNullOrEmpty(imageUrl) ? string.Empty : baseUrl + imageUrl; // // Return a news object for Nordisk Film... // return(new MovieNews { Headline = titleElement.Value, Content = content, ImageUrl = string.IsNullOrEmpty(imageUrl) ? "nordisk.png" : imageUrl, PublicationDate = DateTime.UtcNow - new TimeSpan(300, 0, 0, 0), StoryUrl = linkElement.Value, Author = "Nordisk Film", Source = MovieNewsProviderType.Nordisk.ToString().ToUpper() }); }).Take(20); return(query); } catch (Exception) { //Console.WriteLine(e.Message); return(null); } }