Skip to content

Commit

Permalink
Fix for Download Purchased Tab
Browse files Browse the repository at this point in the history
  • Loading branch information
sim0n00ps committed Oct 4, 2024
1 parent 278f8ce commit e45dea9
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 38 deletions.
2 changes: 1 addition & 1 deletion OF DL/Entities/Post/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public string rawText
public bool? canVote { get; set; }
public List<Medium> media { get; set; }
public bool? canViewMedia { get; set; }
public List<string> preview { get; set; }
public List<object> preview { get; set; }
}

public class Manifest
Expand Down
105 changes: 68 additions & 37 deletions OF DL/Helpers/APIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Org.BouncyCastle.Asn1.Crmf;
using Serilog;
using System.Globalization;
using System.IO;
using System.Reflection.PortableExecutable;
using System.Security.Cryptography;
using System.Text;
Expand Down Expand Up @@ -740,19 +741,25 @@ public async Task<PaidPostCollection> GetPaidPosts(string endpoint, string folde
{
for (int i = 0; i < purchase.previews.Count; i++)
{
if (!previewids.Contains((long)purchase.previews[i]))
if (purchase.previews[i] is long previewId)
{
previewids.Add((long)purchase.previews[i]);
if (!previewids.Contains(previewId))
{
previewids.Add(previewId);
}
}
}
}
else if (purchase.preview != null)
{
for (int i = 0; i < purchase.preview.Count; i++)
{
if (!previewids.Contains((long)purchase.preview[i]))
if (purchase.preview[i] is long previewId)
{
previewids.Add((long)purchase.preview[i]);
if (!previewids.Contains(previewId))
{
previewids.Add(previewId);
}
}
}
}
Expand Down Expand Up @@ -932,13 +939,13 @@ public async Task<PostCollection> GetPosts(string endpoint, string folder, IDown
List<long> postPreviewIds = new();
if (post.preview != null && post.preview.Count > 0)
{
foreach (var id in post.preview)
for (int i = 0; i < post.preview.Count; i++)
{
if (id?.ToString() != "poll")
if (post.preview[i] is long previewId)
{
if (!postPreviewIds.Contains(Convert.ToInt64(id)))
if (!postPreviewIds.Contains(previewId))
{
postPreviewIds.Add(Convert.ToInt64(id));
postPreviewIds.Add(previewId);
}
}
}
Expand Down Expand Up @@ -1046,13 +1053,13 @@ public async Task<SinglePostCollection> GetPost(string endpoint, string folder,
List<long> postPreviewIds = new();
if (singlePost.preview != null && singlePost.preview.Count > 0)
{
foreach (var id in singlePost.preview)
for (int i = 0; i < singlePost.preview.Count; i++)
{
if (id?.ToString() != "poll")
if (singlePost.preview[i] is long previewId)
{
if (!postPreviewIds.Contains(Convert.ToInt64(id)))
if (!postPreviewIds.Contains(previewId))
{
postPreviewIds.Add(Convert.ToInt64(id));
postPreviewIds.Add(previewId);
}
}
}
Expand Down Expand Up @@ -1200,13 +1207,13 @@ public async Task<StreamsCollection> GetStreams(string endpoint, string folder,
List<long> streamPreviewIds = new();
if (stream.preview != null && stream.preview.Count > 0)
{
foreach (var id in stream.preview)
for (int i = 0; i < stream.preview.Count; i++)
{
if (id?.ToString() != "poll")
if (stream.preview[i] is long previewId)
{
if (!streamPreviewIds.Contains(Convert.ToInt64(id)))
if (!streamPreviewIds.Contains(previewId))
{
streamPreviewIds.Add(Convert.ToInt64(id));
streamPreviewIds.Add(previewId);
}
}
}
Expand Down Expand Up @@ -1344,11 +1351,11 @@ public async Task<ArchivedCollection> GetArchived(string endpoint, string folder
{
for (int i = 0; i < archive.preview.Count; i++)
{
if (archive.preview[i]?.ToString() != "poll")
if (archive.preview[i] is long previewId)
{
if (!previewids.Contains((long)archive.preview[i]))
if (!previewids.Contains(previewId))
{
previewids.Add((long)archive.preview[i]);
previewids.Add(previewId);
}
}
}
Expand Down Expand Up @@ -1462,11 +1469,14 @@ public async Task<MessageCollection> GetMessages(string endpoint, string folder,
List<long> messagePreviewIds = new();
if (list.previews != null && list.previews.Count > 0)
{
foreach (var id in list.previews)
for (int i = 0; i < list.previews.Count; i++)
{
if (!messagePreviewIds.Contains((long)id))
if (list.previews[i] is long previewId)
{
messagePreviewIds.Add((long)id);
if (!messagePreviewIds.Contains(previewId))
{
messagePreviewIds.Add(previewId);
}
}
}
}
Expand Down Expand Up @@ -1625,11 +1635,14 @@ public async Task<SinglePaidMessageCollection> GetPaidMessage(string endpoint, s
List<long> messagePreviewIds = new();
if (message.previews != null && message.previews.Count > 0)
{
foreach (var id in message.previews)
for (int i = 0; i < message.previews.Count; i++)
{
if (!messagePreviewIds.Contains((long)id))
if (message.previews[i] is long previewId)
{
messagePreviewIds.Add((long)id);
if (!messagePreviewIds.Contains(previewId))
{
messagePreviewIds.Add(previewId);
}
}
}
}
Expand Down Expand Up @@ -1780,19 +1793,25 @@ public async Task<PaidMessageCollection> GetPaidMessages(string endpoint, string
{
for (int i = 0; i < purchase.previews.Count; i++)
{
if (!previewids.Contains((long)purchase.previews[i]))
if (purchase.previews[i] is long previewId)
{
previewids.Add((long)purchase.previews[i]);
if (!previewids.Contains(previewId))
{
previewids.Add(previewId);
}
}
}
}
else if (purchase.preview != null)
{
for (int i = 0; i < purchase.preview.Count; i++)
{
if (!previewids.Contains((long)purchase.preview[i]))
if (purchase.preview[i] is long previewId)
{
previewids.Add((long)purchase.preview[i]);
if (!previewids.Contains(previewId))
{
previewids.Add(previewId);
}
}
}
}
Expand Down Expand Up @@ -2185,19 +2204,25 @@ public async Task<List<PurchasedTabCollection>> GetPurchasedTab(string endpoint,
{
for (int i = 0; i < purchase.previews.Count; i++)
{
if (!previewids.Contains((long)purchase.previews[i]))
if (purchase.previews[i] is long previewId)
{
previewids.Add((long)purchase.previews[i]);
if (!previewids.Contains(previewId))
{
previewids.Add(previewId);
}
}
}
}
else if (purchase.preview != null)
{
for (int i = 0; i < purchase.preview.Count; i++)
{
if (!previewids.Contains((long)purchase.preview[i]))
if (purchase.preview[i] is long previewId)
{
previewids.Add((long)purchase.preview[i]);
if (!previewids.Contains(previewId))
{
previewids.Add(previewId);
}
}
}
}
Expand Down Expand Up @@ -2286,19 +2311,25 @@ public async Task<List<PurchasedTabCollection>> GetPurchasedTab(string endpoint,
{
for (int i = 0; i < purchase.previews.Count; i++)
{
if (!paidMessagePreviewids.Contains((long)purchase.previews[i]))
if (purchase.previews[i] is long previewId)
{
paidMessagePreviewids.Add((long)purchase.previews[i]);
if (!paidMessagePreviewids.Contains(previewId))
{
paidMessagePreviewids.Add(previewId);
}
}
}
}
else if (purchase.preview != null)
{
for (int i = 0; i < purchase.preview.Count; i++)
{
if (!paidMessagePreviewids.Contains((long)purchase.preview[i]))
if (purchase.preview[i] is long previewId)
{
paidMessagePreviewids.Add((long)purchase.preview[i]);
if (!paidMessagePreviewids.Contains(previewId))
{
paidMessagePreviewids.Add(previewId);
}
}
}
}
Expand Down

0 comments on commit e45dea9

Please sign in to comment.