Skip to content

Commit

Permalink
- updated namings
Browse files Browse the repository at this point in the history
  • Loading branch information
EchterAlsFake committed Jan 5, 2025
1 parent f26743a commit 0d51a05
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 35 deletions.
File renamed without changes.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

<div align="center">
<a href="https://pepy.tech/project/xvideos_api"><img src="https://static.pepy.tech/badge/xvideos_api" alt="Downloads"></a>
<a href="https://pepy.tech/project/xvideos_api-async"><img src="https://static.pepy.tech/badge/xvideos_api-async" alt="Downloads"></a> <pan style="font-size: 20px">(Async)</pan>
<a href="https://github.com/EchterAlsFake/xvideos_api/workflows/"><img src="https://github.com/EchterAlsFake/xvideos_api/workflows/CodeQL/badge.svg" alt="CodeQL Analysis"/></a>
<a href="https://github.com/EchterAlsFake/xvideos_api/workflows/"><img src="https://github.com/EchterAlsFake/xvideos_api/actions/workflows/tests.yml/badge.svg" alt="API Tests"/></a>
<a href="https://github.com/EchterAlsFake/xvideos_api/actions/workflows/tests.yml"><img src="https://github.com/EchterAlsFake/xvideos_api/actions/workflows/tests.yml/badge.svg?branch=async" alt="Async Branch API Tests"></a>
<a href="https://github.com/EchterAlsFake/xvideos_api/actions/workflows/sync-tests.yml"><img src="https://github.com/EchterAlsFake/xvideos_api/actions/workflows/sync-tests.yml/badge.svg" alt="Sync API Tests"/></a>
<a href="https://github.com/EchterAlsFake/xvideos_api/actions/workflows/async-tests.yml"><img src="https://github.com/EchterAlsFake/xvideos_api/actions/workflows/async-tests.yml/badge.svg?branch=async" alt="Async Branch API Tests"></a>
</div>

# Description
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

setup(
name="xvideos_api",
version="1.5.1",
version="1.5.2",
packages=find_packages(),
install_requires=["bs4", "eaf_base_api"],
install_requires=["bs4", "eaf_base_api", "httpx"],
entry_points={
'console_scripts': ['xvideos_api=xvideos_api.xvideos_api:main'
# If you want to create any executable scripts
Expand Down
34 changes: 3 additions & 31 deletions xvideos_api/xvideos_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,6 @@ def disable_logging():
logger.setLevel(logging.CRITICAL)


class User:
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)
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)


@cached_property
def pornstar(self):
return self.search.group()

@cached_property
def is_channel(self):
return self.is_channel

@cached_property
def channel(self):
return



class Video:
def __init__(self, url):
Expand Down Expand Up @@ -109,15 +85,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)
soup = BeautifulSoup(self.html_content, features="html.parser")
target_script = soup.find(self.is_desired_script)
return target_script.text

def get_html_content(self) -> Union[str, httpx.Response]:
return core.fetch(self.url)

def extract_json_from_html(self):
soup = BeautifulSoup(self.html_content)
soup = BeautifulSoup(self.html_content, features="html.parser")
script_tags = soup.find_all('script', {'type': 'application/ld+json'})

combined_data = {}
Expand Down Expand Up @@ -258,10 +234,6 @@ def embed_url(self) -> str:
def cdn_url(self) -> str:
return self.json_data["contentUrl"]

@cached_property
def user(self) -> User:
return User(self.html_content)


class Pornstar:
def __init__(self, url):
Expand Down Expand Up @@ -308,7 +280,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)
soup = BeautifulSoup(html_content, features="html.parser")
video_urls = []

# Find all 'div' elements with the class 'thumb'
Expand Down

0 comments on commit 0d51a05

Please sign in to comment.