summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/hentainexus.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/hentainexus.py')
-rw-r--r--gallery_dl/extractor/hentainexus.py37
1 files changed, 34 insertions, 3 deletions
diff --git a/gallery_dl/extractor/hentainexus.py b/gallery_dl/extractor/hentainexus.py
index 49c1a98..a6db0d5 100644
--- a/gallery_dl/extractor/hentainexus.py
+++ b/gallery_dl/extractor/hentainexus.py
@@ -10,6 +10,7 @@
from .common import GalleryExtractor, Extractor, Message
from .. import text, util
+import binascii
import json
@@ -57,10 +58,40 @@ class HentainexusGalleryExtractor(GalleryExtractor):
return data
def images(self, _):
- url = "{}/read/{}".format(self.root, self.gallery_id)
+ url = "{}/read/{}/001".format(self.root, self.gallery_id)
page = self.request(url).text
- urls = text.extract(page, "initReader(", "]")[0] + "]"
- return [(url, None) for url in json.loads(urls)]
+
+ data = json.loads(self._decode(text.extract(
+ page, 'initReader("', '"')[0]))
+ base = data["b"] + data["r"]
+ gid = data["i"]
+
+ return [
+ ("{}{}/{}/{}".format(base, page["h"], gid, page["p"]), None)
+ for page in data["f"]
+ ]
+
+ @staticmethod
+ def _decode(data):
+ # https://hentainexus.com/static/js/reader.min.js?r=6
+ blob = binascii.a2b_base64(data)
+ key = blob[0:64]
+ indices = list(range(256))
+ result = ""
+
+ x = 0
+ for i in range(256):
+ x = (x + indices[i] + key[i % len(key)]) % 256
+ indices[i], indices[x] = indices[x], indices[i]
+
+ x = i = 0
+ for n in range(64, len(blob)):
+ i = (i + 1) % 256
+ x = (x + indices[i]) % 256
+ indices[i], indices[x] = indices[x], indices[i]
+ result += chr(blob[n] ^ indices[(indices[i] + indices[x]) % 256])
+
+ return result
@staticmethod
def _join_title(data):