mikf / gallery-dl

Command-line program to download image galleries and collections from several image hosting sites
GNU General Public License v2.0
12.09k stars 982 forks source link

[Site Request] ComicWalker #6258

Open ruben1PvP opened 2 months ago

ruben1PvP commented 2 months ago

Japanese comic (manga) site.

Some titles only have some chapters available and the new ones are only for a limited time (1 or 2 days), so I would like to save them due to how quick they could get deleted.

Main site: https://comic-walker.com

mikf commented 2 months ago

This site appears to deliver its image files in encrypted form and decodes them client-side.

ruben1PvP commented 2 months ago

This site appears to deliver its image files in encrypted form and decodes them client-side.

So they are protected by DRM?

mikf commented 2 months ago

Seems like it. Page metadata contains various drm… entries.

    {
      "drmMode": "xor",
      "drmHash": "d7ab847ee8cd355b",
      "drmImageUrl": "https://cdn.comic-walker.com/images/5946/2/1/20240925204648/1/1_2b2dd3f0120ccfd032210670ac32f8cab518c4b5180d8737f6b2cb5447ece916.webp?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9jZG4uY29taWMtd2Fsa2VyLmNvbS9pbWFnZXMvNTk0Ni8yLzEvMjAyNDA5MjUyMDQ2NDgvMS8qLndlYnAiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3Mjc2OTUyODJ9fX1dfQ__&Signature=RJJ-irktYAZ~ke5CgrjJv-qCczh61R8zSXYaFRMLsYGZu-yfvo8-cbCscDKCetYuPiUFT3MtlSDqPAsluDGbkqefYNjTv1CqwF4T6ojkWMZ8ua4kFaD3~CVuxx6JCW821JmX6N5DJEtu439-8ZaR2LoMidZ~gYyI0DbzsL51NDH8X~ULAzMAvJMglka38zO9ZouKIkXz7clhv3UR8M3K5Y7Xl6pjytmLU~aSC5eOYu4WcF8TL2cPyi~vWMRxq1IspuZAlb6~pXmh0etuK0Z3L7G0Yvf9V0OusI7sowpmKvAuE8EEyNtd-itu0CRQvpEefBuqANc-jsKUt2HNOJHh3w__&Key-Pair-Id=K2YXDWASRN7F3E",
      "page": 1,
      "width": 1284,
      "height": 1843
    },
ruben1PvP commented 2 months ago

Seems like it. Page metadata contains various drm… entries.

    {
      "drmMode": "xor",
      "drmHash": "d7ab847ee8cd355b",
      "drmImageUrl": "https://cdn.comic-walker.com/images/5946/2/1/20240925204648/1/1_2b2dd3f0120ccfd032210670ac32f8cab518c4b5180d8737f6b2cb5447ece916.webp?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9jZG4uY29taWMtd2Fsa2VyLmNvbS9pbWFnZXMvNTk0Ni8yLzEvMjAyNDA5MjUyMDQ2NDgvMS8qLndlYnAiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3Mjc2OTUyODJ9fX1dfQ__&Signature=RJJ-irktYAZ~ke5CgrjJv-qCczh61R8zSXYaFRMLsYGZu-yfvo8-cbCscDKCetYuPiUFT3MtlSDqPAsluDGbkqefYNjTv1CqwF4T6ojkWMZ8ua4kFaD3~CVuxx6JCW821JmX6N5DJEtu439-8ZaR2LoMidZ~gYyI0DbzsL51NDH8X~ULAzMAvJMglka38zO9ZouKIkXz7clhv3UR8M3K5Y7Xl6pjytmLU~aSC5eOYu4WcF8TL2cPyi~vWMRxq1IspuZAlb6~pXmh0etuK0Z3L7G0Yvf9V0OusI7sowpmKvAuE8EEyNtd-itu0CRQvpEefBuqANc-jsKUt2HNOJHh3w__&Key-Pair-Id=K2YXDWASRN7F3E",
      "page": 1,
      "width": 1284,
      "height": 1843
    },

That's a request from a browser, right? Not from gallery-dl, I mean. I didn't know because Firefox never tells me when I visit that page. If you could only get the imageUrl with a browser, I suppose that's a dead end.

mikf commented 2 months ago

Yes, this is part of an API response captured with Firefox's network inspector. Getting this information with gallery-dl shouldn't be a problem, but decrypting the drmImageUrl data probably is.

ruben1PvP commented 2 months ago

Yes, this is part of an API response captured with Firefox's network inspector. Getting this information with gallery-dl shouldn't be a problem, but decrypting the drmImageUrl data probably is.

Well, if it's not easy to implement either discard it or leave to a future. Does gallery-dl support any DRM protected site?

mikf commented 2 months ago

Some sites required some deobfuscation and reverse engineering to support them, but none required its downloaded files to be decrypted.

ruben1PvP commented 2 months ago

Do I leave this request in stand by, then? Or do I close it?

missionfloyd commented 2 months ago

Figured it out.

input_file = "in.webp"
output_file = "out.webp"
key = bytes.fromhex("c86e23ae4a70ff55")# drmHash

with open(input_file, "rb") as f:
    data = f.read()

decrypted_data = bytearray(data[i] ^ key[i % len(key)] for i in range(len(data)))

with open(output_file, "wb") as f:
    f.write(decrypted_data)

encrypted image.zip

ruben1PvP commented 2 months ago

Figured it out.

input_file = "in.webp"
output_file = "out.webp"
key = bytes.fromhex("c86e23ae4a70ff55")# drmHash

with open(input_file, "rb") as f:
    data = f.read()

decrypted_data = bytearray(data[i] ^ key[i % len(key)] for i in range(len(data)))

with open(output_file, "wb") as f:
    f.write(decrypted_data)

encrypted image.zip

Perfect! Knowing mikf gave your comment a thumbs up, I guess that at least it appears it's fine for him. I also tried with the in.webp you posted and it indeed produces a legible output. I'll wait until it's added then.