/// <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> /// locates the items (ie: performs a search) using the data in the context. the context /// will (possibly) contain data in fields declared as inputFields in the helper contract /// </summary> /// <param name="context"></param> /// <returns></returns> public override AppHelperItem[] LocateItems(AppHelperContext context) { string url = BuildSearchUrl(context); Debug("requesting URL: " + url); var request = WebRequest.Create(url); request.Proxy = WebRequest.GetSystemWebProxy(); request.Proxy.Credentials = CredentialCache.DefaultCredentials; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Debug("response URI: " + response.ResponseUri); Debug("response status code: " + response.StatusCode); Debug("content type: " + response.ContentType); AppHelperItem[] items; if (response.StatusCode == HttpStatusCode.OK) { items = ProcessSearchResponse(response.GetResponseStream()); } else { // something strange happened... items = new ImdbAppHelperItem[0]; } response.Close(); return items; }
/// <summary> /// locates the items (ie: performs a search) using the data in the context. the context /// will (possibly) contain data in fields declared as inputFields in the helper contract /// </summary> /// <param name="context"></param> /// <returns></returns> public override AppHelperItem[] LocateItems(AppHelperContext context) { string url = BuildSearchUrl(context); Debug("requesting URL: " + url); var request = WebRequest.Create(url); request.Proxy = WebRequest.GetSystemWebProxy(); request.Proxy.Credentials = CredentialCache.DefaultCredentials; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Debug("response URI: " + response.ResponseUri); Debug("response status code: " + response.StatusCode); Debug("content type: " + response.ContentType); AppHelperItem[] items; if (response.StatusCode == HttpStatusCode.OK) { items = ProcessSearchResponse(response.GetResponseStream()); } else { // something strange happened... items = new ImdbAppHelperItem[0]; } response.Close(); return(items); }
/// <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> /// /// </summary> /// <param name="expressions"></param> /// <param name="context"></param> /// <param name="instream"></param> protected void ProcessExpressions( List<RegexMatcher> expressions, AppHelperContext context, Stream instream ) { StreamReader sr = new StreamReader(instream); string line; StringBuilder allLines = new StringBuilder(); while ((line = sr.ReadLine()) != null) { line = line.Replace("\r\n", "\n"); allLines.Append(line).Append("\n"); foreach (RegexMatcher matcher in expressions) { if (! (matcher is EntireStreamRegexMatcher) && matcher.IsMatch(line)) { Debug("got a match: " + matcher.ToString()); matcher.AssignToContext(context); } } } string allLinesStr = allLines.ToString(); foreach (RegexMatcher matcher in expressions) { if (matcher is EntireStreamRegexMatcher && matcher.IsMatch(allLinesStr)) { Debug("got a match: " + matcher.ToString()); matcher.AssignToContext(context); } } sr.Close(); }
/// <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> /// locates the items (ie: performs a search) using the data in the context. the context /// will (possibly) contain data in fields declared as inputFields in the helper contract /// </summary> public AppHelperItem[] LocateItems(AppHelperContext context) { string url = string.Format("{0}{1}", EPGUIDES_SEARCH_URL, HttpUtility.HtmlEncode((string)context["title"])); byte[] data = IOUtil.LoadUrl(url); string response = encoding.GetString(data); // TODO: could possibly refactor this out into a google result matcher Regex regex = new Regex(@"<a class=l href=""([^\""]+)""[^>]*>(.*?)\s*</a>", RegexOptions.Singleline | RegexOptions.IgnoreCase); List <AppHelperItem> items = new List <AppHelperItem>(); foreach (Match m in regex.Matches(response)) { string name = m.Groups[2].Value; name = name.Replace("<b>", ""); name = name.Replace("</b>", ""); if (name.Contains("(a Titles and Air Dates Guide)")) { name = name.Replace("(a Titles and Air Dates Guide)", ""); items.Add(new SimpleAppHelperItem { Name = name, Value = m.Groups[1].Value }); } } return(items.ToArray()); }
/// <summary> /// /// </summary> /// <param name="expressions"></param> /// <param name="context"></param> /// <param name="instream"></param> protected void ProcessExpressions(List <RegexMatcher> expressions, AppHelperContext context, Stream instream) { StreamReader sr = new StreamReader(instream); string line; StringBuilder allLines = new StringBuilder(); while ((line = sr.ReadLine()) != null) { line = line.Replace("\r\n", "\n"); allLines.Append(line).Append("\n"); foreach (RegexMatcher matcher in expressions) { if (!(matcher is EntireStreamRegexMatcher) && matcher.IsMatch(line)) { Debug("got a match: " + matcher.ToString()); matcher.AssignToContext(context); } } } string allLinesStr = allLines.ToString(); foreach (RegexMatcher matcher in expressions) { if (matcher is EntireStreamRegexMatcher && matcher.IsMatch(allLinesStr)) { Debug("got a match: " + matcher.ToString()); matcher.AssignToContext(context); } } sr.Close(); }
/// <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 AppHelperItem[] LocateItems(AppHelperContext context) { string url = string.Format("http://www.thetvdb.com/api/GetSeries.php?seriesname={0}",context["title"]); XElement results = IOUtil.LoadXml(url).Element("Data"); return (from series in results.Elements("Series") let title = series.Element("SeriesName").Value select new SimpleAppHelperItem {Name = title, Value = series}).ToArray(); }
/// <summary> /// locates the items (ie: performs a search) using the data in the context. the context /// will (possibly) contain data in fields declared as inputFields in the helper contract /// </summary> public override AppHelperItem[] LocateItems(AppHelperContext context) { string name = (string)context["title"]; Uri baseUri = new Uri(SEARCH_URI); string url = baseUri + "?type=11&stype=program&x=0&y=0&qs=" + HttpUtility.HtmlEncode(name); byte[] data = IOUtil.LoadUrl(url); string response = encoding.GetString(data); return(parseItems(baseUri, response)); }
public AppHelperItem[] LocateItems(AppHelperContext context) { string url = string.Format("http://www.thetvdb.com/api/GetSeries.php?seriesname={0}", context["title"]); XElement results = IOUtil.LoadXml(url).Element("Data"); return((from series in results.Elements("Series") let title = series.Element("SeriesName").Value select new SimpleAppHelperItem { Name = title, Value = series }).ToArray()); }
public AppHelperItem[] LocateItems(AppHelperContext context) { string url = string.Format("http://services.tvrage.com/myfeeds/search.php?key={0}&show={1}", key, context["title"]); XDocument doc = IOUtil.LoadXml(url); List<AppHelperItem> items = new List<AppHelperItem>(); foreach(var showElement in doc.Element("Results").Elements("show")) { items.Add(new SimpleAppHelperItem { Name = showElement.Element("name").Value, Value = showElement.Element("showid").Value }); } return items.ToArray(); }
/// <summary> /// constructs the search url based on the information in the context /// object that we can use to effect the search /// </summary> /// <param name="context"></param> /// <returns></returns> private static string BuildSearchUrl(AppHelperContext context) { string extra = null; string year = (string)context["year"]; if (!string.IsNullOrEmpty(year)) { extra = string.Format("&y={0}", year); } string theTitle = ((string)context["title"]).Replace(" ", "+"); return(string.Format("http://www.imdbapi.com/?t={0}&r=XML{1}", theTitle, extra ?? "")); }
public AppHelperItem[] LocateItems(AppHelperContext context) { string url = string.Format("http://services.tvrage.com/myfeeds/search.php?key={0}&show={1}", key, context["title"]); XDocument doc = IOUtil.LoadXml(url); List <AppHelperItem> items = new List <AppHelperItem>(); foreach (var showElement in doc.Element("Results").Elements("show")) { items.Add(new SimpleAppHelperItem { Name = showElement.Element("name").Value, Value = showElement.Element("showid").Value }); } return(items.ToArray()); }
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 virtual void ReadFrom(AppHelperContext context) { /* foreach (object obj in context.GetEnumerator()) * { * if (entry.Key.StartsWith("Meta")) * { * MetaData[entry.Key.ToString()] = entry.Value; * } * }*/ foreach (object obj in Components.Values) { if (obj is IAppHelperAware) { ((IAppHelperAware)obj).ReadFrom(context); } } }
/// <summary> /// /// </summary> /// <param name="context"></param> public virtual void ReadFrom(AppHelperContext context) { if (context["year"] != null) { try { this.Date = DateTime.Parse(context["year"].ToString()); } catch { try { int year = int.Parse(context["year"].ToString()); this.Date = new DateTime(year, 1, 1); } catch { this.Date = DateTime.MinValue; } } } this.Genre = (string)context["genre"]; this.Description = (string)context["summary"]; this.Title = (string)context["title"]; this.Country = (string)context["country"]; this.Length = (string)context["length"]; this.Rating = (string)context["rating"]; this.Director = (string)context["director"]; this.Cast = (string)context["cast"]; if (context["imageURL"] != null) { System.Net.WebClient client = new System.Net.WebClient( ); this.Image = Image.FromStream(client.OpenRead(new Uri((string)context["imageURL"]))); } else { this.Image = null; } }
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; }
/// <summary> /// /// </summary> /// <param name="context"></param> public virtual void ReadFrom(AppHelperContext context) { if( context["year"] != null ) { try { this.Date = DateTime.Parse(context["year"].ToString()); } catch { try { int year = int.Parse(context["year"].ToString()); this.Date = new DateTime(year, 1, 1); } catch { this.Date = DateTime.MinValue; } } } this.Genre = (string)context["genre"]; this.Description = (string)context["summary"]; this.Title = (string)context["title"]; this.Country = (string)context["country"]; this.Length = (string)context["length"]; this.Rating = (string)context["rating"]; this.Director = (string)context["director"]; this.Cast = (string)context["cast"]; if (context["imageURL"] != null) { System.Net.WebClient client = new System.Net.WebClient( ); this.Image = Image.FromStream(client.OpenRead(new Uri((string)context["imageURL"]))); } else this.Image = null; }
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 AppHelperItem[] LocateItems(AppHelperContext context) { // prepare an ItemSearch request ItemSearchRequest request = new ItemSearchRequest(); request.SearchIndex = "DVD"; request.Keywords = (string)context["title"]; request.ResponseGroup = new[] { "ItemAttributes", "EditorialReview", "Images" }; var response = DoSearch(request); var item = response.Items[0]; if (item.Request.Errors != null && item.Request.Errors.Length > 0) { // TODO: log error messages? return(new AppHelperItem[0]); } return(item.Item.Select(x => new AmazonAppHelperItem() { Name = x.ItemAttributes.Title, Value = x }).Cast <AppHelperItem>().ToArray()); }
/// <summary> /// locates the items (ie: performs a search) using the data in the context. the context /// will (possibly) contain data in fields declared as inputFields in the helper contract /// </summary> public AppHelperItem[] LocateItems(AppHelperContext context) { string url = string.Format("{0}{1}", EPGUIDES_SEARCH_URL, HttpUtility.HtmlEncode((string)context["title"])); byte[] data = IOUtil.LoadUrl(url); string response = encoding.GetString(data); // TODO: could possibly refactor this out into a google result matcher Regex regex = new Regex(@"<a class=l href=""([^\""]+)""[^>]*>(.*?)\s*</a>", RegexOptions.Singleline | RegexOptions.IgnoreCase); List<AppHelperItem> items = new List<AppHelperItem>(); foreach (Match m in regex.Matches(response)) { string name = m.Groups[2].Value; name = name.Replace("<b>", ""); name = name.Replace("</b>", ""); if (name.Contains("(a Titles and Air Dates Guide)")) { name = name.Replace("(a Titles and Air Dates Guide)", ""); items.Add(new SimpleAppHelperItem {Name = name, Value = m.Groups[1].Value}); } } return items.ToArray(); }
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; }
/// <summary> /// locates the items (ie: performs a search) using the data in the context. the context /// will (possibly) contain data in fields declared as inputFields in the helper contract /// </summary> public override AppHelperItem[] LocateItems(AppHelperContext context) { string name = (string)context["title"]; Uri baseUri = new Uri(SEARCH_URI); string url = baseUri + "?type=11&stype=program&x=0&y=0&qs=" + HttpUtility.HtmlEncode(name); byte[] data = IOUtil.LoadUrl(url); string response = encoding.GetString(data); return parseItems(baseUri, response); }
/// <summary> /// constructs the search url based on the information in the context /// object that we can use to effect the search /// </summary> /// <param name="context"></param> /// <returns></returns> private static string BuildSearchUrl(AppHelperContext context) { string extra = null; string year = (string)context["year"]; if (!string.IsNullOrEmpty(year)) { extra = string.Format("&y={0}", year); } string theTitle = ((string)context["title"]).Replace(" ", "+"); return string.Format("http://www.imdbapi.com/?t={0}&r=XML{1}", theTitle, extra ?? ""); }
private void drpHelperNames_SelectedIndexChanged(object sender, EventArgs e) { if (drpHelperNames.SelectedItem == null) { return; } string appHelperName = (string)drpHelperNames.SelectedItem; context = factory.GetAppHelperContext(appHelperName); /* * tblInputContext.Controls.Clear(); * // tblInputContext.ColumnCount = 2; * tblInputContext.RowCount = context.InputFields.Length; * int row = 0; * foreach (string fieldname in context.InputFields) * { * System.Diagnostics.Debug.WriteLine("received input field: " + fieldname); * Label l = new Label(); * l.Anchor = AnchorStyles.Top | AnchorStyles.Left; * l.Text = fieldname; * TextBox textField = new TextBox(); * textField.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; * tblInputContext.Controls.Add(l, 0, row); * tblInputContext.Controls.Add(textField, 1, row); * row++; * }*/ tblInputContext.SuspendLayout(); tblInputContext.Controls.Clear(); tblInputContext.ColumnCount = 2; this.tblInputContext.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tblInputContext.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); tblInputContext.RowCount = context.InputFields.Length; for (int i = 0; i < tblInputContext.RowCount; i++) { this.tblInputContext.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 28F)); } int row = 0; foreach (string fieldname in context.InputFields) { System.Diagnostics.Debug.WriteLine("received input field: " + fieldname); Label label = new Label(); //label.Size = new Size((int)(fieldname.Length * 8.5), 14); label.AutoSize = true; label.Anchor = AnchorStyles.Left; label.Text = fieldname; TextBox textField = new TextBox(); //textField.Size = new System.Drawing.Size(249, 20); textField.Anchor = AnchorStyles.Left | AnchorStyles.Right; tblInputContext.Controls.Add(label, 0, row); tblInputContext.Controls.Add(textField, 1, row); row++; } tblInputContext.ResumeLayout(); tblOutputContext.SuspendLayout(); tblOutputContext.Controls.Clear(); tblOutputContext.ColumnCount = 2; this.tblOutputContext.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(SizeType.AutoSize)); this.tblOutputContext.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); tblOutputContext.RowCount = context.OutputFields.Length; for (int i = 0; i < tblOutputContext.RowCount; i++) { this.tblOutputContext.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 28F)); } row = 0; foreach (string fieldname in context.OutputFields) { System.Diagnostics.Debug.WriteLine("received output field: " + fieldname); Label l = new Label(); l.AutoSize = true; l.Anchor = AnchorStyles.Left; l.Text = fieldname; TextBox textField = new TextBox(); textField.Anchor = AnchorStyles.Left | AnchorStyles.Right; tblOutputContext.Controls.Add(l, 0, row); tblOutputContext.Controls.Add(textField, 1, row); row++; } tblOutputContext.ResumeLayout(); }
private void drpHelperNames_SelectedIndexChanged(object sender, EventArgs e) { if (drpHelperNames.SelectedItem == null) { return; } string appHelperName = (string)drpHelperNames.SelectedItem; context = factory.GetAppHelperContext(appHelperName); /* tblInputContext.Controls.Clear(); // tblInputContext.ColumnCount = 2; tblInputContext.RowCount = context.InputFields.Length; int row = 0; foreach (string fieldname in context.InputFields) { System.Diagnostics.Debug.WriteLine("received input field: " + fieldname); Label l = new Label(); l.Anchor = AnchorStyles.Top | AnchorStyles.Left; l.Text = fieldname; TextBox textField = new TextBox(); textField.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; tblInputContext.Controls.Add(l, 0, row); tblInputContext.Controls.Add(textField, 1, row); row++; }*/ tblInputContext.SuspendLayout(); tblInputContext.Controls.Clear(); tblInputContext.ColumnCount = 2; this.tblInputContext.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tblInputContext.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); tblInputContext.RowCount = context.InputFields.Length; for (int i = 0; i < tblInputContext.RowCount; i++) { this.tblInputContext.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 28F)); } int row = 0; foreach (string fieldname in context.InputFields) { System.Diagnostics.Debug.WriteLine("received input field: " + fieldname); Label label = new Label(); //label.Size = new Size((int)(fieldname.Length * 8.5), 14); label.AutoSize = true; label.Anchor = AnchorStyles.Left; label.Text = fieldname; TextBox textField = new TextBox(); //textField.Size = new System.Drawing.Size(249, 20); textField.Anchor = AnchorStyles.Left | AnchorStyles.Right; tblInputContext.Controls.Add(label, 0, row); tblInputContext.Controls.Add(textField, 1, row); row++; } tblInputContext.ResumeLayout(); tblOutputContext.SuspendLayout(); tblOutputContext.Controls.Clear(); tblOutputContext.ColumnCount = 2; this.tblOutputContext.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(SizeType.AutoSize)); this.tblOutputContext.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); tblOutputContext.RowCount = context.OutputFields.Length; for (int i = 0; i < tblOutputContext.RowCount; i++) { this.tblOutputContext.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 28F)); } row = 0; foreach (string fieldname in context.OutputFields) { System.Diagnostics.Debug.WriteLine("received output field: " + fieldname); Label l = new Label(); l.AutoSize = true; l.Anchor = AnchorStyles.Left; l.Text = fieldname; TextBox textField = new TextBox(); textField.Anchor = AnchorStyles.Left | AnchorStyles.Right; tblOutputContext.Controls.Add(l, 0, row); tblOutputContext.Controls.Add(textField, 1, row); row++; } tblOutputContext.ResumeLayout(); }
public override void ReadFrom(AppHelperContext context) { base.ReadFrom(context); SummaryUrl = (string)context["URL"]; EpisodeListUrl = (string)context["episodeListUrl"]; }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <param name="context"></param> /// <returns></returns> public abstract bool LoadItem(AppHelperItem item, AppHelperContext context);
public virtual void ReadFrom(AppHelperContext context) { /* foreach (object obj in context.GetEnumerator()) { if (entry.Key.StartsWith("Meta")) { MetaData[entry.Key.ToString()] = entry.Value; } }*/ foreach (object obj in Components.Values) { if (obj is IAppHelperAware) ((IAppHelperAware)obj).ReadFrom(context); } }
public virtual void AssignToContext(AppHelperContext context) { context[ContextName] = Value; }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <returns></returns> public abstract AppHelperItem[] LocateItems(AppHelperContext context);