Skip to content

Commit

Permalink
feat: add onlyfans
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Oct 1, 2024
1 parent bab8263 commit 1786657
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
6 changes: 6 additions & 0 deletions public/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ It resolves user avatar using **microlink.io**.

e.g., https://unavatar.io/microlink/microlink.io

### OnlyFans

It resolves user avatar using **onlyfans.com**.

e.g., https://unavatar.io/onlyfans/amandaribas

### Read.cv

Type: `username`
Expand Down
3 changes: 2 additions & 1 deletion src/providers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const providers = {
// tiktok: require('./tiktok'),
twitch: require('./twitch'),
x: require('./x'),
youtube: require('./youtube')
youtube: require('./youtube'),
onlyfans: require('./onlyfans')
}

const providersBy = reduce(
Expand Down
26 changes: 26 additions & 0 deletions src/providers/onlyfans.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict'

const PCancelable = require('p-cancelable')
const cheerio = require('cheerio')

const getHTML = require('../util/html-get')

module.exports = PCancelable.fn(async function onlyfans ({ input }, onCancel) {
const promise = getHTML(`https://onlyfans.com/${input}`, {
prerender: true,
puppeteerOpts: { abortTypes: ['other', 'image', 'font'] }
})
onCancel(() => promise.onCancel())
const { html } = await promise
const $ = cheerio.load(html)
const json = JSON.parse(
$('script[type="application/ld+json"]').contents().text()
)
return json.mainEntity.image
})

module.exports.supported = {
email: false,
username: true,
domain: false
}

0 comments on commit 1786657

Please sign in to comment.