commit
a8ee5e9648
|
|
@ -0,0 +1,77 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func fileExists(path string) bool {
|
||||||
|
_, err := os.Stat(path)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
//needs changing to actual
|
||||||
|
paidMessageValue := "https://cdn3.onlyfans.com/dash/files,..."
|
||||||
|
paidMessageKey := "mediaId123"
|
||||||
|
path := "/path/to/download"
|
||||||
|
task := "download-task"
|
||||||
|
deviceFolder := "/path/to/device"
|
||||||
|
deviceName := "default"
|
||||||
|
hasSelectedUsers := true
|
||||||
|
|
||||||
|
clientIdBlobMissing := !fileExists(fmt.Sprintf("%s/%s/device_client_id_blob", deviceFolder, deviceName))
|
||||||
|
devicePrivateKeyMissing := !fileExists(fmt.Sprintf("%s/%s/device_private_key", deviceFolder, deviceName))
|
||||||
|
|
||||||
|
if strings.Contains(paidMessageValue, "cdn3.onlyfans.com/dash/files") {
|
||||||
|
parts := strings.Split(paidMessageValue, ",")
|
||||||
|
if len(parts) < 6 {
|
||||||
|
fmt.Println("Invalid media info string.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mpdURL := parts[0]
|
||||||
|
policy := parts[1]
|
||||||
|
signature := parts[2]
|
||||||
|
kvp := parts[3]
|
||||||
|
mediaId := parts[4]
|
||||||
|
messageId := parts[5]
|
||||||
|
|
||||||
|
pssh, err := GetDRMMPDPSSH(mpdURL, policy, signature, kvp)
|
||||||
|
if err != nil || pssh == "" {
|
||||||
|
fmt.Println("Failed to get PSSH")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
lastModified, _ := GetDRMMPDLastModified(mpdURL, policy, signature, kvp)
|
||||||
|
|
||||||
|
drmHeaders := GetDynamicHeaders(fmt.Sprintf("/api2/v2/users/media/%s/drm/message/%s", mediaId, messageId), "?type=widevine")
|
||||||
|
|
||||||
|
var decryptionKey string
|
||||||
|
if clientIdBlobMissing || devicePrivateKeyMissing {
|
||||||
|
decryptionKey, err = GetDecryptionKeyOFDL(drmHeaders, fmt.Sprintf("https://onlyfans.com/api2/v2/users/media/%s/drm/message/%s?type=widevine", mediaId, messageId), pssh)
|
||||||
|
} else {
|
||||||
|
decryptionKey, err = GetDecryptionKeyCDM(drmHeaders, fmt.Sprintf("https://onlyfans.com/api2/v2/users/media/%s/drm/message/%s?type=widevine", mediaId, messageId), pssh)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Failed to get decryption key:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = DownloadPurchasedMessageDRMVideo(mpdURL, decryptionKey, path)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Failed to download DRM video:", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Simulated. needs changing for our needs
|
||||||
|
mediaInfo := "media-metadata"
|
||||||
|
messageInfo := "message-metadata"
|
||||||
|
|
||||||
|
err := DownloadPurchasedMedia(paidMessageValue, path, paidMessageKey, "Messages", task, "filenameFormat", messageInfo, mediaInfo, hasSelectedUsers)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Failed to download regular media:", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue