Skip to content

Commit

Permalink
- proxy support (See Documentation)
Browse files Browse the repository at this point in the history
- updated to eaf_base_api v2
- written tests for search and user objects
- removed headers, cuz they were broken
- type hinting
  • Loading branch information
EchterAlsFake committed Jan 1, 2025
1 parent 51e8f60 commit f4c0155
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 66 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ XNXX API is an API for xnxx.com. It allows you to fetch information from videos


```python
from xnxx_api import Client, Quality, threaded, default, FFMPEG
from xnxx_api import Client
# Initialize a Client object
client = Client()

Expand All @@ -37,7 +37,7 @@ print(video_object.title)
print(video_object.likes)
# Download the video

video_object.download(downloader=threaded, quality=Quality.BEST, path="your_output_path + filename")
video_object.download(downloader="threaded", quality="best", path="your_output_path + filename")

# SEE DOCUMENTATION FOR MORE
```
Expand All @@ -48,6 +48,17 @@ video_object.download(downloader=threaded, quality=Quality.BEST, path="your_outp
# Changelog
See [Changelog](https://github.com/EchterAlsFake/xnxx_api/blob/master/README/Changelog.md) for more details.

# Support (Donations)
I am developing all my projects entirely for free. I do that because I have fun and I don't want
to charge 30€ like other people do.

However, if you find my work useful, please consider donating something. A tiny amount such as 1€
means a lot to me.

Paypal: https://paypal.me/EchterAlsFake
<br>XMR (Monero): `46xL2reuanxZgFxXBBaoagiEJK9c7bL7aiwKNR15neyX2wUsX2QVzkeRMVG2Cro44qLUNYvsP1BQa12KPbNat2ML41nyEeq`


# Contribution
Do you see any issues or having some feature requests? Simply open an Issue or talk
in the discussions.
Expand All @@ -56,5 +67,4 @@ Pull requests are also welcome.

# License
Licensed under the LGPLv3 License

Copyright (C) 2023–2024 Johannes Habel
<br>Copyright (C) 2023–2025 Johannes Habel
9 changes: 8 additions & 1 deletion README/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,11 @@
- fixed an issue with video loading

# 1.4.1
- added support for mode searching #2
- added support for mode searching #2

# 1.4.0
- proxy support (See Documentation)
- updated to eaf_base_api v2
- written tests for search and user objects
- removed headers, cuz they were broken
- type hinting
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="xnxx_api",
version="1.4.3",
version="1.5.0",
packages=find_packages(),
install_requires=[
"requests", "bs4", "lxml", "ffmpeg-progress-yield", "eaf_base_api"
Expand Down
4 changes: 2 additions & 2 deletions xnxx_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# xnxx_api/__init__.py

__all__ = [
"Client", "Core", "Quality", "Video", "Callback", "threaded", "default", "FFMPEG",
"Client", "BaseCore", "Video", "Callback",
"errors", "consts", "search_filters", "category"
]

# Public API from xnxx_api.py
from xnxx_api.xnxx_api import Client, Core, Quality, Video, Callback, threaded, default, FFMPEG
from xnxx_api.xnxx_api import Client, BaseCore, Video, Callback
from xnxx_api.modules import errors, consts, category, search_filters
17 changes: 0 additions & 17 deletions xnxx_api/modules/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,6 @@
# ROOT URLs
ROOT_URL = "https://www.xnxx.com/"

HEADERS = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Language": "en-US,en;q=0.9",
"Accept-Encoding": "gzip, deflate, br",
"DNT": "1", # Do Not Track request header
"Connection": "keep-alive",
"Upgrade-Insecure-Requests": "1",
"Sec-Fetch-Site": "none",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-User": "?1",
"Sec-Fetch-Dest": "document",
"Host": "www.xnxx.com",
"Referer": "https://www.xnxx.com"
}


# REGEX
REGEX_VIDEO_CHECK = re.compile(r"xnxx.com/(.*?)")
REGEX_VIDEO_TITLE = re.compile(r"html5player\.setVideoTitle\('([^']*)'\);")
Expand Down
11 changes: 11 additions & 0 deletions xnxx_api/tests/test_search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from ..xnxx_api import Client

client = Client()
search = client.search("fortnite")

def test_search():
for idx, video in enumerate(search.videos):
assert isinstance(video.title, str)

if idx == 3:
break
19 changes: 19 additions & 0 deletions xnxx_api/tests/test_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from ..xnxx_api import Client

client = Client()
user = client.get_user("https://www.xnxx.com/pornstar/cory-chase")
objects_video = ["title", "publish_date", "length", "author"]



def test_video_views():
assert isinstance(user.total_video_views, str)
assert user.total_videos > 0

def test_videos():
for idx, video in enumerate(user.videos):
if idx == 3:
break
for object in objects_video:
assert isinstance(getattr(video, object), str)

6 changes: 4 additions & 2 deletions xnxx_api/tests/test_video.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ..xnxx_api import Video
from base_api.modules.quality import Quality
url = "https://www.xnxx.com/video-1b9bufc9/die_zierliche_stieftochter_passt_kaum_in_den_mund_ihres_stiefvaters"
# This will be the URL for all tests

Expand Down Expand Up @@ -77,5 +76,8 @@ def test_content_url():


def test_get_segments():
segments = list(video.get_segments(quality=Quality.BEST))
segments = list(video.get_segments(quality="best"))
assert len(segments) > 10

def test_download_low():
assert video.download(quality="worst", downloader="threaded") is True
Loading

0 comments on commit f4c0155

Please sign in to comment.