Skip to content

Commit

Permalink
- fixed stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
EchterAlsFake committed Jan 5, 2025
1 parent 7d5b482 commit f26743a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions xvideos_api/xvideos_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import math
import html
import json
import httpx
import logging
import requests
import argparse

from typing import Union
Expand Down Expand Up @@ -79,7 +79,7 @@ def __init__(self, url):
self.url = self.check_url(url)
self.html_content = self.get_html_content()

if isinstance(self.html_content, requests.Response):
if isinstance(self.html_content, httpx.Response):
if self.html_content.status_code == 404:
raise VideoUnavailable("The video is not available or the URL is incorrect.")

Expand Down Expand Up @@ -113,7 +113,7 @@ def get_script_content(self):
target_script = soup.find(self.is_desired_script)
return target_script.text

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

def extract_json_from_html(self):
Expand Down Expand Up @@ -173,7 +173,7 @@ def download(self, downloader, quality, path="./", callback=None, no_title=False

except AttributeError:
logging.warning("Video doesn't have an HLS stream. Using legacy downloading instead...")
core.legacy_download(stream=True, path=path, callback=callback, url=self.cdn_url)
core.legacy_download(path=path, callback=callback, url=self.cdn_url)
return True

@cached_property
Expand Down Expand Up @@ -289,11 +289,8 @@ def videos(self):

u_values = [video["u"] for video in data["videos"]]
for video in u_values:
print(f"URL: {video}")
url = str(video).split("/")
print(f"URL 1: {url}")
id = url[4]
print(f"ID: {id}")
part_two = url[5]
yield Video(f"https://www.xvideos.com/video.{id}/{part_two}")

Expand Down

0 comments on commit f26743a

Please sign in to comment.