Skip to content

Bulk asynchronous downloader for multiple file hosts

feat: add albums support (XGroovy) (#1602)

Barbarella666666635d6151f34c5
diff --git a/cyberdrop_dl/crawlers/xgroovy.py b/cyberdrop_dl/crawlers/xgroovy.py
index dc5d6e11a..5006bbfad 100644
--- a/cyberdrop_dl/crawlers/xgroovy.py
+++ b/cyberdrop_dl/crawlers/xgroovy.py
@@ -4,12 +4,22 @@ 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.exceptions import ScrapeError
+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 Selectors:
+ ALBUM = "div.swiper-slide > a, a#main_image_holder"
+
+
+_SELECTORS = Selectors()
+
+
class XGroovyCrawler(FluidPlayerCrawler):
SUPPORTED_PATHS: ClassVar[SupportedPaths] = {
"Video": (
@@ -36,6 +46,10 @@ class XGroovyCrawler(FluidPlayerCrawler):
"/<category>/channels/...",
"/channels/...",
),
+ "Images": (
+ "/<category>/photos/<photo_id>/...",
+ "/photos/<photo_id>/...",
+ ),
}
DOMAIN: ClassVar[str] = "xgroovy"
FOLDER_DOMAIN: ClassVar[str] = "XGroovy"
@@ -49,5 +63,20 @@ class XGroovyCrawler(FluidPlayerCrawler):
return await self.collection(scrape_item, type_)
case [*_, "categories" | "channels" | "search" | "tag" as type_, slug]:
return await self.collection(scrape_item, type_, slug)
+ case [*_, "photos", album_id, _]:
+ return await self.album(scrape_item, album_id)
+ case [*_, "contents", "albums", "sources", _, _, _]:
+ return await self.direct_file(scrape_item)
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)
+ if not (title := open_graph.get_title(soup)):
+ raise ScrapeError(401, "Could not find album title")
+ title = self.create_title(title, album_id)
+ scrape_item.setup_as_album(title, album_id=album_id)
+ for _, url in self.iter_tags(soup, _SELECTORS.ALBUM):
+ await self.direct_file(scrape_item, url)
+ scrape_item.add_children()
diff --git a/tests/crawlers/test_cases/xgroovy.py b/tests/crawlers/test_cases/xgroovy.py
index 2e7c5202e..ec42b05f3 100644
--- a/tests/crawlers/test_cases/xgroovy.py
+++ b/tests/crawlers/test_cases/xgroovy.py
@@ -52,4 +52,42 @@ TEST_CASES = [
],
1,
),
+ # Image
+ (
+ "https://xgroovy.com/photos/1082475/hope-you-like-them-perky-and-natural/",
+ [
+ {
+ "url": "https://photos.xgroovy.com/contents/albums/sources/1082000/1082475/1496153.jpg",
+ "download_folder": r"re:Hope you like them perky and natural \(XGroovy\)",
+ "referer": "https://xgroovy.com/photos/1082475/hope-you-like-them-perky-and-natural",
+ "filename": "1496153.jpg",
+ "album_id": "1082475",
+ }
+ ],
+ ),
+ # Album
+ (
+ "https://xgroovy.com/photos/1081573/without-piercing-this-view-is-more-appetizing/",
+ [
+ {
+ "url": "re:https://photos.xgroovy.com/contents/albums/sources/1081000/1081573/",
+ "download_folder": r"re:Without piercing, this view is more appetizing \(XGroovy\)",
+ "referer": "re:https://xgroovy.com/photos/1081573/without-piercing-this-view-is-more-appetizing",
+ "album_id": "1081573",
+ },
+ ],
+ 12,
+ ),
+ # Direct File
+ (
+ "https://photos.xgroovy.com/contents/albums/sources/1081000/1081200/1493360.jpg",
+ [
+ {
+ "url": "https://photos.xgroovy.com/contents/albums/sources/1081000/1081200/1493360.jpg",
+ "download_folder": r"re:Loose Files \(XGroovy\)",
+ "referer": "https://photos.xgroovy.com/contents/albums/sources/1081000/1081200/1493360.jpg",
+ "filename": "1493360.jpg",
+ }
+ ],
+ ),
]