Skip to content

Bulk asynchronous downloader for multiple file hosts

1.1 KB
Raw Blame
from __future__ import annotations

from typing import TYPE_CHECKING, ClassVar

from cyberdrop_dl.crawlers._kvs import KernelVideoSharingCrawler
from cyberdrop_dl.crawlers.crawler import URLConfig
from cyberdrop_dl.url_objects import AbsoluteHttpURL, ScrapeItem

if TYPE_CHECKING:
    from cyberdrop_dl.crawlers.crawler import SupportedPaths


@URLConfig(trim=False)
class XasiatCrawler(KernelVideoSharingCrawler):
    SUPPORTED_PATHS: ClassVar[SupportedPaths] = {
        "Album": "/albums/<id>/<name>",
        "Images": "/get_image/...",
        "Videos": "/videos/<id>/<name>",
    }

    PRIMARY_URL: ClassVar[AbsoluteHttpURL] = AbsoluteHttpURL("https://www.xasiat.com")
    DOMAIN: ClassVar[str] = "xasiat"

    async def fetch(self, scrape_item: ScrapeItem) -> None:
        match scrape_item.url.parts[1:]:
            case ["albums", album_id, _, *_]:
                await self.album(scrape_item, album_id)
            case ["videos", _, _, *_]:
                await self.video(scrape_item)
            case ["get_image", _, *_]:
                await self.direct_file(scrape_item)
            case _:
                raise ValueError