From f78d8750f39ac08d87252b0799290a64534e9170 Mon Sep 17 00:00:00 2001 From: RicterZ Date: Mon, 11 Jan 2021 11:03:45 +0800 Subject: [PATCH 1/3] remove __future__ --- nhentai/cmdline.py | 2 +- nhentai/command.py | 2 +- nhentai/constant.py | 3 +-- nhentai/doujinshi.py | 3 +-- nhentai/downloader.py | 1 - nhentai/parser.py | 1 - nhentai/utils.py | 3 +-- 7 files changed, 5 insertions(+), 10 deletions(-) diff --git a/nhentai/cmdline.py b/nhentai/cmdline.py index b14ec4d..ffc8a3e 100644 --- a/nhentai/cmdline.py +++ b/nhentai/cmdline.py @@ -1,5 +1,5 @@ # coding: utf-8 -from __future__ import print_function + import os import sys import json diff --git a/nhentai/command.py b/nhentai/command.py index 16adc22..cbc50ed 100644 --- a/nhentai/command.py +++ b/nhentai/command.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2.7 # coding: utf-8 -from __future__ import unicode_literals, print_function + import sys import signal import platform diff --git a/nhentai/constant.py b/nhentai/constant.py index bce3604..39c6f3e 100644 --- a/nhentai/constant.py +++ b/nhentai/constant.py @@ -1,7 +1,6 @@ # coding: utf-8 -from __future__ import unicode_literals, print_function + import os -import copy import tempfile try: diff --git a/nhentai/doujinshi.py b/nhentai/doujinshi.py index 3c43d62..0170ad5 100644 --- a/nhentai/doujinshi.py +++ b/nhentai/doujinshi.py @@ -1,7 +1,6 @@ # coding: utf-8 -from __future__ import print_function, unicode_literals + from tabulate import tabulate -from future.builtins import range from nhentai.constant import DETAIL_URL, IMAGE_URL from nhentai.logger import logger diff --git a/nhentai/downloader.py b/nhentai/downloader.py index f11bb60..4f26b6e 100644 --- a/nhentai/downloader.py +++ b/nhentai/downloader.py @@ -1,5 +1,4 @@ # coding: utf- -from __future__ import unicode_literals, print_function import multiprocessing import signal diff --git a/nhentai/parser.py b/nhentai/parser.py index 582add2..7b9142c 100644 --- a/nhentai/parser.py +++ b/nhentai/parser.py @@ -1,5 +1,4 @@ # coding: utf-8 -from __future__ import unicode_literals, print_function import os import re diff --git a/nhentai/utils.py b/nhentai/utils.py index de40d94..1ce4298 100644 --- a/nhentai/utils.py +++ b/nhentai/utils.py @@ -1,5 +1,4 @@ # coding: utf-8 -from __future__ import unicode_literals, print_function import sys import re @@ -240,7 +239,7 @@ def format_filename(s): if filename include forbidden characters (\'/:,;*?"<>|) ,it replace space character(' '). """ # maybe you can use `--format` to select a suitable filename - ban_chars = '\\\'/:,;*?"<>|' + ban_chars = '\\\'/:,;*?"<>|\t' filename = s.translate(str.maketrans(ban_chars, ' '*len(ban_chars))).strip() while filename.endswith('.'): filename = filename[:-1] From ba141efba7d31cf46fa90da7802ca59a54319ff3 Mon Sep 17 00:00:00 2001 From: RicterZ Date: Mon, 11 Jan 2021 11:04:29 +0800 Subject: [PATCH 2/3] remove repeated spaces --- nhentai/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nhentai/utils.py b/nhentai/utils.py index 1ce4298..474ea52 100644 --- a/nhentai/utils.py +++ b/nhentai/utils.py @@ -241,6 +241,8 @@ def format_filename(s): # maybe you can use `--format` to select a suitable filename ban_chars = '\\\'/:,;*?"<>|\t' filename = s.translate(str.maketrans(ban_chars, ' '*len(ban_chars))).strip() + filename = re.sub("\s\s+" , " ", filename) + while filename.endswith('.'): filename = filename[:-1] From fc99d91ac107eaf283feb12d821ac75c43fb089f Mon Sep 17 00:00:00 2001 From: RicterZ Date: Mon, 11 Jan 2021 11:14:35 +0800 Subject: [PATCH 3/3] fix #193 --- nhentai/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nhentai/utils.py b/nhentai/utils.py index 474ea52..099f6a1 100644 --- a/nhentai/utils.py +++ b/nhentai/utils.py @@ -241,7 +241,8 @@ def format_filename(s): # maybe you can use `--format` to select a suitable filename ban_chars = '\\\'/:,;*?"<>|\t' filename = s.translate(str.maketrans(ban_chars, ' '*len(ban_chars))).strip() - filename = re.sub("\s\s+" , " ", filename) + filename = ' '.join(filename.split()) + print(repr(filename)) while filename.endswith('.'): filename = filename[:-1]