Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions cyberdrop_dl/crawlers/xgroovy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@

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": (
Expand All @@ -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"
Expand All @@ -49,5 +63,20 @@ async def fetch(self, scrape_item: ScrapeItem) -> None:
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()
38 changes: 38 additions & 0 deletions tests/crawlers/test_cases/xgroovy.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,42 @@
],
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",
}
],
),
]
Loading