Class: Onlyfans::Resources::Media

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyfans/resources/media.rb,
lib/onlyfans/resources/media/vault.rb,
lib/onlyfans/resources/media/uploads.rb,
lib/onlyfans/resources/media/vault/lists.rb,
lib/onlyfans/resources/media/vault/lists/media.rb

Defined Under Namespace

Classes: Uploads, Vault

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Media

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Media.

Parameters:



125
126
127
128
129
# File 'lib/onlyfans/resources/media.rb', line 125

def initialize(client:)
  @client = client
  @uploads = Onlyfans::Resources::Media::Uploads.new(client: client)
  @vault = Onlyfans::Resources::Media::Vault.new(client: client)
end

Instance Attribute Details

#uploadsOnlyfans::Resources::Media::Uploads (readonly)



7
8
9
# File 'lib/onlyfans/resources/media.rb', line 7

def uploads
  @uploads
end

#vaultOnlyfans::Resources::Media::Vault (readonly)



10
11
12
# File 'lib/onlyfans/resources/media.rb', line 10

def vault
  @vault
end

Instance Method Details

#download(cdn_url, account:, request_options: {}) ⇒ String

Some parameter documentations has been truncated, see Models::MediaDownloadParams for more details.

Downloads a file directly from a ‘cdn*.onlyfans.com/*` URL. When the file is already cached on our CDN, this endpoint returns a `302` redirect to a `cdn.fansapi.com/*` URL. Most HTTP clients follow redirects automatically (`curl` requires `-L`). Otherwise, the file is streamed through our proxies and queued for caching.

expire

Parameters:

  • cdn_url (String)

    Optional parameter. The CDN URL to scrape. **Keep in mind that these URLs

  • account (String)

    The Account ID

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (String)

See Also:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/onlyfans/resources/media.rb', line 33

def download(cdn_url, params)
  parsed, options = Onlyfans::MediaDownloadParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/%1$s/media/download/%2$s", , cdn_url],
    headers: {"accept" => "text/plain"},
    model: String,
    options: options
  )
end

#scrape(account, expiration_date: nil, file_type: nil, media_id: nil, public: nil, url: nil, request_options: {}) ⇒ Onlyfans::Models::MediaScrapeResponse

Some parameter documentations has been truncated, see Models::MediaScrapeParams for more details.

**⚠️ This is a deprecated endpoint. Please use the new “Download media from the OnlyFans CDN” endpoint!** Scrapes a ‘cdn*.onlyfans.com/*` URL or Vault Media ID, and uploads it to the OnlyFans API CDN, where you can view or download the file. **Max file size is 500MB**

Parameters:

  • account (String)

    The Account ID

  • expiration_date (String, nil)

    The expiration date of our returned ‘temporary_url`. Default of 5 minutes. Must

  • file_type (Symbol, Onlyfans::Models::MediaScrapeParams::FileType, nil)

    The file type to scrape. Only allowed when using ‘media_id`.

  • media_id (Integer, nil)

    The OnlyFans Vault Media ID. **Can be used instead of the ‘url`.**

  • public (Boolean, nil)

    Set to true if you want to have the file uploaded to our public CDN (no signed U

  • url (String, nil)

    The CDN URL to scrape. **Keep in mind that these URLs expire fast.**

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



75
76
77
78
79
80
81
82
83
84
# File 'lib/onlyfans/resources/media.rb', line 75

def scrape(, params = {})
  parsed, options = Onlyfans::MediaScrapeParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/%1$s/media/scrape", ],
    body: parsed,
    model: Onlyfans::Models::MediaScrapeResponse,
    options: options
  )
end

#upload(account, async: nil, file: nil, file_url: nil, type: nil, request_options: {}) ⇒ Onlyfans::Models::MediaUploadResponse

Some parameter documentations has been truncated, see Models::MediaUploadParams for more details.

The response can be used **only once** to manually include media in a post or message. This endpoint does not upload media to the Vault. You must provide either ‘file` or `file_url`.

Parameters:

  • account (String)

    The Account ID

  • async (Boolean)

    Set to ‘true` to process uploads in the background. Returns a `polling_url` to c

  • file (Pathname, StringIO, IO, String, Onlyfans::FilePart)

    The file to upload. Required if ‘file_url` is not provided. Maximum file size: 1

  • file_url (String)

    A URL to download the file from. Required if ‘file` is not provided. Maximum fil

  • type (Symbol, Onlyfans::Models::MediaUploadParams::Type)

    Set to ‘avatar` if this file will be used as a profile picture, `header` for a p

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/onlyfans/resources/media.rb', line 110

def upload(, params = {})
  parsed, options = Onlyfans::MediaUploadParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/%1$s/media/upload", ],
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: Onlyfans::Models::MediaUploadResponse,
    options: options
  )
end