Skip to content

Commit

Permalink
[mangadex] use custom User-Agent header (#1535)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jul 15, 2021
1 parent 36a2aff commit dfe1f49
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gallery_dl/extractor/mangadex.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .common import Extractor, Message
from .. import text, util, exception
from ..cache import cache, memcache
from ..version import __version__
from collections import defaultdict

BASE_PATTERN = r"(?:https?://)?(?:www\.)?mangadex\.(?:org|cc)"
Expand All @@ -27,6 +28,7 @@ class MangadexExtractor(Extractor):
archive_fmt = "{chapter_id}_{page}"
root = "https://mangadex.org"
_cache = {}
_headers = {"User-Agent": "gallery-dl/" + __version__}

def __init__(self, match):
Extractor.__init__(self, match)
Expand Down Expand Up @@ -116,6 +118,7 @@ def items(self):
yield Message.Directory, data

cattributes = chapter["data"]["attributes"]
data["_http_headers"] = self._headers
base = "{}/data/{}/".format(
self.api.athome_server(self.uuid)["baseUrl"], cattributes["hash"])
for data["page"], page in enumerate(cattributes["data"], 1):
Expand Down Expand Up @@ -170,7 +173,7 @@ class MangadexAPI():

def __init__(self, extr):
self.extractor = extr
self.headers = {}
self.headers = extr._headers.copy()

self.username, self.password = self.extractor._get_auth_info()
if not self.username:
Expand Down

0 comments on commit dfe1f49

Please sign in to comment.