Skip to content

Commit

Permalink
- switched to httpx
Browse files Browse the repository at this point in the history
- removed lxml and requests from project dependencies
  • Loading branch information
EchterAlsFake committed Jan 3, 2025
1 parent efcdd90 commit 3194635
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 5 additions & 1 deletion README/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@
- removed json5 requirement
- fixed tests
- added VideoUnavailable exception
- code refactoring and type hinting
- code refactoring and type hinting

# 1.5.1
- switched to httpx
- removed lxml and requests from project dependencies
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions xvideos_api/xvideos_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -109,15 +109,15 @@ 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

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 = {}
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 3194635

Please sign in to comment.