• Stars
    star
    394
  • Rank 109,295 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 8 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Unofficial API for PornHub.com in Python

PornHub Unofficial API

Unofficial API for pornhub.com in Python

Pull requests are welcome!!!

I find it quite difficult to make time for an active development on this project, so I will be more than happy to merge your pull requests. Thank you all for supporting this project!

Install

pip3 install pornhubapi

How to use

Create client

import pornhub
client = pornhub.PornHub()

Create client with proxy

import pornhub
# With proxy, given a Proxy IP and Port. For the countries with restricted access like Turkey, etc.
client = pornhub.PornHub("5.135.164.72", 3128)

Grab stars

The request can be sorted by: view, trend, subs, alpha, videos, random

for star in client.getStars(10, sort_by="view"):
    print(star)
    print(star["name"])

Create client with search keywords

keywords = ["word1", "word2"]
client = pornhub.PornHub(keywords)

# if using a proxy
client = pornhub.PornHub(keywords, "5.135.164.72", 3128)
# or
client = pornhub.PornHub(ProxyIP="5.135.164.72", ProxyPort=3128, keywords=["word1", "word2"])

for video in client.getVideos(10, page=2):
    print(video)
    print(video["url"])

Sort Video by parameter

When keywords are set: view, rate, long, recent

keywords = ["word1", "word2"]
client = pornhub.PornHub(keywords)

for video in client.getVideos(10, page=2, sort_by="long"):
    print(video)
    print(video["url"])

When keywords are not set: view, rate, long, new, hot

client = pornhub.PornHub()

for video in client.getVideos(10, page=2, sort_by="hot"):
    print(video)
    print(video["url"])

Take full information about all videos

Parameter full_data allows you to get complete information about the video, but its much more slower due to every page needs to be opened

keywords = ["word1", "word2"]
client = pornhub.PornHub(keywords)

for video in client.getVideos(10, page=2, full_data=True):
  print(video)
  print(video["upload_date"])

Get more information about the single video

Method getVideo(url, viewkey) gives more detail information about a single video

client = pornhub.PornHub()

# You can input the full video url, like that
video = client.getVideo("https://www.pornhub.com/view_video.php?viewkey=SOMEKEY")
# Or that
video = client.getVideo(url="https://www.pornhub.com/view_video.php?viewkey=SOMEKEY")
# Or input only viewkey, like that
video = client.getVideo(viewkey="SOMEKEY")

print(video)
print(video["title"])

The method return a dictionary with keywords:

  1. title (type: string) - Video title
  2. views (type: string) - Rounded number of views, for example "2M"
  3. accurate_views (type: integer) - Full number of views, for example "123456789". When video don't have many views views=accurate_views
  4. rating (type: integer) - Video rating in percent
  5. duration (type: string) - Video duration in format "hh:mm:ss"
  6. loaded (type: string) - When the video was uploaded, for example "2 months ago"
  7. upload_date (type: string) - Video upload date in format "yyyy-mm-dd"
  8. likes (type: string) - Similar like views
  9. accurate_likes (type: integer) - Similar like accurate_views
  10. dislikes (type: string) - Similar like views
  11. accurate_dislikes (type: integer) - Similar like accurate_views
  12. favorite (type: string) - How many times added to favorites, rounded. For example "2K"
  13. author (type: string) - Video author (channel)
  14. pornstars (type: list) - Video stars
  15. categories (type: list) - Video categories
  16. tags (type: list) - Video tags
  17. production (type: string) - Video production (Professional or Homemade)
  18. url (type: string) - URL to Video
  19. img_url (type: string) - URL to Preview Image of Video
  20. embed_url (type: string) - URL to Video Player

If the video is not available in your country, in title will "Video not available in your country", in others keys will None

Contributors


SashaSZ


Ibrahim Ipek


Kittinan


Елизаров Роман Русланович


IThinkImOKAY

License

MIT license

More Repositories

1

stable-farm

Automatically moving stable coins between decentralized finance platforms seeking for maximum yield
Solidity
26
star
2

nextcloud-docker

Full Nextcloud docker-compose with nginx proxy, letsencrypt, redis, mail server and turn server
Dockerfile
8
star
3

ADS

Algorithms and Data Structures implemented in C
C
6
star
4

wordpress-docker

Scalable Wordpress on Docker swarm
4
star
5

docker-swarm-demo

Docker swarm deployment demo with Nginx as front load balancer
Dockerfile
4
star
6

web3-dev-docker

Docker image for starting with Ethereum Web3.js
Dockerfile
3
star
7

mariadb-phpmyadmin-docker

docker-compose for painless setup of mariadb and phpmyadmin panel
2
star
8

analysis-of-massive-datasets

Analysis of Massive Datasets FER labs
Python
2
star
9

dapp-vue-starter

Starter kit for developing decentralized applications on Ethereum with Vue.js front-end
JavaScript
2
star
10

machines

Various Docker containers
Python
2
star
11

programming-language-translation

Programming Language Translation FER labs
Python
2
star
12

introduction-to-data-science-labs

Introduction to Data Science FER labs
Jupyter Notebook
2
star
13

automata-theory

Introduction to automata theory, languages and computation
Python
1
star
14

ASCIIcalc

Calculating with numbers in ASCII art
C
1
star
15

npo-dao

Proof of concept for running a nonprofit organization on Ethereum blockchain
JavaScript
1
star
16

postgres-pgadmin-docker

docker-compose for painless setup of postgresql and pgadmin panel
Shell
1
star
17

advent-of-code

Solutions to Advent of Code
Python
1
star
18

nodejs-backend-starter

Starter kit for developing backend with Node.js
JavaScript
1
star
19

zshrc

zsh & ohmyzsh configuration
Shell
1
star
20

delish-scraper

Scrape recipes from www.delish.com
JavaScript
1
star
21

altcoin-mxe

Docker image with MXE tools required to build altcoins (boost1.58, qt5, db5.3, miniupnpc-1.6, libqrencode-4.0.2, openssl-1.0)
Dockerfile
1
star
22

trackingfriends-android

Tracking friends location Android app
Kotlin
1
star
23

java-basics

Java basics in a nutshell
Java
1
star
24

hackerrank

HackerRank solutions
C++
1
star
25

calendar-app

Simple calendar web app in React.js and Firebase
JavaScript
1
star
26

advanced-operating-systems

Advanced Operating Systems FER labs
C
1
star
27

AADS

Advanced Algorithms and Data Structures FER labs
Python
1
star