Skip to content

Commit

Permalink
- using infinite page generating instead of static one
Browse files Browse the repository at this point in the history
  • Loading branch information
EchterAlsFake committed Jun 25, 2024
1 parent 95f4895 commit f495f7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
5 changes: 4 additions & 1 deletion README/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
- added legacy downloading for low-quality videos

# 1.3
- implemented the Pornstar object
- implemented the Pornstar object

# 1.4
- using infinite page generating instead of static one (for Porn Fetch)
15 changes: 7 additions & 8 deletions xvideos_api/xvideos_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import logging
import argparse

import requests
from bs4 import BeautifulSoup
from functools import cached_property
from base_api.base import Core, threaded, default, FFMPEG
Expand Down Expand Up @@ -308,25 +309,23 @@ def extract_video_urls(cls, html_content):

@classmethod
def search(cls, query, sorting_Sort: Sort = Sort.Sort_relevance, sorting_Date: SortDate = SortDate.Sort_all,
sorting_Time: SortVideoTime = SortVideoTime.Sort_all, sort_Quality: SortQuality = SortQuality.Sort_all,
pages=2):
sorting_Time: SortVideoTime = SortVideoTime.Sort_all, sort_Quality: SortQuality = SortQuality.Sort_all,):

query = query.replace(" ", "+")

base_url = f"https://www.xvideos.com/?k={query}&sort={sorting_Sort}%&datef={sorting_Date}&durf={sorting_Time}&quality={sort_Quality}"
urls = []
for page in range(pages):
page = 0

for page in range(100):
response = Core().get_content(f"{base_url}&p={page}", headers=headers).decode("utf-8")
urls_ = Client.extract_video_urls(response)

for url in urls_:
url = f"https://www.xvideos.com{url}"

if REGEX_VIDEO_CHECK_URL.match(url):
urls.append(url)

for id in urls:
yield Video(id)
yield Video(url)
page += 1

@classmethod
def get_pornstar(self, url):
Expand Down

0 comments on commit f495f7e

Please sign in to comment.