Skip to content

Bulk asynchronous downloader for multiple file hosts

fix: pagination (camwhores) (#1172)

NTFSvolume37d2a1c64ca7
diff --git a/cyberdrop_dl/crawlers/camwhores_dot_tv.py b/cyberdrop_dl/crawlers/camwhores_dot_tv.py
index cb81499ef..d98f93caa 100644
--- a/cyberdrop_dl/crawlers/camwhores_dot_tv.py
+++ b/cyberdrop_dl/crawlers/camwhores_dot_tv.py
@@ -3,8 +3,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, ClassVar
from cyberdrop_dl.crawlers._kvs import KernelVideoSharingCrawler, Video
+from cyberdrop_dl.crawlers.porntrex import PorntrexCrawler
from cyberdrop_dl.data_structures.url_objects import AbsoluteHttpURL, ScrapeItem
-from cyberdrop_dl.utils import open_graph
+from cyberdrop_dl.utils import css, open_graph
if TYPE_CHECKING:
from bs4 import BeautifulSoup
@@ -13,6 +14,7 @@ if TYPE_CHECKING:
PRIMARY_URL = AbsoluteHttpURL("https://www.camwhores.tv")
+LAST_PAGE_SELECTOR = "div.pagination-holder li.page"
class CamwhoresTVCrawler(KernelVideoSharingCrawler):
@@ -49,3 +51,18 @@ class CamwhoresTVCrawler(KernelVideoSharingCrawler):
async def album(self, scrape_item: ScrapeItem) -> None:
raise NotImplementedError
+
+ async def iter_videos(self, scrape_item: ScrapeItem, video_category: str = "") -> None:
+ url = scrape_item.url / video_category if video_category else scrape_item.url
+ await super().iter_videos(scrape_item, video_category)
+ async with self.request_limiter:
+ soup: BeautifulSoup = await self.client.get_soup(self.DOMAIN, url)
+
+ last_page = int(css.get_text(soup.select(LAST_PAGE_SELECTOR)[-1]))
+ # TODO: Porntrex also uses KVS. Make the KVS crawler handle it by default
+ await PorntrexCrawler.proccess_additional_pages(
+ self, # type: ignore[ArgumentType]
+ scrape_item,
+ last_page,
+ block_id="list_videos_common_videos_list",
+ )
diff --git a/cyberdrop_dl/crawlers/porntrex.py b/cyberdrop_dl/crawlers/porntrex.py
index efd22b529..c7c9b2fa7 100644
--- a/cyberdrop_dl/crawlers/porntrex.py
+++ b/cyberdrop_dl/crawlers/porntrex.py
@@ -29,7 +29,9 @@ class Selectors:
VIDEO_JS = "div.video-holder script:contains('var flashvars')"
NEXT_PAGE = "div#list_videos_videos_pagination li.next"
USER_NAME = "div.user-name"
- VIDEOS = "div.video-list a.thumb"
+ VIDEOS_2 = "div#list_videos_common_videos_list_items a"
+ VIDEOS_1 = "div.video-list a.thumb"
+ VIDEOS = f"{VIDEOS_1}, {VIDEOS_2}"
LAST_PAGE = "div.pagination-holder li.page"
TITLE = "div.headline > h1"
MODEL_NAME = "div.name > h1"
@@ -187,7 +189,7 @@ class PorntrexCrawler(Crawler):
mode="async", function="get_block", block_id=block_id, is_private=0, q=search_query, sort_by=sort_by
)
if kwargs:
- page_url.update_query(kwargs)
+ page_url = page_url.update_query(kwargs)
if "members" in scrape_item.url.parts:
from_param_name = "from_uploaded_videos"