Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eight04 committed Mar 25, 2024
1 parent 1638dae commit 0910ae8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion comiccrawler/download_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from os.path import join as path_join
from time import time

from worker import Worker, current, await_, create_worker, async_, sleep
from worker import Worker, current, await_, create_worker, async_

from .analyzer import Analyzer
from .safeprint import print
Expand Down
17 changes: 11 additions & 6 deletions comiccrawler/mods/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@
from ..grabber import cooldown
from ..session_manager import session_manager

def setup_curl(mod):
for key, value in mod.config.items():
if key.startswith("curl") and value:
session_manager.update_by_curl(value)
def setup_session(mod):
if getattr(mod, "autocurl", False):
for key, value in mod.config.items():
if key.startswith("curl") and value:
session_manager.update_by_curl(value)

# if cookie := getattr(mod, "cookie", {}):
# for key, value in cookie.items():
# if value:
# session_manager.update_cookie(key, value)

def import_module_file(ns, file):
# pylint: disable=import-outside-toplevel
Expand Down Expand Up @@ -127,8 +133,7 @@ def load_config(self):
if hasattr(mod, "load_config"):
mod.load_config()

# if getattr(mod, "autocurl", False):
# setup_curl(mod)
setup_session(mod)

mod_loader = ModLoader()
list_domain = mod_loader.list_domain
Expand Down
1 change: 0 additions & 1 deletion comiccrawler/mods/sankaku.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from ..core import Episode
from ..error import PauseDownloadError, SkipEpisodeError
from ..grabber import grabhtml

domain = ["chan.sankakucomplex.com"]
name = "Sankaku"
Expand Down
7 changes: 5 additions & 2 deletions comiccrawler/module_grabber.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

from .grabber import grabhtml, grabimg

def purify_cookie(cookie):
"""Remove empty cookie value."""
return {key: value for key, value in cookie.items() if value and "請" not in value}

class ModuleGrabber:
"""Bind grabber with module's header, cookie..."""
def __init__(self, mod):
Expand All @@ -16,7 +20,7 @@ def img(self, url, **kwargs):
def grab(self, grab_method, url=None, **kwargs):
new_kwargs = {
"header": self.get_header(),
"cookie": self.get_cookie(),
"cookie": purify_cookie(self.get_cookie()),
"done": self.handle_grab,
"proxy": self.mod.config.get("proxy"),
"verify": self.mod.config.getboolean("verify", True)
Expand All @@ -35,7 +39,6 @@ def get_header(self):

def get_cookie(self):
"""Return downloader cookie."""
return {}
cookie = getattr(self.mod, "cookie", {})
config = getattr(self.mod, "config", {})

Expand Down

0 comments on commit 0910ae8

Please sign in to comment.