mirror of
				https://github.com/RicterZ/nhentai.git
				synced 2025-11-04 02:50:55 +01:00 
			
		
		
		
	fix unicode error on windows / python2
This commit is contained in:
		@@ -13,8 +13,12 @@ from nhentai.utils import urlparse, generate_html
 | 
			
		||||
from nhentai.logger import logger
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    reload(sys)
 | 
			
		||||
    sys.setdefaultencoding(sys.stdin.encoding)
 | 
			
		||||
    if sys.version_info < (3, 0, 0):
 | 
			
		||||
        import codecs
 | 
			
		||||
        import locale
 | 
			
		||||
        sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)
 | 
			
		||||
        sys.stderr = codecs.getwriter(locale.getpreferredencoding())(sys.stderr)
 | 
			
		||||
 | 
			
		||||
except NameError:
 | 
			
		||||
    # python3
 | 
			
		||||
    pass
 | 
			
		||||
 
 | 
			
		||||
@@ -104,7 +104,10 @@ class ColorizingStreamHandler(logging.StreamHandler):
 | 
			
		||||
                text = parts.pop(0)
 | 
			
		||||
 | 
			
		||||
                if text:
 | 
			
		||||
                    write(text)
 | 
			
		||||
                    if sys.version_info < (3, 0, 0):
 | 
			
		||||
                        write(text.encode('utf-8'))
 | 
			
		||||
                    else:
 | 
			
		||||
                        write(text)
 | 
			
		||||
 | 
			
		||||
                if parts:
 | 
			
		||||
                    params = parts.pop(0)
 | 
			
		||||
 
 | 
			
		||||
@@ -157,8 +157,8 @@ def print_doujinshi(doujinshi_list):
 | 
			
		||||
        return
 | 
			
		||||
    doujinshi_list = [(i['id'], i['title']) for i in doujinshi_list]
 | 
			
		||||
    headers = ['id', 'doujinshi']
 | 
			
		||||
    logger.info('Search Result\n' +
 | 
			
		||||
                tabulate(tabular_data=doujinshi_list, headers=headers, tablefmt='rst'))
 | 
			
		||||
    data = tabulate(tabular_data=doujinshi_list, headers=headers, tablefmt='rst')
 | 
			
		||||
    logger.info('Search Result\n{}'.format(data))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def tag_parser(tag_id):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user