diff --git a/README/Changelog.md b/README/Changelog.md index d05ded7..e067eb7 100644 --- a/README/Changelog.md +++ b/README/Changelog.md @@ -15,4 +15,7 @@ - added legacy downloading for low-quality videos # 1.3 -- implemented the Pornstar object \ No newline at end of file +- implemented the Pornstar object + +# 1.4 +- using infinite page generating instead of static one (for Porn Fetch) \ No newline at end of file diff --git a/xvideos_api/xvideos_api.py b/xvideos_api/xvideos_api.py index ee8ea6d..d55e15c 100644 --- a/xvideos_api/xvideos_api.py +++ b/xvideos_api/xvideos_api.py @@ -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 @@ -308,14 +309,14 @@ 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) @@ -323,10 +324,8 @@ def search(cls, query, sorting_Sort: Sort = Sort.Sort_relevance, sorting_Date: S 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):