Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
feat: add anysex support (#1545)
Barbarella66666666f02a5d633cd
diff --git a/cyberdrop_dl/crawlers/__init__.py b/cyberdrop_dl/crawlers/__init__.pyindex 0775f0675..f0a768209 100644--- a/cyberdrop_dl/crawlers/__init__.py+++ b/cyberdrop_dl/crawlers/__init__.py@@ -5,6 +5,7 @@ from cyberdrop_dl import envfrom ._chevereto import CheveretoCrawlerfrom .anontransfer import AnonTransferCrawler+from .anysex import AnySexCrawlerfrom .archivebate import ArchiveBateCrawlerfrom .ashemaletube import AShemaleTubeCrawlerfrom .beeg import BeegComCrawlerdiff --git a/cyberdrop_dl/crawlers/_fluid_player.py b/cyberdrop_dl/crawlers/_fluid_player.pynew file mode 100644index 000000000..7089dc4ed--- /dev/null+++ b/cyberdrop_dl/crawlers/_fluid_player.py@@ -0,0 +1,76 @@+from __future__ import annotations++from typing import TYPE_CHECKING, ClassVar, NamedTuple++from cyberdrop_dl.crawlers.crawler import Crawler+from cyberdrop_dl.data_structures.mediaprops import Resolution+from cyberdrop_dl.utils import css, open_graph+from cyberdrop_dl.utils.utilities import error_handling_wrapper++if TYPE_CHECKING:+ from bs4 import BeautifulSoup++ from cyberdrop_dl.data_structures.url_objects import ScrapeItem+++class Selector:+ VIDEO_SRC = ".gif-video, #main_video source"+ COLLECTION_TITLE = "h2.object-title"+ SEARCH_VIDEOS = "div.list-videos div.item > a"+ NEXT_PAGE = "div.pagination-holder li.next > a"+++class Format(NamedTuple):+ resolution: Resolution+ link_str: str+++class FluidPlayerCrawler(Crawler, is_abc=True):+ NEXT_PAGE_SELECTOR: ClassVar[str] = Selector.NEXT_PAGE+ _RATE_LIMIT = 3, 10++ @error_handling_wrapper+ async def video(self, scrape_item: ScrapeItem, video_id: str) -> None:+ if await self.check_complete_from_referer(scrape_item):+ return++ soup = await self.request_soup(scrape_item.url)+ best_format = _get_best_format(soup)+ link = self.parse_url(best_format.link_str)+ filename, ext = self.get_filename_and_ext(link.name)+ title = open_graph.title(soup)+ scrape_item.possible_datetime = self.parse_iso_date(css.get_json_ld_date(soup))+ custom_filename = self.create_custom_filename(title, ext, file_id=video_id, resolution=best_format.resolution)+ return await self.handle_file(+ scrape_item.url, scrape_item, filename, ext, custom_filename=custom_filename, debrid_link=link+ )++ @error_handling_wrapper+ async def collection(+ self,+ scrape_item: ScrapeItem,+ collection_type: str,+ name: str | None = None,+ ) -> None:+ title: str = ""+ async for soup in self.web_pager(scrape_item.url):+ if not title:+ name = name or css.select_text(soup, Selector.COLLECTION_TITLE)+ title = self.create_title(f"{name} [{collection_type}]")+ scrape_item.setup_as_album(title)++ for _, new_scrape_item in self.iter_children(scrape_item, soup, Selector.SEARCH_VIDEOS):+ self.create_task(self.run(new_scrape_item))+++def _get_best_format(soup: BeautifulSoup) -> Format:+ parse_resolution = Resolution.make_parser()++ def parse():+ for src in soup.select(Selector.VIDEO_SRC):+ url = css.get_attr(src, "src")+ quality = css.get_attr_or_none(src, "title")+ resolution = parse_resolution(quality)+ yield Format(resolution, url)++ return max(parse())diff --git a/cyberdrop_dl/crawlers/anysex.py b/cyberdrop_dl/crawlers/anysex.pynew file mode 100644index 000000000..7277145ee--- /dev/null+++ b/cyberdrop_dl/crawlers/anysex.py@@ -0,0 +1,50 @@+from __future__ import annotations++from typing import TYPE_CHECKING, ClassVar++from cyberdrop_dl.crawlers._fluid_player import FluidPlayerCrawler+from cyberdrop_dl.data_structures.url_objects import AbsoluteHttpURL+from cyberdrop_dl.utils import open_graph+from cyberdrop_dl.utils.utilities import error_handling_wrapper++if TYPE_CHECKING:+ from cyberdrop_dl.crawlers.crawler import SupportedPaths+ from cyberdrop_dl.data_structures.url_objects import ScrapeItem+++class Selector:+ IMAGES = "a#main_image_holder, .swiper-wrapper .swiper-slide a"+++class AnySexCrawler(FluidPlayerCrawler):+ SUPPORTED_PATHS: ClassVar[SupportedPaths] = {+ "Video": "/video/<video_id>/...",+ "Album": "/photos/<album_id>/...",+ "Search": "/search/...",+ }+ DOMAIN: ClassVar[str] = "anysex"+ FOLDER_DOMAIN: ClassVar[str] = "AnySex"+ PRIMARY_URL: ClassVar[AbsoluteHttpURL] = AbsoluteHttpURL("https://anysex.com")++ async def fetch(self, scrape_item: ScrapeItem) -> None:+ match scrape_item.url.parts[1:]:+ case [*_, "video", video_id, _]:+ return await self.video(scrape_item, video_id)+ case ["contents", _, *_]:+ return await self.direct_file(scrape_item)+ case [*_, "photos", album_id, _]:+ return await self.album(scrape_item, album_id)+ case ["search" as type_, *_] if query := scrape_item.url.query.get("q"):+ query = query.replace("-", " ")+ return await self.collection(scrape_item, type_, query)+ case _:+ raise ValueError++ @error_handling_wrapper+ async def album(self, scrape_item: ScrapeItem, album_id: str) -> None:+ soup = await self.request_soup(scrape_item.url)+ name = open_graph.title(soup)+ title = self.create_title(f"{name} [album]")+ scrape_item.setup_as_album(title, album_id=album_id)+ for _, new_scrape_item in self.iter_children(scrape_item, soup, Selector.IMAGES):+ self.create_task(self.run(new_scrape_item))diff --git a/cyberdrop_dl/crawlers/xgroovy.py b/cyberdrop_dl/crawlers/xgroovy.pyindex dbd3f430a..dc5d6e11a 100644--- a/cyberdrop_dl/crawlers/xgroovy.py+++ b/cyberdrop_dl/crawlers/xgroovy.py@@ -1,32 +1,16 @@from __future__ import annotations-from typing import TYPE_CHECKING, ClassVar, NamedTuple+from typing import TYPE_CHECKING, ClassVar-from cyberdrop_dl.crawlers.crawler import Crawler, SupportedPaths-from cyberdrop_dl.data_structures.mediaprops import Resolution+from cyberdrop_dl.crawlers._fluid_player import FluidPlayerCrawlerfrom cyberdrop_dl.data_structures.url_objects import AbsoluteHttpURL-from cyberdrop_dl.utils import css, open_graph-from cyberdrop_dl.utils.utilities import error_handling_wrapperif TYPE_CHECKING:- from bs4 import BeautifulSoup-+ from cyberdrop_dl.crawlers.crawler import SupportedPathsfrom cyberdrop_dl.data_structures.url_objects import ScrapeItem-class Selector:- VIDEO_SRC = ".gif-video, #main_video source"- COLLECTION_TITLE = "h2.object-title"- SEARCH_VIDEOS = "div.list-videos a.popito"- NEXT_PAGE = "div.pagination-holder li.next > a"---class Format(NamedTuple):- resolution: Resolution- link_str: str---class XGroovyCrawler(Crawler):+class XGroovyCrawler(FluidPlayerCrawler):SUPPORTED_PATHS: ClassVar[SupportedPaths] = {"Video": ("/<category>/videos/<video_id>/...",@@ -56,8 +40,6 @@ class XGroovyCrawler(Crawler):DOMAIN: ClassVar[str] = "xgroovy"FOLDER_DOMAIN: ClassVar[str] = "XGroovy"PRIMARY_URL: ClassVar[AbsoluteHttpURL] = AbsoluteHttpURL("https://xgroovy.com")- NEXT_PAGE_SELECTOR: ClassVar[str] = Selector.NEXT_PAGE- _RATE_LIMIT = 3, 10async def fetch(self, scrape_item: ScrapeItem) -> None:match scrape_item.url.parts[1:]:@@ -69,42 +51,3 @@ class XGroovyCrawler(Crawler):return await self.collection(scrape_item, type_, slug)case _:raise ValueError-- @error_handling_wrapper- async def video(self, scrape_item: ScrapeItem, video_id: str) -> None:- if await self.check_complete_from_referer(scrape_item):- return-- soup = await self.request_soup(scrape_item.url)- best_format = _get_best_format(soup)- link = self.parse_url(best_format.link_str)- filename, ext = self.get_filename_and_ext(link.name)- title = open_graph.title(soup)- scrape_item.possible_datetime = self.parse_iso_date(css.get_json_ld_date(soup))- custom_filename = self.create_custom_filename(title, ext, file_id=video_id, resolution=best_format.resolution)- return await self.handle_file(- scrape_item.url, scrape_item, filename, ext, custom_filename=custom_filename, debrid_link=link- )-- @error_handling_wrapper- async def collection(self, scrape_item: ScrapeItem, collection_type: str, name: str | None = None) -> None:- title: str = ""- async for soup in self.web_pager(scrape_item.url):- if not title:- name = name or css.select_text(soup, Selector.COLLECTION_TITLE)- title = self.create_title(f"{name} [{collection_type}]")- scrape_item.setup_as_album(title)-- for _, new_scrape_item in self.iter_children(scrape_item, soup, Selector.SEARCH_VIDEOS):- self.create_task(self.run(new_scrape_item))---def _get_best_format(soup: BeautifulSoup) -> Format:- def parse():- for src in soup.select(Selector.VIDEO_SRC):- url = css.get_attr(src, "src")- quality = css.get_attr_or_none(src, "title")- resolution = Resolution.parse(quality)- yield Format(resolution, url)-- return max(parse())diff --git a/tests/crawlers/test_cases/anysex.py b/tests/crawlers/test_cases/anysex.pynew file mode 100644index 000000000..e8d3c6e0e--- /dev/null+++ b/tests/crawlers/test_cases/anysex.py@@ -0,0 +1,68 @@+DOMAIN = "anysex"+TEST_CASES = [+ # Video page link+ (+ "https://anysex.com/video/475758/2-sexy-latina-fitness-girls-get-dicked-hard-by-2-beefy-dudes-outdoor-indoor/",+ [+ {+ "url": "https://anysex.com/video/475758/2-sexy-latina-fitness-girls-get-dicked-hard-by-2-beefy-dudes-outdoor-indoor",+ "filename": "2 Sexy Latina Fitness-girls Get Dicked Hard By 2 Beefy Dudes Outdoor Indoo [475758][1080p].mp4",+ "debrid_link": "ANY",+ "referer": "https://anysex.com/video/475758/2-sexy-latina-fitness-girls-get-dicked-hard-by-2-beefy-dudes-outdoor-indoor",+ "datetime": 1761678940,+ }+ ],+ ),+ # Video with unknown resolution+ (+ "https://anysex.com/video/89167/amazing-blond-slut-makes-a-horny-dude-to-suck-the-dick-of-the-other-stud/",+ [+ {+ "url": "https://anysex.com/video/89167/amazing-blond-slut-makes-a-horny-dude-to-suck-the-dick-of-the-other-stud",+ "filename": "Amazing blond slut makes a horny dude to suck the dick of the other stud [89167].mp4",+ "debrid_link": "ANY",+ "referer": "https://anysex.com/video/89167/amazing-blond-slut-makes-a-horny-dude-to-suck-the-dick-of-the-other-stud",+ "datetime": 1381968000,+ }+ ],+ ),+ # Album page link+ (+ "https://anysex.com/photos/156337/only-5-0-but-thick-and-curvy-in-all-the-right-places/",+ [+ {+ "url": "re:https://photos.anysex.com/contents/albums/main/1920x9999/156000",+ "download_folder": r"re:Only 50 but thick and curvy in all the right places! \[album\] \(AnySex\)",+ "referer": "re:https://photos.anysex.com/contents/albums/main/1920x9999/156000",+ "album_id": "156337",+ }+ ],+ 8,+ ),+ # Album with just one image+ (+ "https://anysex.com/shemale/photos/156591/natures-big-secret/",+ [+ {+ "url": "https://photos.anysex.com/contents/albums/main/1920x9999/156000/156591/255953.jpg",+ "download_folder": r"re:Natures big secret ️ \[album\] \(AnySex\)",+ "referer": "https://photos.anysex.com/contents/albums/main/1920x9999/156000/156591/255953.jpg",+ "album_id": "156591",+ }+ ],+ 1,+ ),+ # Search+ (+ "https://anysex.com/search/?q=helena-price",+ [+ {+ "url": "ANY",+ "download_folder": r"re:helena price [search] (AnySex)",+ "referer": "ANY",+ "album_id": None,+ }+ ],+ range(18, 30),+ ),+]