Skip to content

Bulk asynchronous downloader for multiple file hosts

feat: add support to xgroovy (#1452)

Barbarella666666615e87edef503
diff --git a/cyberdrop_dl/crawlers/__init__.py b/cyberdrop_dl/crawlers/__init__.py
index e01fc9a28..d3481bc22 100644
--- a/cyberdrop_dl/crawlers/__init__.py
+++ b/cyberdrop_dl/crawlers/__init__.py
@@ -114,6 +114,7 @@ from .wetransfer import WeTransferCrawler
from .wordpress import WP_CRAWLERS, WordPressHTMLCrawler, WordPressMediaCrawler
from .xbunkr import XBunkrCrawler
from .xenforo import XF_CRAWLERS, SimpCityCrawler
+from .xgroovy import XGroovyCrawler
from .xhamster import XhamsterCrawler
from .xvideos import XVideosCrawler
from .xxxbunker import XXXBunkerCrawler
diff --git a/cyberdrop_dl/crawlers/xgroovy.py b/cyberdrop_dl/crawlers/xgroovy.py
new file mode 100644
index 000000000..d9af18c92
--- /dev/null
+++ b/cyberdrop_dl/crawlers/xgroovy.py
@@ -0,0 +1,110 @@
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, ClassVar, NamedTuple
+
+from cyberdrop_dl.crawlers.crawler import Crawler, SupportedPaths
+from cyberdrop_dl.data_structures.mediaprops import Resolution
+from cyberdrop_dl.data_structures.url_objects import AbsoluteHttpURL
+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 a.popito"
+ NEXT_PAGE = "div.pagination-holder li.next > a"
+
+
+class Format(NamedTuple):
+ resolution: Resolution
+ link_str: str
+
+
+class XGroovyCrawler(Crawler):
+ SUPPORTED_PATHS: ClassVar[SupportedPaths] = {
+ "Video": (
+ "/<category>/videos/<video_id>/...",
+ "/videos/<video_id>/...",
+ ),
+ "Gif": (
+ "/<category>/gifs/<gif_id>/...",
+ "/gifs/<gif_id>/...",
+ ),
+ "Search": (
+ "/<category>/search/...",
+ "/search/...",
+ ),
+ "Pornstar": (
+ "/<category>/pornstars/<pornstar_id>/...",
+ "/pornstars/<pornstar_id>/...",
+ ),
+ "Tag": (
+ "/<category>/tags/...",
+ "/tags/...",
+ ),
+ "Channel": (
+ "/<category>/channels/...",
+ "/channels/...",
+ ),
+ }
+ 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, 10
+
+ async def fetch(self, scrape_item: ScrapeItem) -> None:
+ match scrape_item.url.parts[1:]:
+ case [*_, "videos" | "gifs", video_id, _]:
+ return await self.video(scrape_item, video_id)
+ case [*_, "pornstars" as type_, _]:
+ return await self.collection(scrape_item, type_)
+ case [*_, "categories" | "channels" | "search" | "tag" as type_, slug]:
+ 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_one_get_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/cyberdrop_dl/data_structures/mediaprops.py b/cyberdrop_dl/data_structures/mediaprops.py
index 8383d82b1..432fb2e36 100644
--- a/cyberdrop_dl/data_structures/mediaprops.py
+++ b/cyberdrop_dl/data_structures/mediaprops.py
@@ -62,7 +62,7 @@ class Resolution(NamedTuple):
return Fraction(self.width, self.height)
@staticmethod
- def parse(url_number_or_string: yarl.URL | str | int, /) -> Resolution:
+ def parse(url_number_or_string: yarl.URL | str | int | None, /) -> Resolution:
if url_number_or_string is None:
return UNKNOWN_RESOLUTION
diff --git a/tests/crawlers/test_cases/xgroovy.py b/tests/crawlers/test_cases/xgroovy.py
new file mode 100644
index 000000000..2e7c5202e
--- /dev/null
+++ b/tests/crawlers/test_cases/xgroovy.py
@@ -0,0 +1,55 @@
+DOMAIN = "xgroovy"
+TEST_CASES = [
+ # Video page link
+ (
+ "https://xgroovy.com/videos/598490/brunette-bombshell-casts-her-magic-in-amateur-pov/",
+ [
+ {
+ "url": "https://xgroovy.com/videos/598490/brunette-bombshell-casts-her-magic-in-amateur-pov",
+ "filename": "Brunette Bombshell Casts Her Magic in Amateur POV [598490][1080p].mp4",
+ "debrid_link": "ANY",
+ "referer": "https://xgroovy.com/videos/598490/brunette-bombshell-casts-her-magic-in-amateur-pov",
+ "datetime": 1758692603,
+ }
+ ],
+ ),
+ # Gif page link
+ (
+ "https://xgroovy.com/shemale/gifs/463103/jaw-dropping3",
+ [
+ {
+ "url": "https://xgroovy.com/shemale/gifs/463103/jaw-dropping3",
+ "filename": "Jaw-dropping! [463103].mp4",
+ "debrid_link": "ANY",
+ "referer": "https://xgroovy.com/shemale/gifs/463103/jaw-dropping3",
+ "datetime": 1733330169,
+ }
+ ],
+ ),
+ # Search
+ (
+ "https://xgroovy.com/search/helena-price/",
+ [
+ {
+ "url": "re:https://xgroovy.com/videos/",
+ "download_folder": r"re:helena\-price \[search\] \(XGroovy\)",
+ "referer": "re:https://xgroovy.com/videos/",
+ "album_id": None,
+ }
+ ],
+ 17,
+ ),
+ # Pornstars
+ (
+ "https://xgroovy.com/pornstars/hotangelsfromhell/",
+ [
+ {
+ "url": "ANY",
+ "download_folder": r"re:HotAngelsFromHell \[pornstars\] \(XGroovy\)",
+ "referer": "re:https://xgroovy.com/videos/",
+ "album_id": None,
+ }
+ ],
+ 1,
+ ),
+]