[util] implement 'decrypt_xor()'

This commit is contained in:
Mike Fährmann
2025-03-04 16:32:27 +01:00
parent b5c1bf3f59
commit 5486a9c429
3 changed files with 19 additions and 27 deletions

View File

@@ -9,8 +9,7 @@
"""Extractors for Chevereto galleries"""
from .common import BaseExtractor, Message
from .. import text
import binascii
from .. import text, util
class CheveretoExtractor(BaseExtractor):
@@ -33,18 +32,6 @@ class CheveretoExtractor(BaseExtractor):
url = text.extr(page, '<a data-pagination="next" href="', '" ><')
def _decrypt_url(self, encrypted_b64):
encrypted_hex = binascii.a2b_base64(encrypted_b64)
encrypted_bytes = bytes.fromhex(encrypted_hex.decode())
key = b"seltilovessimpcity@simpcityhatesscrapers"
div = len(key)
return bytes([
encrypted_bytes[i] ^ key[i % div]
for i in range(len(encrypted_bytes))
]).decode()
BASE_PATTERN = CheveretoExtractor.update({
"jpgfish": {
@@ -75,7 +62,9 @@ class CheveretoImageExtractor(CheveretoExtractor):
pos = page.find(" download=")
url = text.rextract(page, 'href="', '"', pos)[0]
if not url.startswith("https://"):
url = self._decrypt_url(url)
url = util.decrypt_xor(
url, b"seltilovessimpcity@simpcityhatesscrapers",
fromhex=True)
image = {
"id" : self.path.rpartition(".")[2],