Skip to content

Commit

Permalink
Merge pull request #485 from ddirty830/fix/missing-rawtext
Browse files Browse the repository at this point in the history
fix: parse rawTax from text is missing
  • Loading branch information
sim0n00ps committed Jul 24, 2024
2 parents c532851 + b0174c6 commit 852198c
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 5 deletions.
37 changes: 35 additions & 2 deletions OF DL/Entities/Archived/Archived.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using OF_DL.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -82,7 +83,23 @@ public class LinkedPost
public object expiredAt { get; set; }
public Author author { get; set; }
public string text { get; set; }
public string rawText { get; set; }
private string _rawText;
public string rawText
{
get
{
if (string.IsNullOrEmpty(_rawText))
{
_rawText = XmlUtils.EvaluateInnerText(text);
}

return _rawText;
}
set
{
_rawText = value;
}
}
public bool? lockedText { get; set; }
public bool? isFavorite { get; set; }
public bool? canReport { get; set; }
Expand Down Expand Up @@ -124,7 +141,23 @@ public class List
public object expiredAt { get; set; }
public Author author { get; set; }
public string text { get; set; }
public string rawText { get; set; }
private string _rawText;
public string rawText
{
get
{
if (string.IsNullOrEmpty(_rawText))
{
_rawText = XmlUtils.EvaluateInnerText(text);
}

return _rawText;
}
set
{
_rawText = value;
}
}
public bool? lockedText { get; set; }
public bool? isFavorite { get; set; }
public bool? canReport { get; set; }
Expand Down
20 changes: 19 additions & 1 deletion OF DL/Entities/Post/Post.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using OF_DL.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -74,7 +75,24 @@ public class List
public object expiredAt { get; set; }
public Author author { get; set; }
public string text { get; set; }
public string rawText { get; set; }

private string _rawText;
public string rawText
{
get
{
if(string.IsNullOrEmpty(_rawText))
{
_rawText = XmlUtils.EvaluateInnerText(text);
}

return _rawText;
}
set
{
_rawText = value;
}
}
public bool? lockedText { get; set; }
public bool? isFavorite { get; set; }
public bool? canReport { get; set; }
Expand Down
19 changes: 18 additions & 1 deletion OF DL/Entities/Post/SinglePost.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using OF_DL.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -16,7 +17,23 @@ public class SinglePost
public object expiredAt { get; set; }
public Author author { get; set; }
public string text { get; set; }
public string rawText { get; set; }
private string _rawText;
public string rawText
{
get
{
if (string.IsNullOrEmpty(_rawText))
{
_rawText = XmlUtils.EvaluateInnerText(text);
}

return _rawText;
}
set
{
_rawText = value;
}
}
public bool lockedText { get; set; }
public bool isFavorite { get; set; }
public bool canReport { get; set; }
Expand Down
19 changes: 18 additions & 1 deletion OF DL/Entities/Streams/Streams.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using OF_DL.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -52,7 +53,23 @@ public class List
public object expiredAt { get; set; }
public Author author { get; set; }
public string text { get; set; }
public string rawText { get; set; }
private string _rawText;
public string rawText
{
get
{
if (string.IsNullOrEmpty(_rawText))
{
_rawText = XmlUtils.EvaluateInnerText(text);
}

return _rawText;
}
set
{
_rawText = value;
}
}
public bool lockedText { get; set; }
public bool isFavorite { get; set; }
public bool canReport { get; set; }
Expand Down
25 changes: 25 additions & 0 deletions OF DL/Utils/XmlUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace OF_DL.Utils
{
internal static class XmlUtils
{
public static string EvaluateInnerText(string xmlValue)
{
try
{
var parsedText = XElement.Parse($"<root>{xmlValue}</root>");
return parsedText.Value;
}
catch
{ }

return string.Empty;
}
}
}

0 comments on commit 852198c

Please sign in to comment.