-
Notifications
You must be signed in to change notification settings - Fork 6
Servers
MD@H, mdah or simply MangaDex@Home, is a user-hosted, cache server for MangaDex.
The network is made of volunteers that runs their own servers or computers, for the sake of the Horny Jail.
"Basically, your machine will act as a server where a tiny portion of older MangaDex chapters will be stored and when a reader wants to read an older chapter, it will be "fetched" from your machine and served to the reader." (more info on MD's mdah page)
So, basically, if you want to download from MangaDex, you'll have to use the API to fetch images.
A Chapter has a set of pages.
You can retrieve the list of pages by calling the get_chapter()
function with a chapter ID:
>>> import MangaDexPy
>>> cli = MangaDexPy.MangaDex()
>>> manga = cli.get_manga('b9797c5b-642e-44d9-ac40-8b31b9ae110a')
>>> chapter = manga.get_chapters()[0]
>>> chapter.pages
['1-3a604117709612f29d1a2d21612822f676bcb38a4f378e73fec2c7f1298afac4.jpg',
'2-619df12bbb7eeab3eea0f351e303279cad6aac8aaf07289adec678a571262bff.jpg',
...,
'26-f50267e479b81cfa6d0622400e49dceaafd085703d063ee069e61f1db44f309c.jpg',
'27-5971dd9f63218c00260c5f5e95adcdd3dff002f7f1278216345197a392223854.jpg']
These are the page filenames as they are stored on MD@H clients. To retrieve a page from a client, you'll need to be authenticated with a token, which is included when you request a Network Chapter via Chapter.get_md_network()
.
You can then get a link with NetworkChapter.pages
using the page index (0 being the first page, -1 the last, etc.).
(You can also use the .pages_redux property to get lighter pages)
>>> net = chapter.get_md_network()
>>> net.node_url
'https://agrfaez4v18ee.rmhkd98sb0x3y.mangadex.network:443/[........]'
>>> net.pages[0]
'https://agrfaez4v18ee.rmhkd98sb0x3y.mangadex.network:443/Pgx5XF_-KmSobNizAJay9CRTHUaK3nH2VPnM4gFCu7mtib8YThA7EkGlfSTquIFsVGMemzXSTL5lNY4B5sLWClLakIt9qPKJhXD6l8tcUGR30u0TB7YxcdxWvIEMMxCz00g3gGgzxjKdfZAoPJQzz6a4QvygcRR7Rs7X46vNa0J4a8D00081dQPF-WF5Aezd7XejgvRs67x950jcGNl0rnphp8Mmcg/data/7d68dbe3f684dc4c1a68d98179037aa6/1-3a604117709612f29d1a2d21612822f676bcb38a4f378e73fec2c7f1298afac4.jpg'
These URLs will lead you to the page:
However, you need to take this into consideration when using the pages system:
- Tokens for these pages expires after ~15 minutes. When these will be expired, you won't be able to browse them. To counter that, you can use
Chapter.get_md_network()
again. This call will regenerate a new token and assign you a new server - If you can't reach the server, consider reporting (see below) before asking a new server, otherwise you'll be likely assigned the same server.
- Please, for the network's sake, do not spam huge requests to MD@H clients. There is a tool included with this repo to download chapters, which minimizes the network load on MD@H clients by only refreshing one time, and that will automatically report network status, etc.
After downloading a page with MD@H, you should report its status. This allows MangaDex to build anonymous statistics on their servers, and allows them to remove servers that no longer works.
>>> net = chapter.get_md_network()
[... some downloads using requests, for example ...]
>>> net.report('https://agrf[...]98afac4.jpg', success=True, cached=True, req_bytes=120000, req_duration=300)
True
The above example shows that you've success
fully downloaded(or 'used' in any means) image with url https://agrf[...]98afac4.jpg
. The X-Cache
header was set to HIT
, you've transferred 120000 bytes in 300ms.
Please see this link for more info on how to report correct stats.