From 319463559526a043b8bf366a2b348cd7403f16f6 Mon Sep 17 00:00:00 2001 From: Johannes Habel Date: Fri, 3 Jan 2025 14:24:44 +0100 Subject: [PATCH] - switched to httpx - removed lxml and requests from project dependencies --- README/Changelog.md | 6 +++++- setup.py | 6 ++---- xvideos_api/xvideos_api.py | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README/Changelog.md b/README/Changelog.md index 479beac..aed494a 100644 --- a/README/Changelog.md +++ b/README/Changelog.md @@ -27,4 +27,8 @@ - removed json5 requirement - fixed tests - added VideoUnavailable exception -- code refactoring and type hinting \ No newline at end of file +- code refactoring and type hinting + +# 1.5.1 +- switched to httpx +- removed lxml and requests from project dependencies \ No newline at end of file diff --git a/setup.py b/setup.py index 9e0fef2..6434163 100644 --- a/setup.py +++ b/setup.py @@ -2,11 +2,9 @@ setup( name="xvideos_api", - version="1.5.0", + version="1.5.1", packages=find_packages(), - install_requires=[ - "requests", "bs4", "lxml", "ffmpeg-progress-yield", "eaf_base_api" - ], + install_requires=["bs4", "eaf_base_api"], entry_points={ 'console_scripts': ['xvideos_api=xvideos_api.xvideos_api:main' # If you want to create any executable scripts diff --git a/xvideos_api/xvideos_api.py b/xvideos_api/xvideos_api.py index 6dd90ca..6cf073a 100644 --- a/xvideos_api/xvideos_api.py +++ b/xvideos_api/xvideos_api.py @@ -51,7 +51,7 @@ def __init__(self, content): self.content = content blackbox_url = f"https://xvideos.com/{REGEX_USER_BLACKBOX_URL.search(self.content).group(1)}#_tabAboutMe".replace('"', "") self.bb_content = core.fetch(blackbox_url) - self.soup = BeautifulSoup(self.bb_content, "lxml") + self.soup = BeautifulSoup(self.bb_content) content = self.soup.head.find('script').text channel_pattern = r'"channel"\s*:\s*(true|1)|"is_channel"\s*:\s*(true|1)' self.search = re.search(channel_pattern, content, re.IGNORECASE) @@ -109,7 +109,7 @@ def is_desired_script(cls, tag): return all(content in tag.text for content in script_contents) def get_script_content(self): - soup = BeautifulSoup(self.html_content, 'lxml') + soup = BeautifulSoup(self.html_content) target_script = soup.find(self.is_desired_script) return target_script.text @@ -117,7 +117,7 @@ def get_html_content(self) -> Union[str, requests.Response]: return core.fetch(self.url) def extract_json_from_html(self): - soup = BeautifulSoup(self.html_content, 'lxml') + soup = BeautifulSoup(self.html_content) script_tags = soup.find_all('script', {'type': 'application/ld+json'}) combined_data = {} @@ -311,7 +311,7 @@ def get_video(cls, url: str) -> Video: @classmethod def extract_video_urls(cls, html_content: str) -> list: # Parse the HTML content with BeautifulSoup - soup = BeautifulSoup(html_content, 'lxml') + soup = BeautifulSoup(html_content) video_urls = [] # Find all 'div' elements with the class 'thumb'