]> git.lizzy.rs Git - nhentai.git/commitdiff
fix codec error for py2
authorsymant233 <symant233@gmail.com>
Tue, 21 May 2019 09:06:42 +0000 (17:06 +0800)
committersymant233 <symant233@gmail.com>
Tue, 21 May 2019 09:06:42 +0000 (17:06 +0800)
nhentai/utils.py

index 434cf8053d85ee828476c0f891590d3f18889cc7..fe1270924aae1f73cd36fda332298d8f76f14f96 100644 (file)
@@ -119,14 +119,14 @@ def generate_main_html(output_dir='.'):
         image = files[0] # 001.jpg or 001.png
         if folder is not None:
             title = folder.replace('_', ' ')
-            if sys.version_info > (3, 0):
-                title = title.encode('utf-8')
+            if sys.version_info > (3, 0):
+                title = title.encode('utf-8')
         else:
             title = 'nHentai HTML Viewer'
         image_html += element.format(FOLDER=folder, IMAGE=image, TITLE=title)
 
-    data = main.format(STYLES=css, COUNT=count, PICTURE=image_html)
     try:
+        data = main.format(STYLES=css, COUNT=count, PICTURE=image_html)
         if sys.version_info < (3, 0):
             with open('./main.html', 'w') as f:
                 f.write(data)