diff --git a/README/Documentation.md b/README/Documentation.md index 7c83e80..3572b94 100644 --- a/README/Documentation.md +++ b/README/Documentation.md @@ -1,6 +1,6 @@ # XNXX API Documentation -> - Version 1.2 +> - Version 1.3 (partially) > - Author: Johannes Habel > - Copryight (C) 2024 > - License: GPL 3 @@ -8,8 +8,8 @@ > - 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 @@ -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 @@ -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("", 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 diff --git a/xnxx_api/modules/category.py b/xnxx_api/modules/category.py new file mode 100644 index 0000000..e69de29 diff --git a/xnxx_api/modules/search_filters.py b/xnxx_api/modules/search_filters.py index 55de54f..88cf522 100644 --- a/xnxx_api/modules/search_filters.py +++ b/xnxx_api/modules/search_filters.py @@ -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: @@ -11,5 +11,5 @@ class UploadTime: class SearchingQuality: - _720p = "/hd-only" - _1080p_plus = "/fullhd" + X_720p = "/hd-only" + X_1080p_plus = "/fullhd" diff --git a/xnxx_api/xnxx_api.py b/xnxx_api/xnxx_api.py index 47c0b9e..2a8e7a1 100644 --- a/xnxx_api/xnxx_api.py +++ b/xnxx_api/xnxx_api.py @@ -22,6 +22,7 @@ from bs4 import BeautifulSoup from functools import cached_property +from pprint import pprint class Video: @@ -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: @@ -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)