Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
fix: handle new encryption (xhamster) (#1296)
NTFSvolumef7c5bd071678
diff --git a/cyberdrop_dl/crawlers/xhamster.py b/cyberdrop_dl/crawlers/xhamster.pyindex 831dfda6c..29bcf2c08 100644--- a/cyberdrop_dl/crawlers/xhamster.py+++ b/cyberdrop_dl/crawlers/xhamster.py@@ -1,6 +1,7 @@from __future__ import annotationsimport base64+import codecsimport dataclassesimport itertoolsimport json@@ -9,6 +10,7 @@ from typing import TYPE_CHECKING, Any, ClassVar, NamedTuplefrom cyberdrop_dl.crawlers.crawler import Crawler, SupportedPathsfrom cyberdrop_dl.data_structures.mediaprops import Resolutionfrom cyberdrop_dl.data_structures.url_objects import AbsoluteHttpURL+from cyberdrop_dl.exceptions import ScrapeErrorfrom cyberdrop_dl.utils.utilities import error_handling_wrapper, get_text_between, parse_url, xor_decryptif TYPE_CHECKING:@@ -28,9 +30,23 @@ class Selector:NEXT_PAGE = "a[data-page='next']"-def _parse_url(url: str) -> AbsoluteHttpURL:- if url.startswith("eG9y"):- url = xor_decrypt(base64.b64decode(url)[4:], _DECRYPTION_KEY)+def _decrypt_url(b64_url: str) -> str | None:+ if b64_url.startswith("http") or b64_url.startswith("/"):+ return b64_url+ try:+ decoded_url = base64.b64decode(b64_url)+ if decoded_url.startswith(b"xor_"):+ return xor_decrypt(decoded_url[4:], _DECRYPTION_KEY)+ if decoded_url.startswith(b"rot13_"):+ return codecs.decode(decoded_url[6:].decode(), "rot_13")+ except ValueError:+ return+++def _parse_url(b64_url: str) -> AbsoluteHttpURL:+ url = _decrypt_url(b64_url)+ if not url:+ raise ScrapeError(422, f"Unknown encrypted URL: {b64_url}")return parse_url(url, relative_to=_PRIMARY_URL)diff --git a/tests/crawlers/test_cases/xhamster.py b/tests/crawlers/test_cases/xhamster.pyindex 63d12906b..0024da545 100644--- a/tests/crawlers/test_cases/xhamster.py+++ b/tests/crawlers/test_cases/xhamster.py@@ -56,7 +56,7 @@ TEST_CASES = ["datetime": 1372456260,}],- 40,+ 42,),("https://xhamster.com/creators/danielagomezz",@@ -71,12 +71,12 @@ TEST_CASES = ["datetime": 1738917721,},],- 33,+ 34,),("https://xhamster.com/creators/danielagomezz/exclusive",[],- 31,+ 32,),("https://xhamster.com/creators/danielagomezz/photos",