Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
fix: handle new URL format
NTFSvolumea49146849467
diff --git a/cyberdrop_dl/crawlers/whyp_it.py b/cyberdrop_dl/crawlers/whyp_it.pyindex eceabeeb8..b3d56ac0b 100644--- a/cyberdrop_dl/crawlers/whyp_it.py+++ b/cyberdrop_dl/crawlers/whyp_it.py@@ -7,7 +7,6 @@ from cyberdrop_dl import aiofrom cyberdrop_dl.clients.http import HTTPConfigfrom cyberdrop_dl.crawlers.crawler import API, Crawler, SupportedPathsfrom cyberdrop_dl.url_objects import AbsoluteHttpURL-from cyberdrop_dl.utils import parse_urlfrom cyberdrop_dl.utils.dataclass import deserializefrom cyberdrop_dl.utils.errors import error_handling_wrapper@@ -20,9 +19,9 @@ if TYPE_CHECKING:@HTTPConfig(rate_limit=(5, 1))class WhypItCrawler(Crawler):SUPPORTED_PATHS: ClassVar[SupportedPaths] = {- "Audio": "/tracks/<id>/...",- "User": "/users/<id>/<name>",- "Collection": "/collections/<collection_id>/<name>",+ "Audio": "/tracks/<slug>-<id>",+ "User": "/users/<slug>-<id>",+ "Collection": "/collections/<slug>-<id>",}PRIMARY_URL: ClassVar[AbsoluteHttpURL] = AbsoluteHttpURL("https://whyp.it")@@ -30,11 +29,11 @@ class WhypItCrawler(Crawler):async def fetch(self, scrape_item: ScrapeItem) -> None:match scrape_item.url.parts[1:]:- case ["tracks", track_id, *_]:+ case ["tracks", slug] if track_id := slug.rpartition("-")[-1]:return await self.track(scrape_item, track_id)- case ["users", user_id, _]:+ case ["users", slug] if user_id := slug.rpartition("-")[-1]:return await self.user(scrape_item, user_id)- case ["collections", collection_id, _]:+ case ["collections", slug] if collection_id := slug.rpartition("-")[-1]:return await self.collection(scrape_item, collection_id)case _:raise ValueError@@ -81,7 +80,7 @@ class WhypItCrawler(Crawler):async def _track(self, scrape_item: ScrapeItem, track: Track) -> None:scrape_item.uploaded_at = self.parse_iso_date(track.created_at)_, ext = self.get_filename_and_ext(track.src.name)- filename = self.create_custom_filename(track.title, ext, file_id=str(track.id))+ filename = self.create_custom_filename(track.title, ext, file_id=track.public_id)await self.handle_file(track.src,scrape_item,@@ -89,31 +88,29 @@ class WhypItCrawler(Crawler):ext,custom_filename=filename,metadata=track.metadata,+ thumbnail=track.artwork_url,)@dataclasses.dataclass(slots=True)class Track:id: int+ public_id: strtitle: strsrc: AbsoluteHttpURLuser: strpublic: bool- token: str+metadata: dict[str, Any]created_at: str-- @property- def url(self) -> AbsoluteHttpURL:- url = WhypItCrawler.PRIMARY_URL / f"tracks/{self.id}"- if not self.public:- url = url.with_query(token=self.token)- return url+ url: AbsoluteHttpURL+ artwork_url: str | None = None@dataclasses.dataclass(slots=True)class Collection:id: int+ public_id: strtitle: strtoken: struser: str@@ -162,7 +159,8 @@ def _parse_track(track: dict[str, Any]) -> Track:user=track["user"]["username"],metadata=track,created_at=track.get("created_at") or track["pivot_created_at"],- src=parse_url(track.get("lossless_url") or track["lossy_url"]),+ src=WhypItCrawler.parse_url(track.get("lossless_url") or track["lossy_url"]),+ url=WhypItCrawler.parse_url(track["url"]),)diff --git a/tests/crawlers/test_cases/whyp_it.py b/tests/crawlers/test_cases/whyp_it.pyindex 001f8625c..d8b2ad424 100644--- a/tests/crawlers/test_cases/whyp_it.py+++ b/tests/crawlers/test_cases/whyp_it.py@@ -1,15 +1,15 @@DOMAIN = "whyp.it"TEST_CASES = [{- "url": "https://whyp.it/tracks/344383/reading-your-shy-besties-mind?token=WBPWv",+ "url": "https://whyp.it/tracks/reading-your-shy-besties-mind-4eyNuDoUzLk1?token=WBPWv","description": "Private track (requires the ?token param to access)","results": [{"url": "re:https://cdn.whyp.it/7777d4c0-0b06-4500-89e0-f0d960b0a4a4.mp3?token",- "filename": "Reading Your Shy Besties Mind [344383].mp3",+ "filename": "Reading Your Shy Besties Mind [4eyNuDoUzLk1].mp3","debrid_url": None,"original_filename": "Reading Your Shy Bestie's Mind",- "referer": "https://whyp.it/tracks/344383/reading-your-shy-besties-mind?token=WBPWv",+ "referer": "https://whyp.it/tracks/reading-your-shy-besties-mind-4eyNuDoUzLk1?token=WBPWv","album_id": None,"uploaded_at": 1777422482,"download_folder": "re:beegeewanders (Whyp.it)",@@ -18,65 +18,78 @@ TEST_CASES = ["count": 1,},{- "url": "https://whyp.it/users/1/brad",+ "url": "https://whyp.it/users/brad-cGgThTrh8wcG","results": [{"url": "re:https://cdn.whyp.it/5e9de576-f33a-40ea-bd43-1693a568a6a0.mp3",- "filename": "Fallout 3 Intro Remake [13721].mp3",+ "filename": "Fallout 3 Intro Remake [SLEphiH9vh0q].mp3","debrid_url": None,"original_filename": "Fallout 3 Intro Remake",- "referer": "https://whyp.it/tracks/13721",+ "referer": "https://whyp.it/tracks/fallout-3-intro-remake-SLEphiH9vh0q","album_id": None,"uploaded_at": 1764003590,"download_folder": "re:Brad (Whyp.it)",+ "thumbnail": None,},{"url": "re:https://cdn.whyp.it/0d7a196b-3e1a-4510-a4a4-6189c56ecb27.flac",- "filename": "Jason Waters - Heart of the Throne [324260].flac",+ "filename": "Jason Waters - Heart of the Throne [QEYqRdMfoIG8].flac","debrid_url": None,"original_filename": "Jason Waters - Heart of the Throne",- "referer": "https://whyp.it/tracks/324260",+ "referer": "https://whyp.it/tracks/jason-waters-heart-of-the-throne-QEYqRdMfoIG8","album_id": None,"uploaded_at": 1763408657,"download_folder": "re:Brad (Whyp.it)",+ "thumbnail": "https://cdn.whyp.it/b42b34d3-5839-4a26-9c32-41e917f31f6b.jpg",},{"url": "re:https://cdn.whyp.it/3d134d07-7c55-4a6b-b321-56ce90ee1fc8.flac",- "filename": "Example Track [18337].flac",+ "filename": "Example Track [HPuZgly3yViP].flac","debrid_url": None,"original_filename": "Example Track",- "referer": "https://whyp.it/tracks/18337",+ "referer": "https://whyp.it/tracks/example-track-HPuZgly3yViP","album_id": None,"uploaded_at": 1643216583,"download_folder": "re:Brad (Whyp.it)",+ "thumbnail": "https://cdn.whyp.it/4d6f6af1-0114-4e92-863b-996ff3a2f642.jpg",},],"count": 3,},{- "url": "https://whyp.it/collections/1/example-collection",+ "url": "https://whyp.it/collections/example-collection-hNdBmugKbF85","results": [{"url": "re:https://cdn.whyp.it/3d134d07-7c55-4a6b-b321-56ce90ee1fc8.flac?token=",- "filename": "Example Track [18337].flac",+ "filename": "Example Track [HPuZgly3yViP].flac","debrid_url": None,"original_filename": "Example Track",- "referer": "https://whyp.it/tracks/18337",+ "referer": "https://whyp.it/tracks/example-track-HPuZgly3yViP","album_id": None,"uploaded_at": 1708365679,"download_folder": "re:Brad (Whyp.it)/Example Collection",+ "thumbnail": "https://cdn.whyp.it/4d6f6af1-0114-4e92-863b-996ff3a2f642.jpg",},{"url": "re:https://cdn.whyp.it/0d7a196b-3e1a-4510-a4a4-6189c56ecb27.flac?token=",- "filename": "Jason Waters - Heart of the Throne [324260].flac",+ "filename": "Jason Waters - Heart of the Throne [QEYqRdMfoIG8].flac","debrid_url": None,"original_filename": "Jason Waters - Heart of the Throne",- "referer": "https://whyp.it/tracks/324260",+ "referer": "https://whyp.it/tracks/jason-waters-heart-of-the-throne-QEYqRdMfoIG8","album_id": None,"uploaded_at": 1763408701,"download_folder": "re:Brad (Whyp.it)/Example Collection",+ "thumbnail": "https://cdn.whyp.it/b42b34d3-5839-4a26-9c32-41e917f31f6b.jpg",+ },+ {+ "url": "re:https://cdn.whyp.it/5e9de576-f33a-40ea-bd43-1693a568a6a0.mp3?token=",+ "filename": "Fallout 3 Intro Remake [SLEphiH9vh0q].mp3",+ "debrid_url": None,+ "referer": "https://whyp.it/tracks/fallout-3-intro-remake-SLEphiH9vh0q",+ "album_id": None,+ "download_folder": "re:Brad (Whyp.it)/Example Collection",+ "thumbnail": None,},],- "count": 2,},]