Reduce duplicated code and simplify download media methods
This commit is contained in:
parent
a8b2acaad6
commit
44a9fb1fcd
520
OF DL/Program.cs
520
OF DL/Program.cs
@ -1491,64 +1491,43 @@ public class Program(IServiceProvider serviceProvider)
|
||||
foreach (KeyValuePair<long, string> purchasedPostKVP in purchasedPosts.PaidPosts)
|
||||
{
|
||||
bool isNew;
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
purchasedPosts?.PaidPostMedia?.FirstOrDefault(m => m.Id == purchasedPostKVP.Key);
|
||||
PurchasedEntities.ListItem? postInfo = mediaInfo != null
|
||||
? purchasedPosts?.PaidPostObjects?.FirstOrDefault(p =>
|
||||
p?.Media?.Any(m => m.Id == purchasedPostKVP.Key) == true)
|
||||
: null;
|
||||
string filenameFormat = configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PaidPostFileNameFormat ?? "";
|
||||
string paidPostPath = configService.CurrentConfig.FolderPerPaidPost && postInfo != null &&
|
||||
postInfo?.Id is not null && postInfo?.PostedAt is not null
|
||||
? $"/Posts/Paid/{postInfo.Id} {postInfo.PostedAt.Value:yyyy-MM-dd HH-mm-ss}"
|
||||
: "/Posts/Paid";
|
||||
|
||||
if (purchasedPostKVP.Value.Contains("cdn3.onlyfans.com/dash/files"))
|
||||
{
|
||||
string[] messageUrlParsed = purchasedPostKVP.Value.Split(',');
|
||||
string mpdURL = messageUrlParsed[0];
|
||||
string policy = messageUrlParsed[1];
|
||||
string signature = messageUrlParsed[2];
|
||||
string kvp = messageUrlParsed[3];
|
||||
string mediaId = messageUrlParsed[4];
|
||||
string postId = messageUrlParsed[5];
|
||||
string? licenseURL = null;
|
||||
string? pssh = await apiService.GetDRMMPDPSSH(mpdURL, policy, signature, kvp);
|
||||
if (pssh == null)
|
||||
string[] parsed = purchasedPostKVP.Value.Split(',');
|
||||
(string decryptionKey, DateTime lastModified)? drmInfo =
|
||||
await downloadService.GetDecryptionInfo(parsed[0], parsed[1], parsed[2], parsed[3],
|
||||
parsed[4], parsed[5], "post", clientIdBlobMissing, devicePrivateKeyMissing);
|
||||
if (drmInfo == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
DateTime lastModified = await apiService.GetDRMMPDLastModified(mpdURL, policy, signature, kvp);
|
||||
Dictionary<string, string> drmHeaders =
|
||||
apiService.GetDynamicHeaders($"/api2/v2/users/media/{mediaId}/drm/post/{postId}",
|
||||
"?type=widevine");
|
||||
string decryptionKey;
|
||||
if (clientIdBlobMissing || devicePrivateKeyMissing)
|
||||
{
|
||||
decryptionKey = await apiService.GetDecryptionKeyOFDL(drmHeaders,
|
||||
$"https://onlyfans.com/api2/v2/users/media/{mediaId}/drm/post/{postId}?type=widevine",
|
||||
pssh);
|
||||
isNew = await downloadService.DownloadDRMVideo(parsed[1], parsed[2], parsed[3], parsed[0],
|
||||
drmInfo.Value.decryptionKey, path, drmInfo.Value.lastModified, purchasedPostKVP.Key,
|
||||
"Posts",
|
||||
new SpectreProgressReporter(task), paidPostPath + "/Videos", filenameFormat,
|
||||
postInfo, mediaInfo, postInfo?.FromUser, users);
|
||||
}
|
||||
else
|
||||
{
|
||||
decryptionKey = await apiService.GetDecryptionKeyCDM(drmHeaders,
|
||||
$"https://onlyfans.com/api2/v2/users/media/{mediaId}/drm/post/{postId}?type=widevine",
|
||||
pssh);
|
||||
isNew = await downloadService.DownloadMedia(purchasedPostKVP.Value, path,
|
||||
purchasedPostKVP.Key, "Posts", new SpectreProgressReporter(task),
|
||||
paidPostPath, filenameFormat, postInfo, mediaInfo, postInfo?.FromUser, users);
|
||||
}
|
||||
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
purchasedPosts?.PaidPostMedia?.FirstOrDefault(m => m.Id == purchasedPostKVP.Key);
|
||||
PurchasedEntities.ListItem? postInfo = mediaInfo != null
|
||||
? purchasedPosts?.PaidPostObjects?.FirstOrDefault(p =>
|
||||
p?.Media?.Any(m => m.Id == purchasedPostKVP.Key) == true)
|
||||
: null;
|
||||
|
||||
isNew = await downloadService.DownloadPurchasedPostDRMVideo(
|
||||
policy,
|
||||
signature,
|
||||
kvp,
|
||||
mpdURL,
|
||||
decryptionKey,
|
||||
path,
|
||||
lastModified,
|
||||
purchasedPostKVP.Key,
|
||||
"Posts",
|
||||
new SpectreProgressReporter(task),
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PaidPostFileNameFormat ?? "",
|
||||
postInfo,
|
||||
mediaInfo,
|
||||
postInfo?.FromUser,
|
||||
users);
|
||||
if (isNew)
|
||||
{
|
||||
newPaidPostCount++;
|
||||
@ -1558,37 +1537,6 @@ public class Program(IServiceProvider serviceProvider)
|
||||
oldPaidPostCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
purchasedPosts?.PaidPostMedia?.FirstOrDefault(m => m.Id == purchasedPostKVP.Key);
|
||||
PurchasedEntities.ListItem? postInfo = mediaInfo != null
|
||||
? purchasedPosts?.PaidPostObjects?.FirstOrDefault(p =>
|
||||
p?.Media?.Any(m => m.Id == purchasedPostKVP.Key) == true)
|
||||
: null;
|
||||
|
||||
isNew = await downloadService.DownloadPurchasedPostMedia(
|
||||
purchasedPostKVP.Value,
|
||||
path,
|
||||
purchasedPostKVP.Key,
|
||||
"Posts",
|
||||
new SpectreProgressReporter(task),
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PaidPostFileNameFormat ?? "",
|
||||
postInfo,
|
||||
mediaInfo,
|
||||
postInfo?.FromUser,
|
||||
users);
|
||||
if (isNew)
|
||||
{
|
||||
newPaidPostCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldPaidPostCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task.StopTask();
|
||||
});
|
||||
@ -1643,62 +1591,41 @@ public class Program(IServiceProvider serviceProvider)
|
||||
foreach (KeyValuePair<long, string> paidMessageKVP in paidMessageCollection.PaidMessages)
|
||||
{
|
||||
bool isNew;
|
||||
if (paidMessageKVP.Value.Contains("cdn3.onlyfans.com/dash/files"))
|
||||
{
|
||||
string[] messageUrlParsed = paidMessageKVP.Value.Split(',');
|
||||
string mpdURL = messageUrlParsed[0];
|
||||
string policy = messageUrlParsed[1];
|
||||
string signature = messageUrlParsed[2];
|
||||
string kvp = messageUrlParsed[3];
|
||||
string mediaId = messageUrlParsed[4];
|
||||
string messageId = messageUrlParsed[5];
|
||||
string? licenseURL = null;
|
||||
string? pssh = await apiService.GetDRMMPDPSSH(mpdURL, policy, signature, kvp);
|
||||
if (pssh != null)
|
||||
{
|
||||
DateTime lastModified =
|
||||
await apiService.GetDRMMPDLastModified(mpdURL, policy, signature, kvp);
|
||||
Dictionary<string, string> drmHeaders =
|
||||
apiService.GetDynamicHeaders(
|
||||
$"/api2/v2/users/media/{mediaId}/drm/message/{messageId}", "?type=widevine");
|
||||
string decryptionKey;
|
||||
if (clientIdBlobMissing || devicePrivateKeyMissing)
|
||||
{
|
||||
decryptionKey = await apiService.GetDecryptionKeyOFDL(drmHeaders,
|
||||
$"https://onlyfans.com/api2/v2/users/media/{mediaId}/drm/message/{messageId}?type=widevine",
|
||||
pssh);
|
||||
}
|
||||
else
|
||||
{
|
||||
decryptionKey = await apiService.GetDecryptionKeyCDM(drmHeaders,
|
||||
$"https://onlyfans.com/api2/v2/users/media/{mediaId}/drm/message/{messageId}?type=widevine",
|
||||
pssh);
|
||||
}
|
||||
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
paidMessageCollection.PaidMessageMedia.FirstOrDefault(m =>
|
||||
m.Id == paidMessageKVP.Key);
|
||||
paidMessageCollection.PaidMessageMedia.FirstOrDefault(m => m.Id == paidMessageKVP.Key);
|
||||
PurchasedEntities.ListItem? messageInfo =
|
||||
paidMessageCollection.PaidMessageObjects.FirstOrDefault(p =>
|
||||
p?.Media?.Any(m => m.Id == paidMessageKVP.Key) == true);
|
||||
string filenameFormat = configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PaidMessageFileNameFormat ?? "";
|
||||
string paidMsgPath = configService.CurrentConfig.FolderPerPaidMessage && messageInfo != null &&
|
||||
messageInfo?.Id is not null && messageInfo?.CreatedAt is not null
|
||||
? $"/Messages/Paid/{messageInfo.Id} {messageInfo.CreatedAt.Value:yyyy-MM-dd HH-mm-ss}"
|
||||
: "/Messages/Paid";
|
||||
|
||||
isNew = await downloadService.DownloadPurchasedMessageDRMVideo(
|
||||
policy,
|
||||
signature,
|
||||
kvp,
|
||||
mpdURL,
|
||||
decryptionKey,
|
||||
path,
|
||||
lastModified,
|
||||
paidMessageKVP.Key,
|
||||
if (paidMessageKVP.Value.Contains("cdn3.onlyfans.com/dash/files"))
|
||||
{
|
||||
string[] parsed = paidMessageKVP.Value.Split(',');
|
||||
(string decryptionKey, DateTime lastModified)? drmInfo =
|
||||
await downloadService.GetDecryptionInfo(parsed[0], parsed[1], parsed[2], parsed[3],
|
||||
parsed[4], parsed[5], "message", clientIdBlobMissing, devicePrivateKeyMissing);
|
||||
if (drmInfo == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
isNew = await downloadService.DownloadDRMVideo(parsed[1], parsed[2], parsed[3], parsed[0],
|
||||
drmInfo.Value.decryptionKey, path, drmInfo.Value.lastModified, paidMessageKVP.Key,
|
||||
"Messages",
|
||||
new SpectreProgressReporter(task),
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PaidMessageFileNameFormat ?? "",
|
||||
messageInfo,
|
||||
mediaInfo,
|
||||
messageInfo?.FromUser,
|
||||
users);
|
||||
new SpectreProgressReporter(task), paidMsgPath + "/Videos", filenameFormat,
|
||||
messageInfo, mediaInfo, messageInfo?.FromUser, users);
|
||||
}
|
||||
else
|
||||
{
|
||||
isNew = await downloadService.DownloadMedia(paidMessageKVP.Value, path,
|
||||
paidMessageKVP.Key, "Messages", new SpectreProgressReporter(task),
|
||||
paidMsgPath, filenameFormat, messageInfo, mediaInfo, messageInfo?.FromUser, users);
|
||||
}
|
||||
|
||||
if (isNew)
|
||||
{
|
||||
@ -1709,37 +1636,6 @@ public class Program(IServiceProvider serviceProvider)
|
||||
oldPaidMessagesCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
paidMessageCollection.PaidMessageMedia.FirstOrDefault(m => m.Id == paidMessageKVP.Key);
|
||||
PurchasedEntities.ListItem messageInfo =
|
||||
paidMessageCollection.PaidMessageObjects.FirstOrDefault(p =>
|
||||
p?.Media?.Any(m => m.Id == paidMessageKVP.Key) == true);
|
||||
|
||||
isNew = await downloadService.DownloadPurchasedMedia(
|
||||
paidMessageKVP.Value,
|
||||
path,
|
||||
paidMessageKVP.Key,
|
||||
"Messages",
|
||||
new SpectreProgressReporter(task),
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PaidMessageFileNameFormat ?? "",
|
||||
messageInfo,
|
||||
mediaInfo,
|
||||
messageInfo?.FromUser,
|
||||
users);
|
||||
if (isNew)
|
||||
{
|
||||
newPaidMessagesCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldPaidMessagesCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task.StopTask();
|
||||
});
|
||||
@ -1826,6 +1722,9 @@ public class Program(IServiceProvider serviceProvider)
|
||||
IAPIService apiService = serviceProvider.GetRequiredService<IAPIService>();
|
||||
IDownloadService downloadService = serviceProvider.GetRequiredService<IDownloadService>();
|
||||
|
||||
string filenameFormat = configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PaidMessageFileNameFormat ?? "";
|
||||
|
||||
Log.Debug($"Calling DownloadPaidMessage - {username}");
|
||||
|
||||
AnsiConsole.Markup("[red]Getting Paid Message\n[/]");
|
||||
@ -1870,62 +1769,42 @@ public class Program(IServiceProvider serviceProvider)
|
||||
.PreviewSingleMessages)
|
||||
{
|
||||
bool isNew;
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
singlePaidMessageCollection.PreviewSingleMessageMedia.FirstOrDefault(m =>
|
||||
m.Id == paidMessageKVP.Key);
|
||||
MessageEntities.SingleMessage? messageInfo =
|
||||
singlePaidMessageCollection.SingleMessageObjects.FirstOrDefault(p =>
|
||||
p?.Media?.Any(m => m.Id == paidMessageKVP.Key) == true);
|
||||
|
||||
string previewMsgPath = configService.CurrentConfig.FolderPerMessage && messageInfo != null &&
|
||||
messageInfo?.Id is not null && messageInfo?.CreatedAt is not null
|
||||
? $"/Messages/Free/{messageInfo.Id} {messageInfo.CreatedAt.Value:yyyy-MM-dd HH-mm-ss}"
|
||||
: "/Messages/Free";
|
||||
|
||||
if (paidMessageKVP.Value.Contains("cdn3.onlyfans.com/dash/files"))
|
||||
{
|
||||
string[] messageUrlParsed = paidMessageKVP.Value.Split(',');
|
||||
string mpdURL = messageUrlParsed[0];
|
||||
string policy = messageUrlParsed[1];
|
||||
string signature = messageUrlParsed[2];
|
||||
string kvp = messageUrlParsed[3];
|
||||
string mediaId = messageUrlParsed[4];
|
||||
string messageId = messageUrlParsed[5];
|
||||
string? licenseURL = null;
|
||||
string? pssh = await apiService.GetDRMMPDPSSH(mpdURL, policy, signature, kvp);
|
||||
if (pssh != null)
|
||||
string[] parsed = paidMessageKVP.Value.Split(',');
|
||||
(string decryptionKey, DateTime lastModified)? drmInfo =
|
||||
await downloadService.GetDecryptionInfo(parsed[0], parsed[1], parsed[2], parsed[3],
|
||||
parsed[4], parsed[5], "message", clientIdBlobMissing, devicePrivateKeyMissing);
|
||||
if (drmInfo == null)
|
||||
{
|
||||
DateTime lastModified =
|
||||
await apiService.GetDRMMPDLastModified(mpdURL, policy, signature, kvp);
|
||||
Dictionary<string, string> drmHeaders =
|
||||
apiService.GetDynamicHeaders(
|
||||
$"/api2/v2/users/media/{mediaId}/drm/message/{messageId}", "?type=widevine");
|
||||
string decryptionKey;
|
||||
if (clientIdBlobMissing || devicePrivateKeyMissing)
|
||||
{
|
||||
decryptionKey = await apiService.GetDecryptionKeyOFDL(drmHeaders,
|
||||
$"https://onlyfans.com/api2/v2/users/media/{mediaId}/drm/message/{messageId}?type=widevine",
|
||||
pssh);
|
||||
continue;
|
||||
}
|
||||
|
||||
isNew = await downloadService.DownloadDRMVideo(parsed[1], parsed[2], parsed[3], parsed[0],
|
||||
drmInfo.Value.decryptionKey, path, drmInfo.Value.lastModified, paidMessageKVP.Key,
|
||||
"Messages",
|
||||
new SpectreProgressReporter(task), previewMsgPath + "/Videos", filenameFormat,
|
||||
messageInfo, mediaInfo, messageInfo?.FromUser, hasSelectedUsersKVP.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
decryptionKey = await apiService.GetDecryptionKeyCDM(drmHeaders,
|
||||
$"https://onlyfans.com/api2/v2/users/media/{mediaId}/drm/message/{messageId}?type=widevine",
|
||||
pssh);
|
||||
}
|
||||
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
singlePaidMessageCollection.PreviewSingleMessageMedia.FirstOrDefault(m =>
|
||||
m.Id == paidMessageKVP.Key);
|
||||
MessageEntities.SingleMessage? messageInfo =
|
||||
singlePaidMessageCollection.SingleMessageObjects.FirstOrDefault(p =>
|
||||
p?.Media?.Any(m => m.Id == paidMessageKVP.Key) == true);
|
||||
|
||||
isNew = await downloadService.DownloadSingleMessagePreviewDRMVideo(
|
||||
policy,
|
||||
signature,
|
||||
kvp,
|
||||
mpdURL,
|
||||
decryptionKey,
|
||||
path,
|
||||
lastModified,
|
||||
paidMessageKVP.Key,
|
||||
"Messages",
|
||||
new SpectreProgressReporter(task),
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PaidMessageFileNameFormat ?? "",
|
||||
messageInfo,
|
||||
mediaInfo,
|
||||
messageInfo?.FromUser,
|
||||
isNew = await downloadService.DownloadMedia(paidMessageKVP.Value, path,
|
||||
paidMessageKVP.Key, "Messages", new SpectreProgressReporter(task),
|
||||
previewMsgPath, filenameFormat, messageInfo, mediaInfo, messageInfo?.FromUser,
|
||||
hasSelectedUsersKVP.Value);
|
||||
}
|
||||
|
||||
if (isNew)
|
||||
{
|
||||
@ -1936,38 +1815,6 @@ public class Program(IServiceProvider serviceProvider)
|
||||
oldPreviewPaidMessagesCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
singlePaidMessageCollection.PreviewSingleMessageMedia.FirstOrDefault(m =>
|
||||
m.Id == paidMessageKVP.Key);
|
||||
MessageEntities.SingleMessage? messageInfo =
|
||||
singlePaidMessageCollection.SingleMessageObjects.FirstOrDefault(p =>
|
||||
p?.Media?.Any(m => m.Id == paidMessageKVP.Key) == true);
|
||||
|
||||
isNew = await downloadService.DownloadMessagePreviewMedia(
|
||||
paidMessageKVP.Value,
|
||||
path,
|
||||
paidMessageKVP.Key,
|
||||
"Messages",
|
||||
new SpectreProgressReporter(task),
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PaidMessageFileNameFormat ?? "",
|
||||
messageInfo,
|
||||
mediaInfo,
|
||||
messageInfo?.FromUser,
|
||||
hasSelectedUsersKVP.Value);
|
||||
if (isNew)
|
||||
{
|
||||
newPreviewPaidMessagesCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldPreviewPaidMessagesCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task.StopTask();
|
||||
});
|
||||
@ -2010,93 +1857,42 @@ public class Program(IServiceProvider serviceProvider)
|
||||
foreach (KeyValuePair<long, string> paidMessageKVP in singlePaidMessageCollection.SingleMessages)
|
||||
{
|
||||
bool isNew;
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
singlePaidMessageCollection.SingleMessageMedia.FirstOrDefault(m =>
|
||||
m.Id == paidMessageKVP.Key);
|
||||
MessageEntities.SingleMessage? messageInfo =
|
||||
singlePaidMessageCollection.SingleMessageObjects.FirstOrDefault(p =>
|
||||
p?.Media?.Any(m => m.Id == paidMessageKVP.Key) == true);
|
||||
string filenameFormat = configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PaidMessageFileNameFormat ?? "";
|
||||
string singlePaidMsgPath = configService.CurrentConfig.FolderPerPaidMessage &&
|
||||
messageInfo != null && messageInfo?.Id is not null &&
|
||||
messageInfo?.CreatedAt is not null
|
||||
? $"/Messages/Paid/{messageInfo.Id} {messageInfo.CreatedAt.Value:yyyy-MM-dd HH-mm-ss}"
|
||||
: "/Messages/Paid";
|
||||
|
||||
if (paidMessageKVP.Value.Contains("cdn3.onlyfans.com/dash/files"))
|
||||
{
|
||||
string[] messageUrlParsed = paidMessageKVP.Value.Split(',');
|
||||
string mpdURL = messageUrlParsed[0];
|
||||
string policy = messageUrlParsed[1];
|
||||
string signature = messageUrlParsed[2];
|
||||
string kvp = messageUrlParsed[3];
|
||||
string mediaId = messageUrlParsed[4];
|
||||
string messageId = messageUrlParsed[5];
|
||||
string? licenseURL = null;
|
||||
string? pssh = await apiService.GetDRMMPDPSSH(mpdURL, policy, signature, kvp);
|
||||
if (pssh != null)
|
||||
string[] parsed = paidMessageKVP.Value.Split(',');
|
||||
(string decryptionKey, DateTime lastModified)? drmInfo =
|
||||
await downloadService.GetDecryptionInfo(parsed[0], parsed[1], parsed[2], parsed[3],
|
||||
parsed[4], parsed[5], "message", clientIdBlobMissing, devicePrivateKeyMissing);
|
||||
if (drmInfo == null)
|
||||
{
|
||||
DateTime lastModified =
|
||||
await apiService.GetDRMMPDLastModified(mpdURL, policy, signature, kvp);
|
||||
Dictionary<string, string> drmHeaders =
|
||||
apiService.GetDynamicHeaders(
|
||||
$"/api2/v2/users/media/{mediaId}/drm/message/{messageId}", "?type=widevine");
|
||||
string decryptionKey;
|
||||
if (clientIdBlobMissing || devicePrivateKeyMissing)
|
||||
{
|
||||
decryptionKey = await apiService.GetDecryptionKeyOFDL(drmHeaders,
|
||||
$"https://onlyfans.com/api2/v2/users/media/{mediaId}/drm/message/{messageId}?type=widevine",
|
||||
pssh);
|
||||
}
|
||||
else
|
||||
{
|
||||
decryptionKey = await apiService.GetDecryptionKeyCDM(drmHeaders,
|
||||
$"https://onlyfans.com/api2/v2/users/media/{mediaId}/drm/message/{messageId}?type=widevine",
|
||||
pssh);
|
||||
continue;
|
||||
}
|
||||
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
singlePaidMessageCollection.SingleMessageMedia.FirstOrDefault(m =>
|
||||
m.Id == paidMessageKVP.Key);
|
||||
MessageEntities.SingleMessage? messageInfo =
|
||||
singlePaidMessageCollection.SingleMessageObjects.FirstOrDefault(p =>
|
||||
p?.Media?.Any(m => m.Id == paidMessageKVP.Key) == true);
|
||||
|
||||
isNew = await downloadService.DownloadSinglePurchasedMessageDRMVideo(
|
||||
policy,
|
||||
signature,
|
||||
kvp,
|
||||
mpdURL,
|
||||
decryptionKey,
|
||||
path,
|
||||
lastModified,
|
||||
paidMessageKVP.Key,
|
||||
isNew = await downloadService.DownloadDRMVideo(parsed[1], parsed[2], parsed[3], parsed[0],
|
||||
drmInfo.Value.decryptionKey, path, drmInfo.Value.lastModified, paidMessageKVP.Key,
|
||||
"Messages",
|
||||
new SpectreProgressReporter(task),
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PaidMessageFileNameFormat ?? "",
|
||||
messageInfo,
|
||||
mediaInfo,
|
||||
messageInfo?.FromUser,
|
||||
hasSelectedUsersKVP.Value);
|
||||
|
||||
if (isNew)
|
||||
{
|
||||
newPaidMessagesCount++;
|
||||
new SpectreProgressReporter(task), singlePaidMsgPath + "/Videos", filenameFormat,
|
||||
messageInfo, mediaInfo, messageInfo?.FromUser, hasSelectedUsersKVP.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
oldPaidMessagesCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageEntities.Medium? mediaInfo =
|
||||
singlePaidMessageCollection.SingleMessageMedia.FirstOrDefault(m =>
|
||||
m.Id == paidMessageKVP.Key);
|
||||
MessageEntities.SingleMessage? messageInfo =
|
||||
singlePaidMessageCollection.SingleMessageObjects.FirstOrDefault(p =>
|
||||
p?.Media?.Any(m => m.Id == paidMessageKVP.Key) == true);
|
||||
|
||||
isNew = await downloadService.DownloadSinglePurchasedMedia(
|
||||
paidMessageKVP.Value,
|
||||
path,
|
||||
paidMessageKVP.Key,
|
||||
"Messages",
|
||||
new SpectreProgressReporter(task),
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PaidMessageFileNameFormat ?? "",
|
||||
messageInfo,
|
||||
mediaInfo,
|
||||
messageInfo?.FromUser,
|
||||
isNew = await downloadService.DownloadMedia(paidMessageKVP.Value, path,
|
||||
paidMessageKVP.Key, "Messages", new SpectreProgressReporter(task),
|
||||
singlePaidMsgPath, filenameFormat, messageInfo, mediaInfo, messageInfo?.FromUser,
|
||||
hasSelectedUsersKVP.Value);
|
||||
if (isNew)
|
||||
{
|
||||
@ -2162,83 +1958,39 @@ public class Program(IServiceProvider serviceProvider)
|
||||
task.StartTask();
|
||||
foreach (KeyValuePair<long, string> postKVP in post.SinglePosts)
|
||||
{
|
||||
PostEntities.Medium? mediaInfo = post.SinglePostMedia.FirstOrDefault(m => m.Id == postKVP.Key);
|
||||
PostEntities.SinglePost? postInfo =
|
||||
post.SinglePostObjects.FirstOrDefault(p => p?.Media?.Contains(mediaInfo) == true);
|
||||
string filenameFormat = configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PostFileNameFormat ?? "";
|
||||
string postPath = configService.CurrentConfig.FolderPerPost && postInfo != null &&
|
||||
postInfo?.Id is not null && postInfo?.PostedAt is not null
|
||||
? $"/Posts/Free/{postInfo.Id} {postInfo.PostedAt:yyyy-MM-dd HH-mm-ss}"
|
||||
: "/Posts/Free";
|
||||
|
||||
if (postKVP.Value.Contains("cdn3.onlyfans.com/dash/files"))
|
||||
{
|
||||
string[] messageUrlParsed = postKVP.Value.Split(',');
|
||||
string mpdURL = messageUrlParsed[0];
|
||||
string policy = messageUrlParsed[1];
|
||||
string signature = messageUrlParsed[2];
|
||||
string kvp = messageUrlParsed[3];
|
||||
string mediaId = messageUrlParsed[4];
|
||||
string postId = messageUrlParsed[5];
|
||||
string? licenseURL = null;
|
||||
string? pssh = await apiService.GetDRMMPDPSSH(mpdURL, policy, signature, kvp);
|
||||
if (pssh == null)
|
||||
string[] parsed = postKVP.Value.Split(',');
|
||||
(string decryptionKey, DateTime lastModified)? drmInfo =
|
||||
await downloadService.GetDecryptionInfo(parsed[0], parsed[1], parsed[2], parsed[3],
|
||||
parsed[4], parsed[5], "post", clientIdBlobMissing, devicePrivateKeyMissing);
|
||||
if (drmInfo == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
DateTime lastModified = await apiService.GetDRMMPDLastModified(mpdURL, policy, signature, kvp);
|
||||
Dictionary<string, string> drmHeaders =
|
||||
apiService.GetDynamicHeaders($"/api2/v2/users/media/{mediaId}/drm/post/{postId}",
|
||||
"?type=widevine");
|
||||
string decryptionKey;
|
||||
if (clientIdBlobMissing || devicePrivateKeyMissing)
|
||||
{
|
||||
decryptionKey = await apiService.GetDecryptionKeyOFDL(drmHeaders,
|
||||
$"https://onlyfans.com/api2/v2/users/media/{mediaId}/drm/post/{postId}?type=widevine",
|
||||
pssh);
|
||||
}
|
||||
else
|
||||
{
|
||||
decryptionKey = await apiService.GetDecryptionKeyCDM(drmHeaders,
|
||||
$"https://onlyfans.com/api2/v2/users/media/{mediaId}/drm/post/{postId}?type=widevine",
|
||||
pssh);
|
||||
}
|
||||
|
||||
PostEntities.Medium mediaInfo = post.SinglePostMedia.FirstOrDefault(m => m.Id == postKVP.Key);
|
||||
PostEntities.SinglePost postInfo =
|
||||
post.SinglePostObjects.FirstOrDefault(p => p?.Media?.Contains(mediaInfo) == true);
|
||||
|
||||
isNew = await downloadService.DownloadPostDRMVideo(
|
||||
policy,
|
||||
signature,
|
||||
kvp,
|
||||
mpdURL,
|
||||
decryptionKey,
|
||||
path,
|
||||
lastModified,
|
||||
postKVP.Key,
|
||||
"Posts",
|
||||
new SpectreProgressReporter(task),
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).PostFileNameFormat ??
|
||||
"",
|
||||
postInfo,
|
||||
mediaInfo,
|
||||
postInfo?.Author,
|
||||
users);
|
||||
isNew = await downloadService.DownloadDRMVideo(parsed[1], parsed[2], parsed[3], parsed[0],
|
||||
drmInfo.Value.decryptionKey, path, drmInfo.Value.lastModified, postKVP.Key, "Posts",
|
||||
new SpectreProgressReporter(task), postPath + "/Videos", filenameFormat,
|
||||
postInfo, mediaInfo, postInfo?.Author, users);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
PostEntities.Medium? mediaInfo =
|
||||
post.SinglePostMedia.FirstOrDefault(m => m.Id == postKVP.Key);
|
||||
PostEntities.SinglePost? postInfo =
|
||||
post.SinglePostObjects.FirstOrDefault(p => p?.Media?.Contains(mediaInfo) == true);
|
||||
|
||||
isNew = await downloadService.DownloadPostMedia(
|
||||
postKVP.Value,
|
||||
path,
|
||||
postKVP.Key,
|
||||
"Posts",
|
||||
new SpectreProgressReporter(task),
|
||||
configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
||||
.PostFileNameFormat ?? "",
|
||||
postInfo,
|
||||
mediaInfo,
|
||||
postInfo?.Author,
|
||||
users);
|
||||
isNew = await downloadService.DownloadMedia(postKVP.Value, path,
|
||||
postKVP.Key, "Posts", new SpectreProgressReporter(task),
|
||||
postPath, filenameFormat, postInfo, mediaInfo, postInfo?.Author, users);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,5 @@
|
||||
using OF_DL.Models;
|
||||
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;
|
||||
@ -15,105 +14,24 @@ public interface IDownloadService
|
||||
Task<bool> ProcessMediaDownload(string folder, long media_id, string api_type, string url, string path,
|
||||
string serverFileName, string resolvedFileName, string extension, IProgressReporter progressReporter);
|
||||
|
||||
Task<bool> DownloadArchivedMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, ArchivedEntities.ListItem? messageInfo,
|
||||
ArchivedEntities.Medium? messageMedia, CommonEntities.Author? author,
|
||||
Dictionary<string, long> users);
|
||||
Task<bool> DownloadMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string path,
|
||||
string? filenameFormat, object? postInfo, object? postMedia,
|
||||
object? author, Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadArchivedPostDRMVideo(string policy, string signature, string kvp, string url,
|
||||
Task<bool> DownloadDRMVideo(string policy, string signature, string kvp, string url,
|
||||
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, ArchivedEntities.ListItem? postInfo,
|
||||
ArchivedEntities.Medium? postMedia,
|
||||
CommonEntities.Author? author, Dictionary<string, long> users);
|
||||
IProgressReporter progressReporter, string path,
|
||||
string? filenameFormat, object? postInfo, object? postMedia,
|
||||
object? author, Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey,
|
||||
string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter,
|
||||
string filenameFormat, PostEntities.SinglePost postInfo, PostEntities.Medium postMedia,
|
||||
CommonEntities.Author author,
|
||||
Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey,
|
||||
string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter,
|
||||
string? filenameFormat, PostEntities.ListItem? postInfo, PostEntities.Medium? postMedia,
|
||||
CommonEntities.Author? author,
|
||||
Dictionary<string, long> users);
|
||||
Task<(string decryptionKey, DateTime lastModified)?> GetDecryptionInfo(
|
||||
string mpdURL, string policy, string signature, string kvp,
|
||||
string mediaId, string contentId, string drmType,
|
||||
bool clientIdBlobMissing, bool devicePrivateKeyMissing);
|
||||
|
||||
Task DownloadAvatarHeader(string? avatarUrl, string? headerUrl, string folder, string username);
|
||||
|
||||
Task<bool> DownloadMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey,
|
||||
string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter,
|
||||
string? filenameFormat, MessageEntities.ListItem? messageInfo, MessageEntities.Medium? messageMedia,
|
||||
CommonEntities.FromUser? fromUser,
|
||||
Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadMessageMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, MessageEntities.ListItem? messageInfo,
|
||||
MessageEntities.Medium? messageMedia, CommonEntities.FromUser? fromUser, Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadPostMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, PostEntities.ListItem? postInfo,
|
||||
PostEntities.Medium? postMedia,
|
||||
CommonEntities.Author? author, Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadPostMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, PostEntities.SinglePost? postInfo,
|
||||
PostEntities.Medium? postMedia,
|
||||
CommonEntities.Author? author, Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadPurchasedMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, PurchasedEntities.ListItem? messageInfo,
|
||||
MessageEntities.Medium? messageMedia,
|
||||
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,
|
||||
MessageEntities.Medium? messageMedia, CommonEntities.FromUser? fromUser, Dictionary<string, long> users);
|
||||
|
||||
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, PurchasedEntities.ListItem? messageInfo,
|
||||
MessageEntities.Medium? messageMedia,
|
||||
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,
|
||||
IProgressReporter progressReporter, string? filenameFormat, MessageEntities.SingleMessage? messageInfo,
|
||||
MessageEntities.Medium? messageMedia, CommonEntities.FromUser? fromUser, Dictionary<string, long> users);
|
||||
|
||||
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, PurchasedEntities.ListItem? postInfo,
|
||||
MessageEntities.Medium? postMedia,
|
||||
CommonEntities.FromUser? fromUser, Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadPurchasedPostMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, PurchasedEntities.ListItem? messageInfo,
|
||||
MessageEntities.Medium? messageMedia,
|
||||
CommonEntities.FromUser? fromUser, Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadStoryMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter);
|
||||
|
||||
Task<bool> DownloadStreamMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, StreamEntities.ListItem? streamInfo,
|
||||
StreamEntities.Medium? streamMedia, CommonEntities.Author? author,
|
||||
Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadStreamsDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey,
|
||||
string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter,
|
||||
string? filenameFormat, StreamEntities.ListItem? streamInfo, StreamEntities.Medium? streamMedia,
|
||||
CommonEntities.Author? author,
|
||||
Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadSingleMessagePreviewDRMVideo(string policy, string signature, string kvp, string url,
|
||||
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, MessageEntities.SingleMessage? messageInfo,
|
||||
MessageEntities.Medium? messageMedia, CommonEntities.FromUser? fromUser, Dictionary<string, long> users);
|
||||
|
||||
Task<bool> DownloadMessagePreviewMedia(string url, string folder, long media_id, string api_type,
|
||||
IProgressReporter progressReporter, string? filenameFormat, MessageEntities.SingleMessage? messageInfo,
|
||||
MessageEntities.Medium? messageMedia, CommonEntities.FromUser? fromUser, Dictionary<string, long> users);
|
||||
|
||||
Task<DownloadResult> DownloadHighlights(string username, long userId, string path, HashSet<long> paidPostIds,
|
||||
IProgressReporter progressReporter);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user