TooltipText = null,
};
}
- catch (WebException)
- {
- return null;
- }
+ catch (HttpRequestException) { }
+
+ return null;
}
protected virtual string GetThumbnailUrl(string html)
var contentId = match.Groups["ContentId"].Value;
- var xdoc = await this.FetchContentInfoApiAsync(contentId, token)
- .ConfigureAwait(false);
-
- if (xdoc.XPathSelectElement("/rsp").Attribute("stat").Value == "ok")
+ try
{
+ var xdoc = await this.FetchContentInfoApiAsync(contentId, token)
+ .ConfigureAwait(false);
+
+ if (xdoc.XPathSelectElement("/rsp").Attribute("stat").Value != "ok")
+ return null;
+
var thumbUrlElm = xdoc.XPathSelectElement("/rsp/content/thumbnails/thumbnail_150x150");
- if (thumbUrlElm != null)
+ if (thumbUrlElm == null)
+ return null;
+
+ var descElm = xdoc.XPathSelectElement("/rsp/content/description");
+
+ return new ThumbnailInfo
{
- var descElm = xdoc.XPathSelectElement("/rsp/content/description");
-
- return new ThumbnailInfo
- {
- ImageUrl = url,
- ThumbnailUrl = thumbUrlElm.Attribute("url").Value,
- TooltipText = descElm == null ? null : descElm.Value,
- };
- }
+ ImageUrl = url,
+ ThumbnailUrl = thumbUrlElm.Attribute("url").Value,
+ TooltipText = descElm == null ? null : descElm.Value,
+ };
}
+ catch (HttpRequestException) { }
return null;
}
return null;
var postId = match.Groups[1].Value;
- var apiUrl = "http://via.me/api/v1/posts/" + postId;
- var json = await this.http.GetByteArrayAsync(apiUrl)
- .ConfigureAwait(false);
-
- using (var jsonReader = JsonReaderWriterFactory.CreateJsonReader(json, XmlDictionaryReaderQuotas.Max))
+ try
{
- var xElm = XElement.Load(jsonReader);
+ var apiUrl = "http://via.me/api/v1/posts/" + postId;
+
+ var json = await this.http.GetByteArrayAsync(apiUrl)
+ .ConfigureAwait(false);
- var thumbUrlElm = xElm.XPathSelectElement("/response/post/thumb_url");
- if (thumbUrlElm == null)
+ using (var jsonReader = JsonReaderWriterFactory.CreateJsonReader(json, XmlDictionaryReaderQuotas.Max))
{
- return null;
- }
+ var xElm = XElement.Load(jsonReader);
- var textElm = xElm.XPathSelectElement("/response/post/text");
+ var thumbUrlElm = xElm.XPathSelectElement("/response/post/thumb_url");
+ if (thumbUrlElm == null)
+ return null;
- return new ThumbnailInfo
- {
- ImageUrl = url,
- ThumbnailUrl = thumbUrlElm.Value,
- TooltipText = textElm == null ? null : textElm.Value,
- };
+ var textElm = xElm.XPathSelectElement("/response/post/text");
+
+ return new ThumbnailInfo
+ {
+ ImageUrl = url,
+ ThumbnailUrl = thumbUrlElm.Value,
+ TooltipText = textElm == null ? null : textElm.Value,
+ };
+ }
}
+ catch (HttpRequestException) { }
+
+ return null;
}
}
}
if (!match.Success)
return null;
- var apiUrl = "http://vimeo.com/api/oembed.xml?url=" + Uri.EscapeDataString(url);
+ try
+ {
+ var apiUrl = "http://vimeo.com/api/oembed.xml?url=" + Uri.EscapeDataString(url);
- var xmlStr = await this.http.GetStringAsync(apiUrl)
- .ConfigureAwait(false);
+ var xmlStr = await this.http.GetStringAsync(apiUrl)
+ .ConfigureAwait(false);
- var xdoc = XDocument.Parse(xmlStr);
+ var xdoc = XDocument.Parse(xmlStr);
+
+ var thumbUrlElm = xdoc.XPathSelectElement("/oembed/thumbnail_url");
+ if (thumbUrlElm == null)
+ return null;
- var thumbUrlElm = xdoc.XPathSelectElement("/oembed/thumbnail_url");
- if (thumbUrlElm != null)
- {
var titleElm = xdoc.XPathSelectElement("/oembed/title");
var durationElm = xdoc.XPathSelectElement("/oembed/duration");
TooltipText = tooltipText,
};
}
+ catch (HttpRequestException) { }
return null;
}