]> git.lizzy.rs Git - nhentai.git/commitdiff
Merge pull request #214 from lleene/master
authorRicter Zheng <RicterZheng@gmail.com>
Thu, 3 Jun 2021 00:00:18 +0000 (08:00 +0800)
committerGitHub <noreply@github.com>
Thu, 3 Jun 2021 00:00:18 +0000 (08:00 +0800)
Add dryrun option to command line interface

1  2 
nhentai/utils.py

diff --combined nhentai/utils.py
index 45190482d5267c9896b33bf1ffe29fea7e7dcca0,dd74e6690dbd096b5c62509368d913df1f0c63ef..3364d0d4b675b40b6a13141d47bf9cb170dd18c0
@@@ -20,11 -20,7 +20,11 @@@ def request(method, url, **kwargs)
          'User-Agent': 'nhentai command line client (https://github.com/RicterZ/nhentai)',
          'Cookie': constant.CONFIG['cookie']
      })
 -    return getattr(session, method)(url, proxies=constant.CONFIG['proxy'], verify=False, **kwargs)
 +
 +    if not kwargs.get('proxies', None):
 +        kwargs['proxies'] = constant.CONFIG['proxy']
 +
 +    return getattr(session, method)(url, verify=False, **kwargs)
  
  
  def check_cookie():
@@@ -74,6 -70,13 +74,13 @@@ def generate_html(output_dir='.', douji
      else:
          doujinshi_dir = '.'
  
+     if not os.path.exists(doujinshi_dir):
+         logger.warning('Path \'{0}\' does not exist, creating.'.format(doujinshi_dir))
+         try:
+             os.makedirs(doujinshi_dir)
+         except EnvironmentError as e:
+             logger.critical('{0}'.format(str(e)))
      file_list = os.listdir(doujinshi_dir)
      file_list.sort()
  
@@@ -198,7 -201,7 +205,7 @@@ def generate_cbz(output_dir='.', doujin
  def generate_pdf(output_dir='.', doujinshi_obj=None, rm_origin_dir=False):
      try:
          import img2pdf
-         
          """Write images to a PDF file using img2pdf."""
          if doujinshi_obj is not None:
              doujinshi_dir = os.path.join(output_dir, doujinshi_obj.filename)
              shutil.rmtree(doujinshi_dir, ignore_errors=True)
  
          logger.log(15, 'PDF file has been written to \'{0}\''.format(doujinshi_dir))
-         
      except ImportError:
          logger.error("Please install img2pdf package by using pip.")