public async Task<string> Transform(string url) { var match = Regex.Match(url, "twitgoo.com/([A-Za-z0-9]*)"); if (!match.Success) return null; var twitgooID = match.Groups[1].Value; var fetcher = new AsyncWebFetcher(); var text = await fetcher.FetchAsync("http://twitgoo.com/api/message/info/" + twitgooID); var xdoc = new XmlDocument(); xdoc.LoadXml(text); try { var selectSingleNode = xdoc.SelectSingleNode("/rsp/imageurl"); if (selectSingleNode != null) { var r = selectSingleNode.InnerText; return r; } } catch (Exception ex) { CompositionManager.Get<IExceptionReporter>().ReportHandledException(ex); } return null; }
public async Task<string> Process(string url) { if (url == null) return null; string url2 = url; if (url.ToLower().Contains(_flickrshorturl)) { var urlizer = new AsyncWebFetcher(); string longlong = await urlizer.FetchAsync(url); if (longlong == null) return null; Match match2 = Regex.Match(longlong, _flickrfindlonginshort); if (!match2.Success) return null; url2 = match2.Groups["realurl"].Value; } string iid = FindImageID(url2); string getImageInfoUrl = String.Format(_flickrgetphotoid, _apikey, iid); var fetcher = new AsyncWebFetcher(); string flickrdata = await fetcher.FetchAsync(getImageInfoUrl); if (flickrdata == null) return null; var xdoc = new XmlDocument(); if (xdoc == null) return null; xdoc.LoadXml(flickrdata); XmlNode photo = xdoc.SelectSingleNode("/rsp/photo"); if (photo == null) return null; return photo.Attributes == null ? null : String.Format(_flickrimagestaticurl, photo.Attributes["farm"].InnerText, photo.Attributes["server"].InnerText, iid, photo.Attributes["secret"].InnerText); }
public async Task<string> Transform(string url) { var match = Regex.Match(url, "yfrog.com/([A-Za-z0-9]*)"); if (match.Success) { var yfrogId = match.Groups[1].Value; var fetcher = new AsyncWebFetcher(); var text = await fetcher.FetchAsync("http://yfrog.com/api/xmlInfo?path=" + yfrogId); var xdoc = new XmlDocument(); try { xdoc.LoadXml(text); var xnm = new XmlNamespaceManager(xdoc.NameTable); xnm.AddNamespace("is", "http://ns.imageshack.us/imginfo/7/"); var selectSingleNode = xdoc.SelectSingleNode("/is:imginfo/is:links/is:image_link", xnm); if (selectSingleNode != null) { var r = selectSingleNode.InnerText; return r; } } catch(Exception ex) { CompositionManager.Get<IExceptionReporter>().ReportHandledException(ex); } } return null; }
public async Task<string> Transform(string url) { Match match = Regex.Match(url, "yfrog.com/([A-Za-z0-9]*)"); if (match.Success) { string yfrogId = match.Groups[1].Value; var _fetcher = new AsyncWebFetcher(); string text = await _fetcher.FetchAsync("http://yfrog.com/api/xmlInfo?path=" + yfrogId); var xdoc = new XmlDocument(); xdoc.LoadXml(text); var xnm = new XmlNamespaceManager(xdoc.NameTable); xnm.AddNamespace("is", "http://ns.imageshack.us/imginfo/7/"); XmlNode selectSingleNode = xdoc.SelectSingleNode("/is:imginfo/is:links/is:image_link", xnm); if (selectSingleNode != null) { string r = selectSingleNode.InnerText; return r; } return null; } return null; }
public async Task<string> Transform(string url) { var fetcher = new AsyncWebFetcher(); var imgly = await fetcher.FetchAsync(url); if (imgly == null) return null; var match = Regex.Match(imgly, _matcher); return match.Success ? match.Groups[1].Value : null; }
public async Task<string> Transform(string url) { var _fetcher = new AsyncWebFetcher(); var dbooth = await _fetcher.FetchAsync(url); var matchPicture = Regex.Match(dbooth, @"<img src=\x22(http:\/\/[a-zA-Z0-9\._\'\/\-\?\=\#\&\%]*)\x22"); return matchPicture.Success ? "http://" + matchPicture.Groups[1].Value : null; }
public async Task<string> Transform(string url) { var _fetcher = new AsyncWebFetcher(); string smugmug = await _fetcher.FetchAsync(url); if (smugmug == null) return null; //Find the image uri via regex Match match = Regex.Match(smugmug, _matcher); return match.Success ? match.Groups[1].Value : null; }
public async Task<string> Transform(string url) { var _fetcher = new AsyncWebFetcher(); string lb = await _fetcher.FetchAsync(url); if (lb == null) return null; Match matchPicture = Regex.Match(lb, _matcher); return matchPicture.Success ? "http://" + matchPicture.Groups[1].Value : null; }
public async Task<string> Transform(string url) { var fetcher = new AsyncWebFetcher(); var lockerz = await fetcher.FetchAsync(url); if (lockerz == null) return null; var matchPicture = Regex.Match(lockerz, @"<img id=\x22photo\x22 src=\x22(http:\/\/[a-zA-Z0-9\._\'\/\-\?\=\#\&\%]*)\x22"); return matchPicture.Success ? matchPicture.Groups[1].Value : null; }
public async Task<string> Transform(string url) { var _fetcher = new AsyncWebFetcher(); var instagram = await _fetcher.FetchAsync(url); if (instagram == null) return null; var matchPicture = Regex.Match(instagram, @"<img.*class=\x22photo\x22.*src=\x22(http:\/\/[a-zA-Z0-9\._\'\/\-\?\=\#\&\%]*)\x22"); return matchPicture.Success ? matchPicture.Groups[1].Value : null; }
public async Task<string> Transform(string url) { var _fetcher = new AsyncWebFetcher(); string picplz = await _fetcher.FetchAsync(url); if (picplz == null) return null; Match matchPicture = Regex.Match(picplz, @"<img id=\x22mainImage\x22 src=\x22(http:\/\/[a-zA-Z0-9\._\'\/\-\?\=\#\&\%]*)\x22"); return matchPicture.Success ? "http://" + matchPicture.Groups[1].Value : null; }
public async Task<string> Transform(string url) { //Fetch the Twitpic page var _fetcher = new AsyncWebFetcher(); string cameraplus = await _fetcher.FetchAsync(url); if (cameraplus == null) return null; //Find the image uri via regex Match match = Regex.Match(cameraplus, @"<img*.src=\x22(?<imagesrc>http:\/\/[a-zA-Z0-9\._\'\/\-\?\=\#\&\%]*)\x22 class=\x22photo\x22"); return match.Success ? match.Groups["imagesrc"].Value : null; }
public async Task<string> Process(String url) { var fetcher = new AsyncWebFetcher(); var page = await fetcher.FetchAsync(url); if (page == null) return null; var titleRegex = new Regex(@"<h1.*>(?<title>.*)<\/h1>", RegexOptions.IgnoreCase); var match = titleRegex.Match(page); if (!match.Success) return null; var title = WebUtility.HtmlDecode(match.Groups["title"].Value); return title; }
public async Task<string> Process(String url) { var _fetcher = new AsyncWebFetcher(); string page = await _fetcher.FetchAsync(url); if (page == null) return null; var titleRegex = new Regex(@"<meta name=\x22title\x22 content=\x22(?<title>.*)\x22>", RegexOptions.IgnoreCase); Match match = titleRegex.Match(page); if (!match.Success) return null; string title = WebUtility.HtmlDecode(match.Groups["title"].Value); return title; }
public async Task<string> Process(String url) { var fetcher = new AsyncWebFetcher(); var page = await fetcher.FetchAsync(url); if (page == null) return null; var titleRegex = new Regex(@"<title>(?<title>.*)<\/title>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); var match = titleRegex.Match(page); if (!match.Success) return null; var title = WebUtility.HtmlDecode(match.Groups["title"].Value.Replace(Environment.NewLine, "")); return title; }
public async Task<string> Transform(string url) { Match match = Regex.Match(url, "twitgoo.com/([A-Za-z0-9]*)"); if (!match.Success) return null; string twitgooID = match.Groups[1].Value; var _fetcher = new AsyncWebFetcher(); string text = await _fetcher.FetchAsync("http://twitgoo.com/api/message/info/" + twitgooID); var xdoc = new XmlDocument(); xdoc.LoadXml(text); XmlNode selectSingleNode = xdoc.SelectSingleNode("/rsp/imageurl"); if (selectSingleNode != null) { string r = selectSingleNode.InnerText; return r; } return null; }
public async Task<string> Shorten(String Url) { try { if (Url.Length <= 30) { return Url; } var _fetcher = new AsyncWebFetcher(); string text = await _fetcher.FetchAsync("http://tinyurl.com/api-create.php?url=" + Uri.EscapeDataString(Url)); return text; } catch (Exception ex) { CompositionManager.Get<IExceptionReporter>().ReportHandledException(ex); return Url; } }
public async void HandleCheckMahTweetsVersion (CheckMahTweetsVersionMessage currentVersion) { var webFetcher = new AsyncWebFetcher(); var versionraw = await webFetcher.FetchAsync(_versioncheckurl); var j = JObject.Parse(versionraw); var currentmajor = j["major"].ToObject<Int32>(); var currentminor = j["minor"].ToObject<Int32>(); var currentpatch = j["patch"].ToObject<Int32>(); var currentbuild = j["build"].ToObject<String>(); var runningmajor = currentVersion.RunningVersion.Item1; var runningminor = currentVersion.RunningVersion.Item2; var runningpatch = currentVersion.RunningVersion.Item3; var runningbuild = currentVersion.RunningVersion.Item4; var flagupdate = currentmajor > runningmajor; if (currentminor > runningminor) { flagupdate = true; } if (currentpatch > runningpatch) { flagupdate = true; } if (currentbuild.ToLower() != runningbuild.ToLower()) { flagupdate = true; } if (!flagupdate) return; var infourl = j["infourl"].ToObject<String>(); var downloadurl = j["downloadurl"].ToObject<String>(); var messagetext = j["messagetext"].ToObject<String>(); var versiontext = string.Format("{0}.{1}.{2}.{3}", currentmajor, currentminor, currentpatch, currentbuild); _eventAggregator.GetEvent<ShowNotification>().Publish(new ShowNotificationPayload(new UpdateNotification(messagetext,versiontext,downloadurl,infourl), TimeSpan.FromMinutes(1), NotificactionLevel.Information)); }
public async Task<string> Process(string url) { try { if (url == null) return null; var url2 = url; if (url.ToLower().Contains(Flickrshorturl)) { var urlizer = new AsyncWebFetcher(); var longlong = await urlizer.FetchAsync(url); if (longlong == null) return null; var match2 = Regex.Match(longlong, Flickrfindlonginshort); if (!match2.Success) return null; url2 = match2.Groups["realurl"].Value; } var iid = FindImageID(url2); var getImageInfoUrl = String.Format(Flickrgetphotoid, Apikey, iid); var fetcher = new AsyncWebFetcher(); var flickrdata = await fetcher.FetchAsync(getImageInfoUrl); if (flickrdata == null) return null; var xdoc = new XmlDocument(); xdoc.LoadXml(flickrdata); var photo = xdoc.SelectSingleNode("/rsp/photo"); if (photo == null) return null; return photo.Attributes == null ? null : String.Format(Flickrimagestaticurl, photo.Attributes["farm"].InnerText, photo.Attributes["server"].InnerText, iid, photo.Attributes["secret"].InnerText); } catch (Exception ex) { CompositionManager.Get<IExceptionReporter>().ReportHandledException(ex); } return null; }
public async Task<string> Shorten(String Url) { if (Url == null) return null; var urlExpanders = CompositionManager.Get<IUrlExpandService>(); if (urlExpanders.IsShortUrl(Url) || Url.Length < 20) { return Url; } if (Credentials == null) { var plugins = CompositionManager.Get<IPluginRepository>(); IUrlShortener bitlyPlugin = plugins.UrlShorteners.FirstOrDefault(t => t.Protocol == Protocol); if (bitlyPlugin == null) { ShowSettings(Url); return null; } Credentials = bitlyPlugin.Credentials; } string url = string.Format("http://api.bit.ly/v3/shorten?format=xml&longUrl={0}&login={1}&apiKey={2}", Uri.EscapeDataString(Url), Credentials.Username, Credentials.Password); var _fetcher = new AsyncWebFetcher(); string resultText = await _fetcher.FetchAsync(url); XDocument resultXml = XDocument.Parse(resultText); XElement status = resultXml.Descendants("status_code").First(); if (status != null) { if (status.Value == "500") { string errorMessage = "Unknown error"; try { errorMessage = resultXml.Descendants("status_txt").First().Value; } catch (Exception ex) { CompositionManager.Get<IExceptionReporter>().ReportHandledException(ex); } var _eventAggregator = CompositionManager.Get<IEventAggregator>(); _eventAggregator.GetEvent<ShowNotification>().Publish( new ShowNotificationPayload("Error with bit.ly: " + errorMessage, TimeSpan.Zero, NotificactionLevel.Error)); if (errorMessage == "INVALID_APIKEY") { Credentials = null; var plugins = CompositionManager.Get<IPluginRepository>(); IUrlShortener bitlyPlugin = plugins.UrlShorteners.FirstOrDefault(t => t.Protocol == Protocol); if (bitlyPlugin != null) plugins.UrlShorteners.Remove(bitlyPlugin); } } else { IEnumerable<XElement> data = resultXml.Descendants("data"); if (data != null) { string x = (from result in data let xElement = result.Element("url") where xElement != null select xElement.Value).FirstOrDefault(); if (!String.IsNullOrEmpty(x)) { return x; } } } } return Url; }
private async Task<Dictionary<string, string>> GetLongUrlPleaseRequest(IEnumerable<string> shortUrls) { Uri longUrlPleaseUri = GetLongUrlPleaseUri(shortUrls); var _fetcher = new AsyncWebFetcher(); try { string responseText = await _fetcher.FetchAsync(longUrlPleaseUri); var responseObject = JsonConvert.DeserializeObject<Dictionary<String, String>>(responseText); return responseObject; } catch (Exception ex) { CompositionManager.Get<IExceptionReporter>().ReportHandledException(ex); } return null; }