Module: PornhubApi

Defined in:
lib/pornhub_api.rb,
lib/pornhub_api/version.rb

Overview

PornhubApi client namespace

Defined Under Namespace

Classes: Error

Constant Summary collapse

BASE_URI =
URI("https://www.pornhub.com")
VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.categoriesObject

Get all categories PornhubApi.categories # => {

"categories": [
  {
    "id": "139",
    "category": "verified-models"
  }
]

}



185
186
187
# File 'lib/pornhub_api.rb', line 185

def categories
  webmasters_request("categories")
end

.is_video_active(id:, **options) ⇒ Object

Get video activeness rubocop:disable Naming/PredicateName

Example

PornhubApi.is_video_active(id: ‘ph5f59beb3df90a’) # => {

"active": {
    "video_id": "ph5f59beb3df90a",
    "is_active": "1"
}

}



169
170
171
# File 'lib/pornhub_api.rb', line 169

def is_video_active(id:, **options)
  webmasters_request("is_video_active", { id: id, **options })
end

.search(**options) ⇒ Object

Search pornhub videos

PornhubApi.search # => {

"videos": [
    {
        "duration": "11:20",
        "views": 2597,
        "video_id": "ph5e7cddd1b610e",
        "rating": "81.8182",
        "ratings": 22,
        "title": "Young babe Anna fed cum after anal banging and blowjob",
        "url": "https://www.pornhub.com/view_video.php?viewkey=ph5e7cddd1b610e",
        "default_thumb": "https://di.phncdn.com/videos/202003/26/296992831/original/(m=eaf8Ggaaaa)",
        "thumb": "https://di.phncdn.com/videos/202003/26/296992831/original/(m=eaf8Ggaaaa)13.jpg",
        "publish_date": "2020-12-26 12:10:17",
        "thumbs": [
            {
                "size": "320x240",
                "width": "320",
                "height": "240",
                "src": "https://di.phncdn.com/videos/202003/26/296992831/original/(mh=_Tyqk2i6XofP-YRe)1.jpg"
            }
        ],
        "tags": [
            { "tag_name": "hotbabes4k" }
        ],
        "pornstars": [
           { "pornstar_name": "Sheena Ryder" }
        ],
        "categories": [
            { "category": "babe" },
        ],
        "segment": "straight"
    },
]

}

Options Hash (**options):

  • :search (String)

    Search query

  • :page (Integer)

    Page number

  • :thumbsize (String)

    Possible values are small, medium, large, small_hd, medium_hd, large_hd

  • :category (String)

    The subject

  • :ordering (String)

    Possible values are featured, newest, mostviewed and rating

  • :phrase (Array)

    Used as pornstars filter.

  • :tags (Array)

    The email’s body

  • :period (String)

    Works ith ordering Possible values are weekly, monthly, and alltime



64
65
66
# File 'lib/pornhub_api.rb', line 64

def search(**options)
  webmasters_request("search", options)
end

.starsObject

Get pornstars list

Example

PornhubApi.stars # => {

"stars": [
    {
        "star": {
            "star_name": " Vixxen Goddess"
        }
    }
]

}



82
83
84
# File 'lib/pornhub_api.rb', line 82

def stars
  webmasters_request("stars")
end

.stars_detailedObject

Get detailed pornstars list

Example

PornhubApi.stars_detailed # => {

"stars": [
    {
        "star": {
            "star_name": " Melisa Wide",
            "star_thumb": "https://di.phncdn.com/pics/pornstars/default/(m=lciuhScOb_c)female.jpg",
            "star_url": "https://www.pornhub.com/pornstar/videos_overview?pornstar=melisa-wide",
            "gender": "female",
            "videos_count_all": "0"
        }
    },
]

}



104
105
106
# File 'lib/pornhub_api.rb', line 104

def stars_detailed
  webmasters_request("stars_detailed")
end

.tags(list:) ⇒ Object

Get all tags by first char PornhubApi.tags(list: ‘a’) # =>

"warning": "We had to change the response structure due to high amount of tags. Please adjust your code",
"tagsCount": 283196,
"tags": [
  "płąnący",
  "płaska",
  "płaszcz",
  "płaszczyk",
  "pławska",
  "płock",
  "płonę"
]



206
207
208
# File 'lib/pornhub_api.rb', line 206

def tags(list:)
  webmasters_request("tags", { list: list })
end

.video_by_id(id:, **options) ⇒ Object

Get video by id

Example

PornhubApi.video_by_id(id: ‘ph5f59beb3df90a’) # => {

"video": {
  "duration": "0:04",
  "views": 2,
  "video_id": "ph5f59beb3df90a",
  "rating": 0,
  "ratings": 0,
  "title": "Dick stroke",
  "url": "https://www.pornhub.com/view_video.php?viewkey=ph5f59beb3df90a",
  "default_thumb": "https://ei.phncdn.com/videos/202009/10/350564541/original/(m=eaf8Ggaaaa)12.jpg",
  "thumb": "https://ei.phncdn.com/videos/202009/10/350564541/original/(m=eaf8Ggaaaa)13.jpg",
  "publish_date": "2020-12-26 22:44:47",
  "thumbs": [
    {
      "size": "320x240",
      "width": "320",
      "height": "240",
      "src": "https://ei.phncdn.com/videos/202009/10/350564541/original/(m=eaf8Ggaaaa)15.jpg"
    }
  ],
  "tags": [
    {
      "tag_name": "big cock"
    }
  ],
  "pornstars": [],
  "categories": [
    {
      "category": "amateur"
    }
  ],
  "segment": "straight"
}

}

Options Hash (**options):

  • thumbsize (String)

    Possible values are small, medium, large, small_hd, medium_hd, large_hd



151
152
153
# File 'lib/pornhub_api.rb', line 151

def video_by_id(id:, **options)
  webmasters_request("video_by_id", { id: id, **options })
end