Skip to content

Commit

Permalink
Fixes my bad on past attempt to deal with BOM (#1130)
Browse files Browse the repository at this point in the history
Previously write bom segment wrote garbage instead of actual
byte order mark on every system.
With this I remove a NIH fix and add a system-dependent definition for
download file encoding, so on Windows there would no need to fix BOM
and on Linux there's no need to remove BOM for scripting with Downloaded file
  • Loading branch information
NHOrus committed Jul 2, 2022
1 parent 5f53aeb commit 1c4d8eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion PixivDownloadHandler.py
Expand Up @@ -248,7 +248,7 @@ def download_image(caller,

# write to downloaded lists
if caller.start_iv or config.createDownloadLists:
dfile = codecs.open(caller.dfilename, 'a+', encoding='utf-8')
dfile = codecs.open(caller.dfilename, 'a+', encoding=caller.platform_encoding)
dfile.write(filename_save + "\n")
dfile.close()

Expand Down
11 changes: 4 additions & 7 deletions PixivUtil2.py
Expand Up @@ -65,6 +65,10 @@ def win_getpass_with_mask(prompt='Password: ', stream=None):
return pw

getpass.getpass = win_getpass_with_mask
platform_encoding = 'utf-8-sig'
else:
platform_encoding = 'utf-8'


script_path = PixivHelper.module_path()

Expand Down Expand Up @@ -1624,13 +1628,6 @@ def main():
os.makedirs(directory)
__log__.info('Creating directory: %s', directory)

# write BOM
if start_iv or __config__.createDownloadLists:
if not os.path.isfile(dfilename) or os.path.getsize(dfilename) == 0:
dfile = codecs.open(dfilename, 'a+', encoding='utf-8')
dfile.write(u'\uefbbbf')
dfile.close()

# Yavos: adding IrfanView-Handling
start_irfan_slide = False
start_irfan_view = False
Expand Down

0 comments on commit 1c4d8eb

Please sign in to comment.