-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7cd4ac5
Showing
29 changed files
with
3,402 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Upload a Python Package using Twine | ||
|
||
name: Upload to PYPI | ||
|
||
on: workflow_dispatch | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build | ||
- name: Build package | ||
run: python -m build | ||
- name: Publish package | ||
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test.py | ||
src/test.py | ||
build/ | ||
build/* | ||
docs/build/ | ||
docs/build/* | ||
build.bat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
|
||
build: | ||
os: ubuntu-22.04 | ||
tools: | ||
python: "3.11" | ||
|
||
python: | ||
install: | ||
- requirements: docs/source/requirements.txt | ||
- requirements: requirements.txt |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
![PHUB](https://github.com/Egsagon/PHUB/blob/master/assets/banner.png) | ||
|
||
# PHUB 4.0 for python 3.9 | ||
|
||
Same as the master PHUB, but supports older python versions. | ||
|
||
## License | ||
|
||
PHUB uses GPLv3. See the `LICENSE` file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# PHUB - An API wrapper for PornHub. | ||
|
||
PHUB is an hybrid API for Pornhub. It is able to communicate with Pornhub | ||
using both web-scraping and Pornhub's HubTraffic API. It is | ||
able to access most used or useful PH features, such as video searching, | ||
accessing account features, video downloading, and a lot more. | ||
|
||
Learn more on the project [documentation](https://phub.readthedocs.io) and | ||
[github page](https://github.com/Egsagon/PHUB). | ||
|
||
## Installation | ||
|
||
```sh | ||
pip install --upgrade phub | ||
``` | ||
|
||
## Quickstart | ||
|
||
```python | ||
import phub | ||
|
||
client = phub.Client() | ||
|
||
video = client.get(url = '...') | ||
video.download('my-video.mp4', quality = 'best') | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[project] | ||
name = "phub" | ||
version = "4.0-3.9" | ||
description = "An API for Pornhub" | ||
authors = [{name = "Egsagon", email = "[email protected]"}] | ||
license = {file = "LICENSE"} | ||
readme = {file = "pypi.md", content-type = "text/markdown"} | ||
keywords = ["pornhub", "api", "web scrapper", "api wrapper"] | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Programming Language :: Python" | ||
] | ||
dependencies = ["requests"] | ||
requires-python = ">=3.9" | ||
|
||
[project.optional-dependencies] | ||
cli = ["click"] | ||
|
||
[project.urls] | ||
Documentation = "https://phub.readthedocs.io" | ||
Repository = "https://github.com/Egsagon/PHUB" | ||
|
||
[build-system] | ||
requires = ["setuptools", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["src"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
requests>=2.28.1 | ||
click>=8.0.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from setuptools import setup | ||
|
||
if __name__ == "__main__": | ||
setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
''' | ||
PHUB v4.0.0 | ||
See github.com/Egsagon/PHUB for docs. | ||
''' | ||
|
||
__all__ = ['Client', 'Quality', 'core', 'utils', 'consts', 'errors'] | ||
|
||
# Shortcuts | ||
from .core import Client | ||
from .locals import Quality | ||
|
||
from . import core | ||
from . import utils | ||
from . import consts | ||
from . import errors | ||
|
||
from .objects import * | ||
from .modules import * | ||
|
||
# EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
''' | ||
PHUB 4 CLI. | ||
Contains a bunch of features | ||
that can be accessed quickly. | ||
''' | ||
|
||
import phub | ||
import click | ||
import getpass | ||
|
||
@click.group() | ||
def cli(): pass | ||
|
||
@cli.command() | ||
@click.argument('entry') | ||
@click.option('--quality', '-q', help = 'Video quality', default = 'best') | ||
@click.option('--output', '-o', help = 'Output video file', default = '.') | ||
def download(entry: str, quality: str, output: str) -> None: | ||
''' | ||
Download a specific video. | ||
''' | ||
|
||
client = phub.Client() | ||
|
||
urls = [entry] | ||
if entry.endswith('.txt'): | ||
with open(entry, 'r') as file: | ||
urls = file.read().split() | ||
|
||
for url in urls: | ||
video = client.get(url) | ||
print(f'Downloading video \033[92m{video.key}\033[0m') | ||
video.download(output, quality) | ||
|
||
@cli.command() | ||
@click.argument('query') | ||
@click.option('--pages', '-p', help = 'Pages to search', default = '1') | ||
def search(query: str, pages: str) -> None: | ||
''' | ||
Search for videos. | ||
''' | ||
|
||
client = phub.Client() | ||
|
||
q = client.search(query) | ||
|
||
for i in range(int(pages) * 32): | ||
|
||
video = q[i] | ||
print(f'* \033[93m{video.title}\033[0m ({video.duration}) - {video.key}') | ||
|
||
def init_pass_client(user: str = None) -> phub.Client: | ||
''' | ||
Get credentials and load a client | ||
''' | ||
|
||
if not user: user = input('Username: ') | ||
password = getpass.getpass() | ||
return phub.Client(user, password) | ||
|
||
@cli.command() | ||
@click.option('-n', help = 'Video count', default = '1') | ||
@click.option('-o', '--output', help = 'Output dir', default = '.') | ||
@click.option('-u', '--user', help = 'Account username') | ||
@click.option('-q', '--quality', help = 'Video quality', default = 'best') | ||
def watched(n: str, output: str, user: str, quality: str) -> None: | ||
''' | ||
Download the n-last watched videos. | ||
''' | ||
client = init_pass_client(user) | ||
q = client.account.watched | ||
|
||
for i in range(int(n)): | ||
|
||
video = q[i] | ||
|
||
video.download(output, quality, display = phub.display.bar(f'Downloading {video.key}')) | ||
|
||
@cli.command() | ||
@click.option('-n', help = 'Video count', default = '1') | ||
@click.option('-o', '--output', help = 'Output dir', default = '.') | ||
@click.option('-u', '--user', help = 'Account username') | ||
@click.option('-q', '--quality', help = 'Video quality', default = 'best') | ||
def liked(n: str, output: str, user: str, quality: str) -> None: | ||
''' | ||
Download the n-last watched videos. | ||
''' | ||
|
||
client = init_pass_client(user) | ||
q = client.account.liked | ||
|
||
for i in range(int(n)): | ||
|
||
video = q[i] | ||
|
||
video.download(output, quality, display = phub.display.bar(f'Downloading {video.key}')) | ||
|
||
@cli.command() | ||
@click.argument('user') | ||
@click.option('-n', help = 'Video count') | ||
@click.option('-o', '--output', help = 'Output dir', default = '.') | ||
@click.option('-q', '--quality', help = 'Video quality', default = 'best') | ||
def user_videos(user: str, n: str, output: str, quality: str) -> None: | ||
''' | ||
Download the n last videos from a channel/model/etc. | ||
''' | ||
|
||
client = phub.Client() | ||
user = client.get_user(user) | ||
|
||
for i, video in enumerate(user.videos[:n]): | ||
|
||
video.download(output, quality, display = phub.display.bar(f'#{i}')) | ||
|
||
@cli.command() | ||
def update_locals() -> None: | ||
''' | ||
Update PHUB locals that depends on PH. | ||
''' | ||
|
||
phub.utils.update_locals() | ||
|
||
if __name__ == '__main__': | ||
cli() | ||
|
||
# EOF |
Oops, something went wrong.