/// <summary> /// loads the specified item into the context, setting values as declared as outputFields /// in the helper contract (defined in the Helpers.xml file) /// </summary> /// <param name="item"></param> /// <param name="listener"></param> /// <param name="context"></param> public bool LoadItem(AppHelperItem item, AppHelperContext context) { string name = item.Name; string url = (string)item.Value; //load the page to find out the url for tv.com or tvtome return false; }
public bool LoadItem(AppHelperItem item, AppHelperContext context) { XElement series = (XElement)item.Value; string seriesId = series.Element("seriesid").Value; string language = series.Element("language").Value; XElement doc = GetSeriesData(seriesId, language).Element("Series"); context["id"] = seriesId; context["lastUpdate"] = LastUpdate; context["title"] = doc.Element("SeriesName").Value; context["summary"] = doc.Element("Overview").Value; context["year"] = doc.Element("FirstAired").Value; context["length"] = doc.Element("Runtime").Value; context["genre"] = string.Join(", ", doc.Element("Genre").Value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)); context["cast"] = string.Join(", ", doc.Element("Actors").Value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)); context["rating"] = doc.Element("Rating").Value; string poster = doc.Element("poster").Value; if (!string.IsNullOrEmpty(poster)) { context["imageURL"] = string.Format("{0}/banners/{1}", MirrorInfo.BannerMirror, poster); string imageUrl = (string)context["imageURL"]; context["imageData"] = IOUtil.LoadUrl(imageUrl); } return(true); }
/// <summary> /// loads the specified item into the context, setting values as declared as outputFields /// in the helper contract (defined in the Helpers.xml file) /// </summary> /// <param name="item"></param> /// <param name="listener"></param> /// <param name="context"></param> public override bool LoadItem(AppHelperItem item, AppHelperContext context) { Trace.WriteLine("Loading: " + item.Name + " from " + item.Value); Uri uri = item.Value as Uri; // name, duration, start time, episode list url, image url string epListUrl = Regex.Replace(uri.ToString(), "(.*)/(.*?)$", "$1/episode_listings.html"); context["episodeListUrl"] = epListUrl; context["title"] = item.Name; context["URL"] = uri.ToString(); byte[] data = IOUtil.LoadUrl(uri.ToString()); string response = encoding.GetString(data); ProcessExpressions(expressions, context, new MemoryStream(data)); string summary = (string)context["summary"]; // fix up segment of html to be hopefully xhtml compliant summary = Regex.Replace(summary, "<br>", "<br/>", RegexOptions.IgnoreCase); summary = Regex.Replace(summary, "&(\\s|([^;]+\\s))", "& ", RegexOptions.IgnoreCase); summary = Regex.Replace(summary, "([^\\r]?)\\n", "$1" + Environment.NewLine); //summary = Regex.Replace(summary, "<br[^>]*>", "\n", RegexOptions.IgnoreCase); //summary = Regex.Replace(summary, "<p>", "\n\n", RegexOptions.IgnoreCase); //summary = Regex.Replace(summary, "</p>", "", RegexOptions.IgnoreCase); context["summary"] = summary.Trim(); Uri imageUri = (context["imageURL"] == null ? null : new Uri((string)context["imageURL"])); // TvShowDetails tvd = new TvShowDetails(item.Name, new Uri(epListUrl), imageUri, (string)context["duration"], DateTime.MinValue); // context["episodesAppHelper"] = tvd; return true; }
/// <summary> /// loads the specified item into the context, setting values as declared as outputFields /// in the helper contract (defined in the Helpers.xml file) /// </summary> /// <param name="item"></param> /// <param name="listener"></param> /// <param name="context"></param> public override bool LoadItem(AppHelperItem item, AppHelperContext context) { Trace.WriteLine("Loading: " + item.Name + " from " + item.Value); Uri uri = item.Value as Uri; // name, duration, start time, episode list url, image url string epListUrl = Regex.Replace(uri.ToString(), "(.*)/(.*?)$", "$1/episode_listings.html"); context["episodeListUrl"] = epListUrl; context["title"] = item.Name; context["URL"] = uri.ToString(); byte[] data = IOUtil.LoadUrl(uri.ToString()); string response = encoding.GetString(data); ProcessExpressions(expressions, context, new MemoryStream(data)); string summary = (string)context["summary"]; // fix up segment of html to be hopefully xhtml compliant summary = Regex.Replace(summary, "<br>", "<br/>", RegexOptions.IgnoreCase); summary = Regex.Replace(summary, "&(\\s|([^;]+\\s))", "& ", RegexOptions.IgnoreCase); summary = Regex.Replace(summary, "([^\\r]?)\\n", "$1" + Environment.NewLine); //summary = Regex.Replace(summary, "<br[^>]*>", "\n", RegexOptions.IgnoreCase); //summary = Regex.Replace(summary, "<p>", "\n\n", RegexOptions.IgnoreCase); //summary = Regex.Replace(summary, "</p>", "", RegexOptions.IgnoreCase); context["summary"] = summary.Trim(); Uri imageUri = (context["imageURL"] == null ? null : new Uri((string)context["imageURL"])); // TvShowDetails tvd = new TvShowDetails(item.Name, new Uri(epListUrl), imageUri, (string)context["duration"], DateTime.MinValue); // context["episodesAppHelper"] = tvd; return(true); }
public bool LoadItem(AppHelperItem item, AppHelperContext context) { XElement series = (XElement) item.Value; string seriesId = series.Element("seriesid").Value; string language = series.Element("language").Value; XElement doc = GetSeriesData(seriesId, language).Element("Series"); context["id"] = seriesId; context["lastUpdate"] = LastUpdate; context["title"] = doc.Element("SeriesName").Value; context["summary"] = doc.Element("Overview").Value; context["year"] = doc.Element("FirstAired").Value; context["length"] = doc.Element("Runtime").Value; context["genre"] = string.Join(", ", doc.Element("Genre").Value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)); context["cast"] = string.Join(", ", doc.Element("Actors").Value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)); context["rating"] = doc.Element("Rating").Value; string poster = doc.Element("poster").Value; if( ! string.IsNullOrEmpty(poster)) { context["imageURL"] = string.Format("{0}/banners/{1}", MirrorInfo.BannerMirror, poster); string imageUrl = (string) context["imageURL"]; context["imageData"] = IOUtil.LoadUrl(imageUrl); } return true; }
/// <summary> /// loads the specified item into the context, setting values as declared as outputFields /// in the helper contract (defined in the Helpers.xml file) /// </summary> /// <param name="item"></param> /// <param name="listener"></param> /// <param name="context"></param> public bool LoadItem(AppHelperItem item, AppHelperContext context) { string name = item.Name; string url = (string)item.Value; //load the page to find out the url for tv.com or tvtome return(false); }
private void appResult_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { AppHelperItem item = (AppHelperItem)((LinkLabel)sender).Tag; Console.WriteLine("got a click on item: " + item.Name + " with value: " + item.Value); //Hide(); Close(); ItemSelectedEvent(appHelper, item); }
private void AppHelperItemSelected(IAppHelper helper, AppHelperItem item) { System.Diagnostics.Debug.WriteLine(string.Format("got selected item. name: {0}. value: {1}", item.Name, item.Value)); AppHelperContext context = new SimpleAppHelperContext(); if (helper.LoadItem(item, context)) { // if (context["title"] != null) // this.txtMovieName.Text = (string)context["title"]; MediaItem.ReadFrom(context); UpdateDisplay(); } }
public bool LoadItem(AppHelperItem item, AppHelperContext context) { Item details = (Item)item.Value; // for debugging XmlSerializer ser = new XmlSerializer(typeof(Item)); StringWriter outWriter = new StringWriter(); ser.Serialize(outWriter, details); string xml = outWriter.ToString(); // end debugging context["title"] = details.ItemAttributes.Title; if (!string.IsNullOrEmpty(details.ItemAttributes.MiniMovieDescription)) { context["summary"] = details.ItemAttributes.MiniMovieDescription; } else if (details.EditorialReviews.Length > 0) { context["summary"] = details.EditorialReviews[0].Content; } if (!string.IsNullOrEmpty(details.LargeImage.URL)) { context["imageURL"] = details.LargeImage.URL; context["imageData"] = IOUtil.LoadUrl(details.LargeImage.URL); } if (details.ItemAttributes.Actor != null) { context["cast"] = string.Join(", ", details.ItemAttributes.Actor); } if (details.ItemAttributes.Director != null) { context["director"] = string.Join(", ", details.ItemAttributes.Director); } context["length"] = details.ItemAttributes.RunningTime.Value + " " + details.ItemAttributes.RunningTime.Units; DateTime relDate; if (DateTime.TryParse(details.ItemAttributes.TheatricalReleaseDate, out relDate)) { context["year"] = relDate.Year; } else { context["year"] = details.ItemAttributes.TheatricalReleaseDate; } return(true); }
public override bool LoadItem(AppHelperItem item, AppHelperContext context) { string url = string.Format("http://www.imdbapi.com/?i={0}&r=XML", item.Value); context["URL"] = url; HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url); webrequest.UserAgent = "Mozilla 6.0"; HttpWebResponse response = (HttpWebResponse)webrequest.GetResponse(); Debug("creating new request/response"); if (response.StatusCode != HttpStatusCode.OK) { Debug("invalid response code (" + response.StatusCode + ") cannot load item"); return(false); } XDocument document = XDocument.Load(response.GetResponseStream()); var movie = document.Element("root").Element("movie"); context["imageURL"] = movie.Attribute("poster").Value; context["title"] = movie.Attribute("title").Value; context["genre"] = movie.Attribute("genre").Value; context["summary"] = movie.Attribute("plot").Value; context["director"] = movie.Attribute("director").Value; context["cast"] = movie.Attribute("actors").Value; context["length"] = movie.Attribute("runtime").Value; context["rating"] = movie.Attribute("rated").Value; context["year"] = movie.Attribute("year").Value; // length rating director cast genre summary // ProcessExpressions(expressions, context, response.GetResponseStream());)))) if (context["imageURL"] != null) { string imageUrl = (string)context["imageURL"]; context["imageData"] = IOUtil.LoadUrl(imageUrl); } return(true); }
public bool LoadItem(AppHelperItem item, AppHelperContext context) { string showId = (string)item.Value; string url = string.Format("http://services.tvrage.com/myfeeds/showinfo.php?key={0}&sid={1}", key, showId); XElement doc = IOUtil.LoadXml(url).Element("Showinfo"); context["title"] = doc.Element("showname").Value; context["id"] = doc.Element("showid").Value; context["country"] = doc.Element("origin_country").Value; context["year"] = doc.Element("startdate").Value; context["length"] = doc.Element("seasons").Value + " seasons"; context["genre"] = string.Join(", ", from e in doc.Element("genres").Elements("genre") select e.Value); context["imageURL"] = doc.Element("image").Value; if (context["imageURL"] != null) { string imageUrl = (string)context["imageURL"]; context["imageData"] = IOUtil.LoadUrl(imageUrl); } return true; }
public bool LoadItem(AppHelperItem item, AppHelperContext context) { string showId = (string)item.Value; string url = string.Format("http://services.tvrage.com/myfeeds/showinfo.php?key={0}&sid={1}", key, showId); XElement doc = IOUtil.LoadXml(url).Element("Showinfo"); context["title"] = doc.Element("showname").Value; context["id"] = doc.Element("showid").Value; context["country"] = doc.Element("origin_country").Value; context["year"] = doc.Element("startdate").Value; context["length"] = doc.Element("seasons").Value + " seasons"; context["genre"] = string.Join(", ", from e in doc.Element("genres").Elements("genre") select e.Value); context["imageURL"] = doc.Element("image").Value; if (context["imageURL"] != null) { string imageUrl = (string)context["imageURL"]; context["imageData"] = IOUtil.LoadUrl(imageUrl); } return(true); }
public override bool LoadItem(AppHelperItem item, AppHelperContext context) { string url = string.Format("http://www.imdbapi.com/?i={0}&r=XML", item.Value); context["URL"] = url; HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url); webrequest.UserAgent = "Mozilla 6.0"; HttpWebResponse response = (HttpWebResponse)webrequest.GetResponse(); Debug("creating new request/response"); if (response.StatusCode != HttpStatusCode.OK) { Debug("invalid response code (" + response.StatusCode + ") cannot load item"); return false; } XDocument document = XDocument.Load(response.GetResponseStream()); var movie = document.Element("root").Element("movie"); context["imageURL"] = movie.Attribute("poster").Value; context["title"] = movie.Attribute("title").Value; context["genre"] = movie.Attribute("genre").Value; context["summary"] = movie.Attribute("plot").Value; context["director"] = movie.Attribute("director").Value; context["cast"] = movie.Attribute("actors").Value; context["length"] = movie.Attribute("runtime").Value; context["rating"] = movie.Attribute("rated").Value; context["year"] = movie.Attribute("year").Value; // length rating director cast genre summary // ProcessExpressions(expressions, context, response.GetResponseStream());)))) if (context["imageURL"] != null) { string imageUrl = (string)context["imageURL"]; context["imageData"] = IOUtil.LoadUrl(imageUrl); } return true; }
private void AppHelperItemSelected(IAppHelper helper, AppHelperItem item) { System.Diagnostics.Debug.WriteLine(string.Format("got selected item. name: {0}. value: {1}", item.Name, item.Value)); AppHelperContext context = new SimpleAppHelperContext(); if (helper.LoadItem(item, context)) { // if (context["title"] != null) // this.txtMovieName.Text = (string)context["title"]; MediaItem.ReadFrom(context); UpdateDisplay(); } }
public ItemHolder(AppHelperItem item) { this.item = item; }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <param name="context"></param> /// <returns></returns> public abstract bool LoadItem(AppHelperItem item, AppHelperContext context);
public ItemHolder(AppHelperItem item) { this.item = item; }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <param name="context"></param> /// <returns></returns> public abstract bool LoadItem(AppHelperItem item, AppHelperContext context);