Skip to content

Commit

Permalink
Fix issue #539 Likes cannot be downloaded anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas694 committed Jun 3, 2024
1 parent 48c301d commit 4663be2
Showing 1 changed file with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ private bool PostWithinTimespan(DataModels.TumblrSearchJson.Data post)
}
dynamic obj = JsonConvert.DeserializeObject(extracted);
var likedPosts = obj.Likes.likedPosts;
if (likedPosts is null)
{
foreach (var query in obj.queries.queries)
{
if (query?.queryKey?[0] == "likes")
{
likedPosts = query.state.data.pages[0].items;
}
}
}
extracted = JsonConvert.SerializeObject(likedPosts);
var posts = JsonConvert.DeserializeObject<List<DataModels.TumblrSearchJson.Data>>(extracted);
return posts;
Expand Down Expand Up @@ -726,13 +736,19 @@ private static long ExtractNextPageLink(string document)

const string htmlPagination = "(id=\"next_page_link\" href=\"[A-Za-z0-9_/:.-]+/([0-9]+)/([A-Za-z0-9]+))\"";
const string jsonPagination = "&before=([0-9]*)";
const string jsonPagination2 = "\\?before=([0-9]*)";

_ = long.TryParse(Regex.Match(document, htmlPagination).Groups[3].Value, out var unixTime);

long.TryParse(Regex.Match(document, htmlPagination).Groups[3].Value, out var unixTime);

if(unixTime == 0)
if (unixTime == 0)
{
var r = Regex.Match(document, jsonPagination);
long.TryParse(r.Groups[1].Value, out unixTime);
_ = long.TryParse(r.Groups[1].Value, out unixTime);

if (unixTime == 0)
{
_ = long.TryParse(Regex.Match(document, jsonPagination2).Groups[1].Value, out unixTime);
}
}

return unixTime;
Expand Down

0 comments on commit 4663be2

Please sign in to comment.