mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
Added some fixes for the Imgur V3 API response parsing, the links were not correctly processed.
This commit is contained in:
parent
45c0e1efed
commit
ca84909f4b
1 changed files with 27 additions and 2 deletions
|
@ -166,16 +166,41 @@ namespace GreenshotImgurPlugin
|
|||
}
|
||||
nodes = doc.GetElementsByTagName("datetime");
|
||||
if(nodes.Count > 0) {
|
||||
imgurInfo.Timestamp = DateTime.Parse(nodes.Item(0).InnerText);
|
||||
try
|
||||
{
|
||||
imgurInfo.Timestamp = DateTime.Parse(nodes.Item(0).InnerText);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Version 3 has seconds since Epoch
|
||||
double secondsSince;
|
||||
if (double.TryParse(nodes.Item(0).InnerText, out secondsSince))
|
||||
{
|
||||
var epoch = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
|
||||
imgurInfo.Timestamp = epoch.AddSeconds(secondsSince).DateTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes = doc.GetElementsByTagName("original");
|
||||
if(nodes.Count > 0) {
|
||||
imgurInfo.Original = nodes.Item(0).InnerText;
|
||||
}
|
||||
// Version 3 API only has Link
|
||||
nodes = doc.GetElementsByTagName("link");
|
||||
if (nodes.Count > 0)
|
||||
{
|
||||
imgurInfo.Original = nodes.Item(0).InnerText;
|
||||
}
|
||||
nodes = doc.GetElementsByTagName("imgur_page");
|
||||
if(nodes.Count > 0) {
|
||||
if (nodes.Count > 0)
|
||||
{
|
||||
imgurInfo.Page = nodes.Item(0).InnerText;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Version 3 doesn't have a page link in the response
|
||||
imgurInfo.Page = string.Format("http://imgur.com/{0}", imgurInfo.Hash);
|
||||
}
|
||||
nodes = doc.GetElementsByTagName("small_square");
|
||||
if(nodes.Count > 0) {
|
||||
imgurInfo.SmallSquare = nodes.Item(0).InnerText;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue