Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
EchterAlsFake committed Feb 29, 2024
2 parents e9eb281 + 3ceb521 commit 4d91226
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 28 deletions.
30 changes: 26 additions & 4 deletions README/Documentation.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# XNXX API Documentation

> - Version 1.2
> - Version 1.3 (partially)
> - Author: Johannes Habel
> - Copryight (C) 2024
> - License: GPL 3
> - Dependencies: requests, lxml, bs4, ffmpeg-progress-yield
> - Optional dependency: ffmpeg (installed in path)

# Important Notice
The ToS of xnxx.com clearly say, that using scrapers / bots isn't allowed.
> [!WARNING]
> The ToS of xnxx.com clearly say, that using scrapers / bots isn't allowed.
> Using this API is on your risk. I am not liable for your actions!
# Table of Contents
Expand All @@ -19,9 +19,11 @@ The ToS of xnxx.com clearly say, that using scrapers / bots isn't allowed.
- [Attributes](#attributes)
- [Downloading](#downloading-a-video)
- [Custom callback](#custom-callback-for-downloading--videos)

- [Searching](#searching)
- [Model / Users]
- [Locals](#locals)
- [Quality](#the-quality-object)
- [Searching Filters]

# Importing the API

Expand Down Expand Up @@ -118,6 +120,26 @@ def custom_callback(pos, total):

When downloading a video, you can just specify your callback functions in the `callback` argument

# Searching
```python
from xnxx_api.xnxx_api import Client
from xnxx_api.modules.search_filters import UploadTime, SearchingQuality, Length

client = Client()
search = client.search("<query>", upload_time=UploadTime.month, length=Length.X_0_10min, searching_quality=SearchingQuality.X_720p)
# this is an example

for video in search.videos:
print(video.title)
# Iterate like this over results
```

> [!Important]
> You can also search using categories with filters. Specify the category name
> in the query.



# Locals

Expand Down
Empty file added xnxx_api/modules/category.py
Empty file.
12 changes: 6 additions & 6 deletions xnxx_api/modules/search_filters.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class Length:
_0_10min = "/0-10min"
_10min_plus = "/10min+"
_10_20min = "/10-20min"
_20min_plus = "/20min+"
X_0_10min = "/0-10min"
X_10min_plus = "/10min+"
X_10_20min = "/10-20min"
X_20min_plus = "/20min+"


class UploadTime:
Expand All @@ -11,5 +11,5 @@ class UploadTime:


class SearchingQuality:
_720p = "/hd-only"
_1080p_plus = "/fullhd"
X_720p = "/hd-only"
X_1080p_plus = "/fullhd"
35 changes: 17 additions & 18 deletions xnxx_api/xnxx_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from bs4 import BeautifulSoup
from functools import cached_property
from pprint import pprint


class Video:
Expand Down Expand Up @@ -233,30 +234,34 @@ def videos(self):
class User:
def __init__(self, url):
self.url = url
self.pages = round(self.total_videos / 50)

@cached_property
def html_content(self):
# Now this is going to be weird, just don't ask
return Core().get_content(f"{self.url}", headers=HEADERS).decode("utf-8")
def base_json(self):
url = f"{self.url}/videos/best/0?from=goldtab"
content = Core().get_content(url, headers=HEADERS).decode("utf-8")
data = html.unescape(json.loads(content))
return data

@cached_property
def videos(self):

page = 0
while True:
page += 1
url = f"{self.url}/videos/best/{page}?from=goldtab"
content = Core().get_content(url, headers=HEADERS).decode("utf-8")
print(content)
urls = REGEX_SCRAPE_VIDEOS.findall(content)
data = html.unescape(json.loads(content))
videos = data["videos"]
for video in videos:
url = video.get("u")
yield Video(f"https://www.xnxx.com{url}")

if not urls:
if int(page) >= (self.pages):
break

else:
for url_ in urls:
yield Video(f"https://www.xnxx.com/video-{url_}")

page += 1
@cached_property
def total_videos(self):
return self.base_json["nb_videos"]


class Client:
Expand All @@ -272,9 +277,3 @@ def search(cls, query, upload_time: UploadTime = "", length: Length = "", search
@classmethod
def get_user(cls, url):
return User(url)

client = Client()
user = Client.get_user("https://www.xnxx.com/pornstar/abella-danger")
videos = user.videos
for video in videos:
print(video.title)

0 comments on commit 4d91226

Please sign in to comment.