Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Egsago-n committed Mar 20, 2024
1 parent ff6d2b5 commit 071b589
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 227 deletions.
5 changes: 5 additions & 0 deletions build-docs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/sh

py -3.11 -m pip install sphinx
py -3.11 -m pip install -r docs/source/requirements.txt
py -3.11 -m sphinx.cmd.build -b html docs/source build/
2 changes: 0 additions & 2 deletions docs/source/api/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@ PHUB can raise the following expressions.

.. autoexception:: phub.errors.InvalidCategory

.. autoexception:: phub.errors.InvalidSortParam

.. autoexception:: phub.errors.VideoError
1 change: 0 additions & 1 deletion docs/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ For more details, you can also have a look at the `source code`_.

objects
errors
locals
utils
43 changes: 0 additions & 43 deletions docs/source/api/locals.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs/source/api/objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ Here is a list of all API objects.
:members:
:private-members:

.. autoclass:: phub.objects.Param
:members:
:private-members:

.. autoclass:: phub.objects.Query
:members:
:private-members:
Expand Down
4 changes: 0 additions & 4 deletions docs/source/api/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ Maybe they can be helpful to you too.

.. autofunction:: phub.utils.closest

.. autofunction:: phub.utils.make_constant

.. autofunction:: phub.utils.update_locals

.. autofunction:: phub.utils.serialize

.. autofunction:: phub.utils.dictify
Expand Down
21 changes: 0 additions & 21 deletions docs/source/features/account.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,6 @@ Here is an example on how to view your account history.
for i, video in enumerate(client.account.watched):
print(f'{i}. [{video.key}] "{video.title}"')
.. warning::

**For PHUB 4.2 and below**,
Pornhub videos are not excluded from being deleted by their creators.
These videos still exist and have a key and a title, but accessing video data
will raise errors. If you are iterating videos (e.g. your history), you
can ignore these videos by using ``phub.utils.suppress``.

.. code-block:: python
import phub
from phub.utils import suppress
client = phub.Client('my-username', 'my-password')
for video in suppress(client.account.watched):
# Access data that requires a page load
print(video.tags)
**For version 4.3 and upper**, the videos are automatically suppressed.

Accessing the feed
------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/source/features/feed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You can also specify custom feed filters:
comments_feed = client.account.feed.filter(
user = 'my-user', # Filter notifications from a specific user name or object
section = Section.COMMENTS # Or any other section type
section = 'comments' # Or any other section type
)
# Print the first 10 feed news
Expand Down
42 changes: 16 additions & 26 deletions docs/source/features/search.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,31 @@ You can easily perform a research on Pornhub with :meth:`.Client.search`.
Search filters
--------------

You can specify search filters by adding :py:class:`.Param` objects.
There is a list of constant Parameters you can import from ``phub.locals``.
You can see :doc:`here </api/locals>` a list of possible filters.
You can specify a lot of parameters to restrict your search.

.. code-block:: python
import phub
from phub.locals import *
client = phub.Client()
query = client.search('my query', Category.FRENCH)
query = client.search('my query', category = 'french')
For instance, this query will be restrained to search in the French category.

You can use multiple Parameters objects by adding or subtracting them, e.g.:

.. warning::

As of now, Pornhub only supports searching in one Category at a time.
But you can still exclude as many as you want!

.. code-block:: python
# Search in the French category for homemade production
client.search(..., Category.FRENCH | Production.HOMEMADE)
# Search for professional production, but exclude all BBW videos
client.search(..., Production.PROFESSIONAL - Category.BBW)
# Search for everything but BBW
client.search(..., -Category.BBW)
client.search(
...,
category = 'french',
exclude_category = ('bbw', 'german'),
production = 'homemade'
)
Using queries
-------------
Expand Down Expand Up @@ -71,26 +65,22 @@ For more in-depth iteration, you can use the sample method.
# Fetch only non watched
for video in query.sample(watched = False):
print(video.title)
# Fetch by pages
for page in video.pages:
print(page)
To exploit video data, see :doc:`here </features/video>`.

Using different Query types while searching
-------------------------------------------

With searching only, you can choose to use 2 different queries subclasses.
You should choose which one to use depending on what you want to do.
Alternatively, you can use the HubTraffic API from Pornhub.
It is faster and more reliable, but provides less information.

.. code-block:: python
# Uses a JSONQuery (recommended) - faster and 'pornhub approved', but less data
query = client.search(..., use_hubtraffic = True)
# Uses a VideoQuery - slower, but fetches all of the video data
query = client.search(..., use_hubtraffic = False)
.. note::

To access others properties from a JSONQuery, see the warning on :doc:`Using videos </features/video>`.
query = client.search_hubtraffic(...)
Refreshing queries
------------------
Expand All @@ -104,7 +94,7 @@ to initialise a new query.
args = dict(
query = 'my query',
filter = Category.FRENCH # Or/and any filter you want
category = 'french'
# Other parameters if you want
)
Expand Down
50 changes: 4 additions & 46 deletions docs/source/features/user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Users

:py:class:`.User` objects represents Pornhub users.

.. note:: There is a difference between Users and
.. important:: There is a difference between Users and
Account objects. :doc:`Accounts </features/account>` represents *your*
account connected via PHUB.

Expand Down Expand Up @@ -44,53 +44,11 @@ You can search for user accounts on the platform using :meth:`.Client.search_use
members = client.search_user(
username = 'user',
param = (Sort.USER_NEWEST
| Member.IS_ONLINE
| Member.HAS_AVATAR
| Member.OPEN_RELATION
| Member.GENDER_NON_BINARY)
sort = 'newest',
online = True,
gender = 'non binary'
)
This method behaves like :meth:`.Client.search`: you can select custom filters for the
query.
You can learn more about PHUB queries :doc:`here </features/search>`.

.. code-block:: python
# Member type
Member.IS_MODEL
Member.IS_STAFF
Member.IS_ONLINE
# Member content
Member.HAS_AVATAR
Member.HAS_VIDEOS
Member.HAS_PHOTOS
Member.HAS_PLAYLISTS
Member.OFFER_FAN_CLUB
Member.OFFER_CUSTOM_VIDEOS
# Member relationship
Member.SINGLE
Member.TAKEN
Member.OPEN_RELATION
# Member gender
Member.GENDER_MALE
Member.GENDER_FEMALE
Member.GENDER_COUPLE
Member.GENDER_TRANS_FEMALE
Member.GENDER_FEMALE_COUPLE
Member.GENDER_TRANS_MALE
Member.GENDER_NON_BINARY
Member.GENDER_OTHER
# Member interests
Member.INTO_NONE
Member.INTO_MALE
Member.INTO_FEMALE
Member.INTO_ALL
# You can also use these sort filters
Sort.USER_POPULAR # Alongside with a sort period like SORT.week
Sort.USER_NEWEST
10 changes: 5 additions & 5 deletions docs/source/features/video.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ You can use the following properties on a video:
- List of video tags. Each tag is represented as a :py:class:`.Tag` object.

* - :literal:`video.like`
- Votes representation as a :py:class:`.Like`object.
- Votes representation as a :py:class:`.Like` object.

* - :literal:`video.views`
- The video views (:py:class:`int`).
Expand All @@ -53,7 +53,7 @@ You can use the following properties on a video:
- Pornstars in the video, represented as a list of :py:class:`.User` objects.

* - :literal:`video.categories`
- The video categories. Represented as a :py:class:`.Category` generator.
- The video categories.

* - :literal:`video.author`
- The user account that posted the video, as a :py:class:`.User` object.
Expand All @@ -62,13 +62,13 @@ You can use the following properties on a video:
- The video internal id. Most likely to be used in Pornhub's databases.

* - :literal:`video.watched`
- Whether the video has been watched by the client.
- Whether the video has been watched by the client (Will not work in some cases).

* - :literal:`video.is_free_premium`
- Whether the video is part of Pornhub free premium plan.
- Whether the video is part of Pornhub free premium plan (Will not work in some cases).

* - :literal:`video.preview`
- The small preview you see when hovering a video, as a :py:class:`.Image` object.
- The small preview you see when hovering a video, as a :py:class:`.Image` object (Will not work in some cases).

* - :literal:`video.is_favorite`
- Whether the video is set a favorite by the client.
Expand Down
Loading

0 comments on commit 071b589

Please sign in to comment.