Refactor Purchased entities into DTOs and application entities with standardized naming conventions and default values
This commit is contained in:
parent
3c307bf7de
commit
6c60509398
10
OF DL/Models/Dtos/Purchased/FromUserDto.cs
Normal file
10
OF DL/Models/Dtos/Purchased/FromUserDto.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace OF_DL.Models.Dtos.Purchased;
|
||||
|
||||
public class FromUserDto
|
||||
{
|
||||
[JsonProperty("id")] public long Id { get; set; }
|
||||
|
||||
[JsonProperty("_view")] public string View { get; set; } = "";
|
||||
}
|
||||
72
OF DL/Models/Dtos/Purchased/ListItemDto.cs
Normal file
72
OF DL/Models/Dtos/Purchased/ListItemDto.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using Newtonsoft.Json;
|
||||
using OF_DL.Models.Dtos.Common;
|
||||
using MessageDtos = OF_DL.Models.Dtos.Messages;
|
||||
|
||||
namespace OF_DL.Models.Dtos.Purchased;
|
||||
|
||||
public class ListItemDto
|
||||
{
|
||||
[JsonProperty("responseType")] public string ResponseType { get; set; } = "";
|
||||
|
||||
[JsonProperty("text")] public string Text { get; set; } = "";
|
||||
|
||||
[JsonProperty("giphyId")] public object GiphyId { get; set; } = new();
|
||||
|
||||
[JsonProperty("lockedText")] public bool? LockedText { get; set; }
|
||||
|
||||
[JsonProperty("isFree")] public bool? IsFree { get; set; }
|
||||
|
||||
[JsonProperty("price")] public string? Price { get; set; }
|
||||
|
||||
[JsonProperty("isMediaReady")] public bool? IsMediaReady { get; set; }
|
||||
|
||||
[JsonProperty("mediaCount")] public int? MediaCount { get; set; }
|
||||
|
||||
[JsonProperty("media")] public List<MessageDtos.MediumDto>? Media { get; set; }
|
||||
|
||||
[JsonProperty("previews")] public List<object>? Previews { get; set; }
|
||||
|
||||
[JsonProperty("preview")] public List<object>? Preview { get; set; }
|
||||
|
||||
[JsonProperty("isTip")] public bool? IsTip { get; set; }
|
||||
|
||||
[JsonProperty("isReportedByMe")] public bool? IsReportedByMe { get; set; }
|
||||
|
||||
[JsonProperty("isCouplePeopleMedia")] public bool? IsCouplePeopleMedia { get; set; }
|
||||
|
||||
[JsonProperty("queueId")] public object QueueId { get; set; } = new();
|
||||
|
||||
[JsonProperty("fromUser")] public FromUserDto? FromUser { get; set; }
|
||||
|
||||
[JsonProperty("author")] public AuthorDto? Author { get; set; }
|
||||
|
||||
[JsonProperty("isFromQueue")] public bool? IsFromQueue { get; set; }
|
||||
|
||||
[JsonProperty("canUnsendQueue")] public bool? CanUnsendQueue { get; set; }
|
||||
|
||||
[JsonProperty("unsendSecondsQueue")] public int? UnsendSecondsQueue { get; set; }
|
||||
|
||||
[JsonProperty("id")] public long Id { get; set; }
|
||||
|
||||
[JsonProperty("isOpened")] public bool IsOpened { get; set; }
|
||||
|
||||
[JsonProperty("isNew")] public bool? IsNew { get; set; }
|
||||
|
||||
[JsonProperty("createdAt")] public DateTime? CreatedAt { get; set; }
|
||||
|
||||
[JsonProperty("postedAt")] public DateTime? PostedAt { get; set; }
|
||||
|
||||
[JsonProperty("changedAt")] public DateTime? ChangedAt { get; set; }
|
||||
|
||||
[JsonProperty("cancelSeconds")] public int? CancelSeconds { get; set; }
|
||||
|
||||
[JsonProperty("isLiked")] public bool? IsLiked { get; set; }
|
||||
|
||||
[JsonProperty("canPurchase")] public bool? CanPurchase { get; set; }
|
||||
|
||||
[JsonProperty("canReport")] public bool? CanReport { get; set; }
|
||||
|
||||
[JsonProperty("isCanceled")] public bool? IsCanceled { get; set; }
|
||||
|
||||
[JsonProperty("isArchived")] public bool? IsArchived { get; set; }
|
||||
}
|
||||
10
OF DL/Models/Dtos/Purchased/PurchasedDto.cs
Normal file
10
OF DL/Models/Dtos/Purchased/PurchasedDto.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace OF_DL.Models.Dtos.Purchased;
|
||||
|
||||
public class PurchasedDto
|
||||
{
|
||||
[JsonProperty("list")] public List<ListItemDto> List { get; set; } = [];
|
||||
|
||||
[JsonProperty("hasMore")] public bool HasMore { get; set; }
|
||||
}
|
||||
@ -2,5 +2,5 @@ namespace OF_DL.Models.Entities.Common;
|
||||
|
||||
public class FromUser
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
public long Id { get; set; }
|
||||
}
|
||||
|
||||
33
OF DL/Models/Entities/Purchased/ListItem.cs
Normal file
33
OF DL/Models/Entities/Purchased/ListItem.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using OF_DL.Models.Entities.Common;
|
||||
using MessageEntities = OF_DL.Models.Entities.Messages;
|
||||
|
||||
namespace OF_DL.Models.Entities.Purchased;
|
||||
|
||||
public class ListItem
|
||||
{
|
||||
public string ResponseType { get; set; } = "";
|
||||
|
||||
public string? Text { get; set; }
|
||||
|
||||
public string? Price { get; set; }
|
||||
|
||||
public List<MessageEntities.Medium>? Media { get; set; }
|
||||
|
||||
public List<object>? Previews { get; set; }
|
||||
|
||||
public List<object>? Preview { get; set; }
|
||||
|
||||
public FromUser FromUser { get; set; } = new();
|
||||
|
||||
public Author Author { get; set; } = new();
|
||||
|
||||
public long Id { get; set; }
|
||||
|
||||
public bool IsOpened { get; set; }
|
||||
|
||||
public DateTime? CreatedAt { get; set; }
|
||||
|
||||
public DateTime? PostedAt { get; set; }
|
||||
|
||||
public bool? IsArchived { get; set; }
|
||||
}
|
||||
12
OF DL/Models/Entities/Purchased/PaidMessageCollection.cs
Normal file
12
OF DL/Models/Entities/Purchased/PaidMessageCollection.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using MessageEntities = OF_DL.Models.Entities.Messages;
|
||||
|
||||
namespace OF_DL.Models.Entities.Purchased;
|
||||
|
||||
public class PaidMessageCollection
|
||||
{
|
||||
public List<MessageEntities.Medium> PaidMessageMedia { get; set; } = [];
|
||||
|
||||
public List<ListItem> PaidMessageObjects { get; set; } = [];
|
||||
|
||||
public Dictionary<long, string> PaidMessages { get; set; } = new();
|
||||
}
|
||||
12
OF DL/Models/Entities/Purchased/PaidPostCollection.cs
Normal file
12
OF DL/Models/Entities/Purchased/PaidPostCollection.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using MessageEntities = OF_DL.Models.Entities.Messages;
|
||||
|
||||
namespace OF_DL.Models.Entities.Purchased;
|
||||
|
||||
public class PaidPostCollection
|
||||
{
|
||||
public List<MessageEntities.Medium> PaidPostMedia { get; set; } = [];
|
||||
|
||||
public List<ListItem> PaidPostObjects { get; set; } = [];
|
||||
|
||||
public Dictionary<long, string> PaidPosts { get; set; } = new();
|
||||
}
|
||||
8
OF DL/Models/Entities/Purchased/Purchased.cs
Normal file
8
OF DL/Models/Entities/Purchased/Purchased.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace OF_DL.Models.Entities.Purchased;
|
||||
|
||||
public class Purchased
|
||||
{
|
||||
public List<ListItem> List { get; set; } = [];
|
||||
|
||||
public bool HasMore { get; set; }
|
||||
}
|
||||
@ -1,9 +1,12 @@
|
||||
namespace OF_DL.Models.Purchased;
|
||||
namespace OF_DL.Models.Entities.Purchased;
|
||||
|
||||
public class PurchasedTabCollection
|
||||
{
|
||||
public long UserId { get; set; }
|
||||
public string Username { get; set; } = string.Empty;
|
||||
|
||||
public string Username { get; set; } = "";
|
||||
|
||||
public PaidPostCollection PaidPosts { get; set; } = new();
|
||||
|
||||
public PaidMessageCollection PaidMessages { get; set; } = new();
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
using MessageEntities = OF_DL.Models.Entities.Messages;
|
||||
|
||||
namespace OF_DL.Models.Entities.Purchased;
|
||||
|
||||
public class SinglePaidMessageCollection
|
||||
{
|
||||
public List<MessageEntities.Medium> PreviewSingleMessageMedia { get; set; } = [];
|
||||
|
||||
|
||||
public Dictionary<long, string> PreviewSingleMessages { get; set; } = new();
|
||||
|
||||
public List<MessageEntities.Medium> SingleMessageMedia { get; set; } = [];
|
||||
|
||||
public List<MessageEntities.SingleMessage> SingleMessageObjects { get; set; } = [];
|
||||
|
||||
public Dictionary<long, string> SingleMessages { get; set; } = new();
|
||||
}
|
||||
@ -64,7 +64,7 @@ public static class MessagesMapper
|
||||
media?.Select(MapMedium).ToList();
|
||||
|
||||
private static FromUser? MapFromUser(FromUserDto? dto) =>
|
||||
dto == null ? null : new FromUser { Id = dto.Id };
|
||||
dto?.Id == null ? null : new FromUser { Id = (long)dto.Id };
|
||||
|
||||
private static Files? MapFiles(FilesDto? dto) =>
|
||||
dto == null ? null : new Files { Full = MapFull(dto.Full), Drm = MapDrm(dto.Drm) };
|
||||
|
||||
56
OF DL/Models/Mappers/PurchasedMapper.cs
Normal file
56
OF DL/Models/Mappers/PurchasedMapper.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using OF_DL.Models.Dtos.Purchased;
|
||||
using OF_DL.Models.Dtos.Common;
|
||||
using MessageDtos = OF_DL.Models.Dtos.Messages;
|
||||
using CommonEntities = OF_DL.Models.Entities.Common;
|
||||
using MessageEntities = OF_DL.Models.Entities.Messages;
|
||||
using PurchasedEntities = OF_DL.Models.Entities.Purchased;
|
||||
|
||||
|
||||
namespace OF_DL.Models.Mappers;
|
||||
|
||||
public static class PurchasedMapper
|
||||
{
|
||||
public static PurchasedEntities.Purchased FromDto(PurchasedDto? dto)
|
||||
{
|
||||
PurchasedEntities.Purchased mapped = new() { HasMore = dto?.HasMore ?? false };
|
||||
|
||||
if (dto?.List == null)
|
||||
{
|
||||
return mapped;
|
||||
}
|
||||
|
||||
foreach (ListItemDto entry in dto.List)
|
||||
{
|
||||
mapped.List.Add(MapList(entry));
|
||||
}
|
||||
|
||||
return mapped;
|
||||
}
|
||||
|
||||
private static PurchasedEntities.ListItem MapList(ListItemDto dto) =>
|
||||
new()
|
||||
{
|
||||
ResponseType = dto.ResponseType,
|
||||
Text = dto.Text,
|
||||
Price = dto.Price,
|
||||
IsOpened = dto.IsOpened,
|
||||
IsArchived = dto.IsArchived,
|
||||
CreatedAt = dto.CreatedAt,
|
||||
PostedAt = dto.PostedAt,
|
||||
Id = dto.Id,
|
||||
Media = MapMedia(dto.Media),
|
||||
Previews = dto.Previews,
|
||||
Preview = dto.Preview,
|
||||
FromUser = MapFromUser(dto.FromUser),
|
||||
Author = MapAuthor(dto.Author)
|
||||
};
|
||||
|
||||
private static CommonEntities.FromUser MapFromUser(FromUserDto? dto) =>
|
||||
dto == null ? new CommonEntities.FromUser() : new CommonEntities.FromUser { Id = dto.Id };
|
||||
|
||||
private static CommonEntities.Author MapAuthor(AuthorDto? dto) =>
|
||||
dto == null ? new CommonEntities.Author() : new CommonEntities.Author { Id = dto.Id };
|
||||
|
||||
private static List<MessageEntities.Medium>? MapMedia(List<MessageDtos.MediumDto>? media) =>
|
||||
media?.Select(MessagesMapper.MapMedium).ToList();
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
using MessageEntities = OF_DL.Models.Entities.Messages;
|
||||
|
||||
namespace OF_DL.Models.Purchased;
|
||||
|
||||
public class PaidMessageCollection
|
||||
{
|
||||
public List<MessageEntities.Medium> PaidMessageMedia = new();
|
||||
public List<Purchased.List> PaidMessageObjects = new();
|
||||
public Dictionary<long, string> PaidMessages = new();
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
using MessageEntities = OF_DL.Models.Entities.Messages;
|
||||
|
||||
namespace OF_DL.Models.Purchased;
|
||||
|
||||
public class PaidPostCollection
|
||||
{
|
||||
public List<MessageEntities.Medium> PaidPostMedia = new();
|
||||
public List<Purchased.List> PaidPostObjects = new();
|
||||
public Dictionary<long, string> PaidPosts = new();
|
||||
}
|
||||
@ -1,75 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using OF_DL.Models.Dtos.Messages;
|
||||
|
||||
namespace OF_DL.Models.Purchased;
|
||||
|
||||
public class Purchased
|
||||
{
|
||||
public List<List> list { get; set; }
|
||||
public bool hasMore { get; set; }
|
||||
|
||||
public class FromUser
|
||||
{
|
||||
public long id { get; set; }
|
||||
public string _view { get; set; }
|
||||
}
|
||||
|
||||
public class Author
|
||||
{
|
||||
public long id { get; set; }
|
||||
public string _view { get; set; }
|
||||
}
|
||||
|
||||
public class Hls
|
||||
{
|
||||
[JsonProperty("CloudFront-Policy")] public string CloudFrontPolicy { get; set; }
|
||||
|
||||
[JsonProperty("CloudFront-Signature")] public string CloudFrontSignature { get; set; }
|
||||
|
||||
[JsonProperty("CloudFront-Key-Pair-Id")]
|
||||
public string CloudFrontKeyPairId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class List
|
||||
{
|
||||
public string responseType { get; set; }
|
||||
public string text { get; set; }
|
||||
public object giphyId { get; set; }
|
||||
public bool? lockedText { get; set; }
|
||||
public bool? isFree { get; set; }
|
||||
public string? price { get; set; }
|
||||
public bool? isMediaReady { get; set; }
|
||||
public int? mediaCount { get; set; }
|
||||
public List<MediumDto> media { get; set; }
|
||||
public List<object> previews { get; set; }
|
||||
public List<object> preview { get; set; }
|
||||
public bool? isTip { get; set; }
|
||||
public bool? isReportedByMe { get; set; }
|
||||
public bool? isCouplePeopleMedia { get; set; }
|
||||
public object queueId { get; set; }
|
||||
public FromUser fromUser { get; set; }
|
||||
public Author author { get; set; }
|
||||
public bool? isFromQueue { get; set; }
|
||||
public bool? canUnsendQueue { get; set; }
|
||||
public int? unsendSecondsQueue { get; set; }
|
||||
public long id { get; set; }
|
||||
public bool isOpened { get; set; }
|
||||
public bool? isNew { get; set; }
|
||||
public DateTime? createdAt { get; set; }
|
||||
public DateTime? postedAt { get; set; }
|
||||
public DateTime? changedAt { get; set; }
|
||||
public int? cancelSeconds { get; set; }
|
||||
public bool? isLiked { get; set; }
|
||||
public bool? canPurchase { get; set; }
|
||||
public bool? canReport { get; set; }
|
||||
public bool? isCanceled { get; set; }
|
||||
public bool? isArchived { get; set; }
|
||||
}
|
||||
|
||||
public class Manifest
|
||||
{
|
||||
public string hls { get; set; }
|
||||
public string dash { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
using MessageEntities = OF_DL.Models.Entities.Messages;
|
||||
|
||||
namespace OF_DL.Models.Purchased;
|
||||
|
||||
public class SinglePaidMessageCollection
|
||||
{
|
||||
public List<MessageEntities.Medium> PreviewSingleMessageMedia = new();
|
||||
|
||||
public Dictionary<long, string> PreviewSingleMessages = new();
|
||||
public List<MessageEntities.Medium> SingleMessageMedia = new();
|
||||
public List<MessageEntities.SingleMessage> SingleMessageObjects = new();
|
||||
public Dictionary<long, string> SingleMessages = new();
|
||||
}
|
||||
@ -7,13 +7,13 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OF_DL.CLI;
|
||||
using OF_DL.Models;
|
||||
using OF_DL.Models.Purchased;
|
||||
using OF_DL.Models.Streams;
|
||||
using OF_DL.Enumerations;
|
||||
using OF_DL.Helpers;
|
||||
using ArchivedEntities = OF_DL.Models.Entities.Archived;
|
||||
using MessageEntities = OF_DL.Models.Entities.Messages;
|
||||
using PostEntities = OF_DL.Models.Entities.Posts;
|
||||
using PurchasedEntities = OF_DL.Models.Entities.Purchased;
|
||||
using OF_DL.Services;
|
||||
using Serilog;
|
||||
using Spectre.Console;
|
||||
@ -801,9 +801,9 @@ public class Program(IServiceProvider serviceProvider)
|
||||
|
||||
Log.Debug($"Download path: {p}");
|
||||
|
||||
List<PurchasedTabCollection> purchasedTabCollections =
|
||||
List<PurchasedEntities.PurchasedTabCollection> purchasedTabCollections =
|
||||
await apiService.GetPurchasedTab("/posts/paid/all", p, users);
|
||||
foreach (PurchasedTabCollection purchasedTabCollection in purchasedTabCollections)
|
||||
foreach (PurchasedEntities.PurchasedTabCollection purchasedTabCollection in purchasedTabCollections)
|
||||
{
|
||||
AnsiConsole.Markup($"[red]\nScraping Data for {purchasedTabCollection.Username}\n[/]");
|
||||
string path = "";
|
||||
@ -1056,7 +1056,7 @@ public class Program(IServiceProvider serviceProvider)
|
||||
IAPIService apiService = serviceProvider.GetRequiredService<IAPIService>();
|
||||
IDownloadService downloadService = serviceProvider.GetRequiredService<IDownloadService>();
|
||||
|
||||
PaidMessageCollection paidMessageCollection = new();
|
||||
PurchasedEntities.PaidMessageCollection paidMessageCollection = new();
|
||||
|
||||
await AnsiConsole.Status()
|
||||
.StartAsync("[red]Getting Paid Messages[/]",
|
||||
@ -1391,7 +1391,7 @@ public class Program(IServiceProvider serviceProvider)
|
||||
AnsiConsole.Markup("[red]Getting Paid Posts\n[/]");
|
||||
Log.Debug($"Calling DownloadPaidPosts - {user.Key}");
|
||||
|
||||
PaidPostCollection purchasedPosts = new();
|
||||
PurchasedEntities.PaidPostCollection purchasedPosts = new();
|
||||
|
||||
await AnsiConsole.Status()
|
||||
.StartAsync("[red]Getting Paid Posts[/]",
|
||||
@ -1442,7 +1442,8 @@ public class Program(IServiceProvider serviceProvider)
|
||||
return result.TotalCount;
|
||||
}
|
||||
|
||||
private async Task<int> DownloadPaidPostsPurchasedTab(string username, PaidPostCollection purchasedPosts,
|
||||
private async Task<int> DownloadPaidPostsPurchasedTab(string username,
|
||||
PurchasedEntities.PaidPostCollection purchasedPosts,
|
||||
KeyValuePair<string, long> user, int paidPostCount, string path, Dictionary<string, long> users)
|
||||
{
|
||||
IDBService dbService = serviceProvider.GetRequiredService<IDBService>();
|
||||
@ -1525,9 +1526,9 @@ public class Program(IServiceProvider serviceProvider)
|
||||
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
purchasedPosts?.PaidPostMedia?.FirstOrDefault(m => m.Id == purchasedPostKVP.Key);
|
||||
Purchased.List? postInfo = mediaInfo != null
|
||||
PurchasedEntities.ListItem? postInfo = mediaInfo != null
|
||||
? purchasedPosts?.PaidPostObjects?.FirstOrDefault(p =>
|
||||
p?.media?.Any(m => m.Id == purchasedPostKVP.Key) == true)
|
||||
p?.Media?.Any(m => m.Id == purchasedPostKVP.Key) == true)
|
||||
: null;
|
||||
|
||||
isNew = await downloadService.DownloadPurchasedPostDRMVideo(
|
||||
@ -1545,7 +1546,7 @@ public class Program(IServiceProvider serviceProvider)
|
||||
.PaidPostFileNameFormat ?? string.Empty,
|
||||
postInfo,
|
||||
mediaInfo,
|
||||
postInfo?.fromUser,
|
||||
postInfo?.FromUser,
|
||||
users);
|
||||
if (isNew)
|
||||
{
|
||||
@ -1560,9 +1561,9 @@ public class Program(IServiceProvider serviceProvider)
|
||||
{
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
purchasedPosts?.PaidPostMedia?.FirstOrDefault(m => m.Id == purchasedPostKVP.Key);
|
||||
Purchased.List? postInfo = mediaInfo != null
|
||||
PurchasedEntities.ListItem? postInfo = mediaInfo != null
|
||||
? purchasedPosts?.PaidPostObjects?.FirstOrDefault(p =>
|
||||
p?.media?.Any(m => m.Id == purchasedPostKVP.Key) == true)
|
||||
p?.Media?.Any(m => m.Id == purchasedPostKVP.Key) == true)
|
||||
: null;
|
||||
|
||||
isNew = await downloadService.DownloadPurchasedPostMedia(
|
||||
@ -1575,7 +1576,7 @@ public class Program(IServiceProvider serviceProvider)
|
||||
.PaidPostFileNameFormat ?? string.Empty,
|
||||
postInfo,
|
||||
mediaInfo,
|
||||
postInfo?.fromUser,
|
||||
postInfo?.FromUser,
|
||||
users);
|
||||
if (isNew)
|
||||
{
|
||||
@ -1597,7 +1598,8 @@ public class Program(IServiceProvider serviceProvider)
|
||||
}
|
||||
|
||||
private async Task<int> DownloadPaidMessagesPurchasedTab(string username,
|
||||
PaidMessageCollection paidMessageCollection, KeyValuePair<string, long> user, int paidMessagesCount,
|
||||
PurchasedEntities.PaidMessageCollection paidMessageCollection, KeyValuePair<string, long> user,
|
||||
int paidMessagesCount,
|
||||
string path, Dictionary<string, long> users)
|
||||
{
|
||||
IDBService dbService = serviceProvider.GetRequiredService<IDBService>();
|
||||
@ -1675,9 +1677,9 @@ public class Program(IServiceProvider serviceProvider)
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
paidMessageCollection.PaidMessageMedia.FirstOrDefault(m =>
|
||||
m.Id == paidMessageKVP.Key);
|
||||
Purchased.List? messageInfo =
|
||||
PurchasedEntities.ListItem? messageInfo =
|
||||
paidMessageCollection.PaidMessageObjects.FirstOrDefault(p =>
|
||||
p?.media?.Any(m => m.Id == paidMessageKVP.Key) == true);
|
||||
p?.Media?.Any(m => m.Id == paidMessageKVP.Key) == true);
|
||||
|
||||
isNew = await downloadService.DownloadPurchasedMessageDRMVideo(
|
||||
policy,
|
||||
@ -1694,7 +1696,7 @@ public class Program(IServiceProvider serviceProvider)
|
||||
.PaidMessageFileNameFormat ?? string.Empty,
|
||||
messageInfo,
|
||||
mediaInfo,
|
||||
messageInfo?.fromUser,
|
||||
messageInfo?.FromUser,
|
||||
users);
|
||||
|
||||
if (isNew)
|
||||
@ -1711,9 +1713,9 @@ public class Program(IServiceProvider serviceProvider)
|
||||
{
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
paidMessageCollection.PaidMessageMedia.FirstOrDefault(m => m.Id == paidMessageKVP.Key);
|
||||
Purchased.List messageInfo =
|
||||
PurchasedEntities.ListItem messageInfo =
|
||||
paidMessageCollection.PaidMessageObjects.FirstOrDefault(p =>
|
||||
p?.media?.Any(m => m.Id == paidMessageKVP.Key) == true);
|
||||
p?.Media?.Any(m => m.Id == paidMessageKVP.Key) == true);
|
||||
|
||||
isNew = await downloadService.DownloadPurchasedMedia(
|
||||
paidMessageKVP.Value,
|
||||
@ -1725,7 +1727,7 @@ public class Program(IServiceProvider serviceProvider)
|
||||
.PaidMessageFileNameFormat ?? string.Empty,
|
||||
messageInfo,
|
||||
mediaInfo,
|
||||
messageInfo?.fromUser,
|
||||
messageInfo?.FromUser,
|
||||
users);
|
||||
if (isNew)
|
||||
{
|
||||
@ -1827,7 +1829,7 @@ public class Program(IServiceProvider serviceProvider)
|
||||
|
||||
AnsiConsole.Markup("[red]Getting Paid Message\n[/]");
|
||||
|
||||
SinglePaidMessageCollection singlePaidMessageCollection =
|
||||
PurchasedEntities.SinglePaidMessageCollection singlePaidMessageCollection =
|
||||
await apiService.GetPaidMessage($"/messages/{message_id.ToString()}", path);
|
||||
int oldPreviewPaidMessagesCount = 0;
|
||||
int newPreviewPaidMessagesCount = 0;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -4,13 +4,13 @@ using System.Xml.Linq;
|
||||
using FFmpeg.NET;
|
||||
using FFmpeg.NET.Events;
|
||||
using OF_DL.Models;
|
||||
using OF_DL.Models.Purchased;
|
||||
using OF_DL.Models.Streams;
|
||||
using OF_DL.Enumerations;
|
||||
using ArchivedEntities = OF_DL.Models.Entities.Archived;
|
||||
using CommonEntities = OF_DL.Models.Entities.Common;
|
||||
using MessageEntities = OF_DL.Models.Entities.Messages;
|
||||
using PostEntities = OF_DL.Models.Entities.Posts;
|
||||
using PurchasedEntities = OF_DL.Models.Entities.Purchased;
|
||||
using OF_DL.Utils;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
@ -1109,15 +1109,15 @@ public class DownloadService(
|
||||
}
|
||||
|
||||
public async Task<bool> DownloadPurchasedMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo,
|
||||
IProgressReporter progressReporter, string? filenameFormat, PurchasedEntities.ListItem? messageInfo,
|
||||
MessageEntities.Medium? messageMedia,
|
||||
Purchased.FromUser? fromUser, Dictionary<string, long> users)
|
||||
CommonEntities.FromUser? fromUser, Dictionary<string, long> users)
|
||||
{
|
||||
string path;
|
||||
if (configService.CurrentConfig.FolderPerPaidMessage && messageInfo != null && messageInfo?.id is not null &&
|
||||
messageInfo?.createdAt is not null)
|
||||
if (configService.CurrentConfig.FolderPerPaidMessage && messageInfo != null && messageInfo?.Id is not null &&
|
||||
messageInfo?.CreatedAt is not null)
|
||||
{
|
||||
path = $"/Messages/Paid/{messageInfo.id} {messageInfo.createdAt.Value:yyyy-MM-dd HH-mm-ss}";
|
||||
path = $"/Messages/Paid/{messageInfo.Id} {messageInfo.CreatedAt.Value:yyyy-MM-dd HH-mm-ss}";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1161,16 +1161,16 @@ public class DownloadService(
|
||||
string api_type,
|
||||
IProgressReporter progressReporter,
|
||||
string? filenameFormat,
|
||||
Purchased.List? messageInfo,
|
||||
PurchasedEntities.ListItem? messageInfo,
|
||||
MessageEntities.Medium? messageMedia,
|
||||
Purchased.FromUser? fromUser,
|
||||
CommonEntities.FromUser? fromUser,
|
||||
Dictionary<string, long> users)
|
||||
{
|
||||
string path;
|
||||
if (configService.CurrentConfig.FolderPerPaidPost && messageInfo != null && messageInfo?.id is not null &&
|
||||
messageInfo?.postedAt is not null)
|
||||
if (configService.CurrentConfig.FolderPerPaidPost && messageInfo != null && messageInfo?.Id is not null &&
|
||||
messageInfo?.PostedAt is not null)
|
||||
{
|
||||
path = $"/Posts/Paid/{messageInfo.id} {messageInfo.postedAt.Value:yyyy-MM-dd HH-mm-ss}";
|
||||
path = $"/Posts/Paid/{messageInfo.Id} {messageInfo.PostedAt.Value:yyyy-MM-dd HH-mm-ss}";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1451,9 +1451,9 @@ public class DownloadService(
|
||||
|
||||
public async Task<bool> DownloadPurchasedMessageDRMVideo(string policy, string signature, string kvp, string url,
|
||||
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo,
|
||||
IProgressReporter progressReporter, string? filenameFormat, PurchasedEntities.ListItem? messageInfo,
|
||||
MessageEntities.Medium? messageMedia,
|
||||
Purchased.FromUser? fromUser, Dictionary<string, long> users)
|
||||
CommonEntities.FromUser? fromUser, Dictionary<string, long> users)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -1462,9 +1462,9 @@ public class DownloadService(
|
||||
Uri uri = new(url);
|
||||
string filename = Path.GetFileName(uri.LocalPath).Split(".")[0];
|
||||
if (configService.CurrentConfig.FolderPerPaidMessage && messageInfo != null &&
|
||||
messageInfo?.id is not null && messageInfo?.createdAt is not null)
|
||||
messageInfo?.Id is not null && messageInfo?.CreatedAt is not null)
|
||||
{
|
||||
path = $"/Messages/Paid/{messageInfo.id} {messageInfo.createdAt.Value:yyyy-MM-dd HH-mm-ss}/Videos";
|
||||
path = $"/Messages/Paid/{messageInfo.Id} {messageInfo.CreatedAt.Value:yyyy-MM-dd HH-mm-ss}/Videos";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2095,9 +2095,9 @@ public class DownloadService(
|
||||
|
||||
public async Task<bool> DownloadPurchasedPostDRMVideo(string policy, string signature, string kvp, string url,
|
||||
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? postInfo,
|
||||
IProgressReporter progressReporter, string? filenameFormat, PurchasedEntities.ListItem? postInfo,
|
||||
MessageEntities.Medium? postMedia,
|
||||
Purchased.FromUser? fromUser, Dictionary<string, long> users)
|
||||
CommonEntities.FromUser? fromUser, Dictionary<string, long> users)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -2105,10 +2105,10 @@ public class DownloadService(
|
||||
string path;
|
||||
Uri uri = new(url);
|
||||
string filename = Path.GetFileName(uri.LocalPath).Split(".")[0];
|
||||
if (configService.CurrentConfig.FolderPerPaidPost && postInfo != null && postInfo?.id is not null &&
|
||||
postInfo?.postedAt is not null)
|
||||
if (configService.CurrentConfig.FolderPerPaidPost && postInfo != null && postInfo?.Id is not null &&
|
||||
postInfo?.PostedAt is not null)
|
||||
{
|
||||
path = $"/Posts/Paid/{postInfo.id} {postInfo.postedAt.Value:yyyy-MM-dd HH-mm-ss}/Videos";
|
||||
path = $"/Posts/Paid/{postInfo.Id} {postInfo.PostedAt.Value:yyyy-MM-dd HH-mm-ss}/Videos";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2712,7 +2712,8 @@ public class DownloadService(
|
||||
|
||||
|
||||
public async Task<DownloadResult> DownloadPaidMessages(string username, string path, Dictionary<string, long> users,
|
||||
bool clientIdBlobMissing, bool devicePrivateKeyMissing, PaidMessageCollection paidMessageCollection,
|
||||
bool clientIdBlobMissing, bool devicePrivateKeyMissing,
|
||||
PurchasedEntities.PaidMessageCollection paidMessageCollection,
|
||||
IProgressReporter progressReporter)
|
||||
{
|
||||
Log.Debug($"Calling DownloadPaidMessages - {username}");
|
||||
@ -2760,14 +2761,14 @@ public class DownloadService(
|
||||
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
paidMessageCollection.PaidMessageMedia.FirstOrDefault(m => m.Id == kvp.Key);
|
||||
Purchased.List? messageInfo =
|
||||
PurchasedEntities.ListItem? messageInfo =
|
||||
paidMessageCollection.PaidMessageObjects.FirstOrDefault(p =>
|
||||
p?.media?.Any(m => m.Id == kvp.Key) == true);
|
||||
p?.Media?.Any(m => m.Id == kvp.Key) == true);
|
||||
|
||||
isNew = await DownloadPurchasedMessageDRMVideo(parsed[1], parsed[2], parsed[3], parsed[0],
|
||||
decryptionKey, path, lastModified, kvp.Key, "Messages", progressReporter,
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).MessageFileNameFormat ??
|
||||
string.Empty, messageInfo, mediaInfo, messageInfo?.fromUser, users);
|
||||
string.Empty, messageInfo, mediaInfo, messageInfo?.FromUser, users);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2778,11 +2779,11 @@ public class DownloadService(
|
||||
{
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
paidMessageCollection.PaidMessageMedia.FirstOrDefault(m => m.Id == kvp.Key);
|
||||
Purchased.List? messageInfo = paidMessageCollection.PaidMessageObjects.FirstOrDefault(p =>
|
||||
p?.media?.Any(m => m.Id == kvp.Key) == true);
|
||||
PurchasedEntities.ListItem? messageInfo = paidMessageCollection.PaidMessageObjects.FirstOrDefault(p =>
|
||||
p?.Media?.Any(m => m.Id == kvp.Key) == true);
|
||||
isNew = await DownloadPurchasedMedia(kvp.Value, path, kvp.Key, "Messages", progressReporter,
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).MessageFileNameFormat ??
|
||||
string.Empty, messageInfo, mediaInfo, messageInfo?.fromUser, users);
|
||||
string.Empty, messageInfo, mediaInfo, messageInfo?.FromUser, users);
|
||||
}
|
||||
|
||||
if (isNew)
|
||||
@ -2992,7 +2993,7 @@ public class DownloadService(
|
||||
|
||||
public async Task<DownloadResult> DownloadPaidPosts(string username, long userId, string path,
|
||||
Dictionary<string, long> users, bool clientIdBlobMissing, bool devicePrivateKeyMissing,
|
||||
PaidPostCollection purchasedPosts, IProgressReporter progressReporter)
|
||||
PurchasedEntities.PaidPostCollection purchasedPosts, IProgressReporter progressReporter)
|
||||
{
|
||||
Log.Debug($"Calling DownloadPaidPosts - {username}");
|
||||
|
||||
@ -3038,14 +3039,14 @@ public class DownloadService(
|
||||
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
purchasedPosts.PaidPostMedia.FirstOrDefault(m => m.Id == postKVP.Key);
|
||||
Purchased.List? postInfo =
|
||||
PurchasedEntities.ListItem? postInfo =
|
||||
purchasedPosts.PaidPostObjects.FirstOrDefault(p =>
|
||||
p?.media?.Any(m => m.Id == postKVP.Key) == true);
|
||||
p?.Media?.Any(m => m.Id == postKVP.Key) == true);
|
||||
|
||||
isNew = await DownloadPurchasedPostDRMVideo(parsed[1], parsed[2], parsed[3], parsed[0],
|
||||
decryptionKey, path, lastModified, postKVP.Key, "Posts", progressReporter,
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).PostFileNameFormat ??
|
||||
string.Empty, postInfo, mediaInfo, postInfo?.fromUser, users);
|
||||
string.Empty, postInfo, mediaInfo, postInfo?.FromUser, users);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3056,11 +3057,11 @@ public class DownloadService(
|
||||
{
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
purchasedPosts.PaidPostMedia.FirstOrDefault(m => m.Id == postKVP.Key);
|
||||
Purchased.List? postInfo =
|
||||
purchasedPosts.PaidPostObjects.FirstOrDefault(p => p?.media?.Any(m => m.Id == postKVP.Key) == true);
|
||||
PurchasedEntities.ListItem? postInfo =
|
||||
purchasedPosts.PaidPostObjects.FirstOrDefault(p => p?.Media?.Any(m => m.Id == postKVP.Key) == true);
|
||||
isNew = await DownloadPurchasedPostMedia(postKVP.Value, path, postKVP.Key, "Posts", progressReporter,
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).PostFileNameFormat ??
|
||||
string.Empty, postInfo, mediaInfo, postInfo?.fromUser, users);
|
||||
string.Empty, postInfo, mediaInfo, postInfo?.FromUser, users);
|
||||
}
|
||||
|
||||
if (isNew)
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OF_DL.Models;
|
||||
using OF_DL.Models.Purchased;
|
||||
using OF_DL.Models.Streams;
|
||||
using OF_DL.Enumerations;
|
||||
using OF_DL.Models.Entities.Purchased;
|
||||
using ArchivedEntities = OF_DL.Models.Entities.Archived;
|
||||
using MessageEntities = OF_DL.Models.Entities.Messages;
|
||||
using PostEntities = OF_DL.Models.Entities.Posts;
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
using OF_DL.Models;
|
||||
using OF_DL.Models.Purchased;
|
||||
using OF_DL.Models.Streams;
|
||||
using ArchivedEntities = OF_DL.Models.Entities.Archived;
|
||||
using CommonEntities = OF_DL.Models.Entities.Common;
|
||||
using MessageEntities = OF_DL.Models.Entities.Messages;
|
||||
using PostEntities = OF_DL.Models.Entities.Posts;
|
||||
using PurchasedEntities = OF_DL.Models.Entities.Purchased;
|
||||
|
||||
namespace OF_DL.Services;
|
||||
|
||||
@ -61,9 +61,9 @@ public interface IDownloadService
|
||||
CommonEntities.Author? author, Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadPurchasedMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo,
|
||||
IProgressReporter progressReporter, string? filenameFormat, PurchasedEntities.ListItem? messageInfo,
|
||||
MessageEntities.Medium? messageMedia,
|
||||
Purchased.FromUser? fromUser, Dictionary<string, long> users);
|
||||
CommonEntities.FromUser? fromUser, Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadSinglePurchasedMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, MessageEntities.SingleMessage? messageInfo,
|
||||
@ -71,9 +71,9 @@ public interface IDownloadService
|
||||
|
||||
Task<bool> DownloadPurchasedMessageDRMVideo(string policy, string signature, string kvp, string url,
|
||||
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo,
|
||||
IProgressReporter progressReporter, string? filenameFormat, PurchasedEntities.ListItem? messageInfo,
|
||||
MessageEntities.Medium? messageMedia,
|
||||
Purchased.FromUser? fromUser, Dictionary<string, long> users);
|
||||
CommonEntities.FromUser? fromUser, Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadSinglePurchasedMessageDRMVideo(string policy, string signature, string kvp, string url,
|
||||
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
|
||||
@ -82,14 +82,14 @@ public interface IDownloadService
|
||||
|
||||
Task<bool> DownloadPurchasedPostDRMVideo(string policy, string signature, string kvp, string url,
|
||||
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? postInfo,
|
||||
IProgressReporter progressReporter, string? filenameFormat, PurchasedEntities.ListItem? postInfo,
|
||||
MessageEntities.Medium? postMedia,
|
||||
Purchased.FromUser? fromUser, Dictionary<string, long> users);
|
||||
CommonEntities.FromUser? fromUser, Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadPurchasedPostMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo,
|
||||
IProgressReporter progressReporter, string? filenameFormat, PurchasedEntities.ListItem? messageInfo,
|
||||
MessageEntities.Medium? messageMedia,
|
||||
Purchased.FromUser? fromUser, Dictionary<string, long> users);
|
||||
CommonEntities.FromUser? fromUser, Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadStoryMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter);
|
||||
@ -127,7 +127,8 @@ public interface IDownloadService
|
||||
IProgressReporter progressReporter);
|
||||
|
||||
Task<DownloadResult> DownloadPaidMessages(string username, string path, Dictionary<string, long> users,
|
||||
bool clientIdBlobMissing, bool devicePrivateKeyMissing, PaidMessageCollection paidMessageCollection,
|
||||
bool clientIdBlobMissing, bool devicePrivateKeyMissing,
|
||||
PurchasedEntities.PaidMessageCollection paidMessageCollection,
|
||||
IProgressReporter progressReporter);
|
||||
|
||||
Task<DownloadResult> DownloadStreams(string username, long userId, string path, Dictionary<string, long> users,
|
||||
@ -139,6 +140,6 @@ public interface IDownloadService
|
||||
IProgressReporter progressReporter);
|
||||
|
||||
Task<DownloadResult> DownloadPaidPosts(string username, long userId, string path, Dictionary<string, long> users,
|
||||
bool clientIdBlobMissing, bool devicePrivateKeyMissing, PaidPostCollection purchasedPosts,
|
||||
bool clientIdBlobMissing, bool devicePrivateKeyMissing, PurchasedEntities.PaidPostCollection purchasedPosts,
|
||||
IProgressReporter progressReporter);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user