Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/unicode support #77

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

N64Core
Copy link
Contributor

@N64Core N64Core commented Mar 24, 2023

Pertains to issue #74

This PR fixes a bug that occurs when downloading files that use UTF-8 characters, the characters they're meant to represent will get "smeared" into a different encoding format, the root cause I believe is this line in utils.py:

#filename_re = re.search(r'filename="(.+)"', cd)

What's going on here has something to do either with re.search returning an ascii formated byte string, or a weird consequence of passing the string through the assignment operator. My memory is a bit hazy on the specifics. in addition to fixing that issue the directory handling code was improved in other sections, using existing functions to replace blocks of code and making the variable names slightly more readable.

Also apologies for the weird duplicate commits on the branch, I'm a little rusty with git.

Copy link
Owner

@Emersont1 Emersont1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code should be using pathlib, it makes it easier to use throughout the codebase

@N64Core
Copy link
Contributor Author

N64Core commented Mar 30, 2023

The code should be using pathlib, it makes it easier to use throughout the codebase

Should be good now

@N64Core N64Core requested a review from Emersont1 March 30, 2023 04:03
itchiodl/game.py Outdated Show resolved Hide resolved
itchiodl/game.py Outdated Show resolved Hide resolved
itchiodl/utils.py Outdated Show resolved Hide resolved
@eibe1014
Copy link

I used this branch today (pip install https://github.com/N64Core/itchio/archive/refs/heads/bugfix/unicode_support.zip) and try to download my full lib and get into this issues:

When downloading:
Downloaded Moonlight on Roseville Beach | A Visitor's Guide to Cruisin! (180 of 6320) Traceback (most recent call last): File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\downloader\__main__.py", line 75, in <module> main() File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\downloader\__main__.py", line 71, in main lib.download_library(args.platform) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\library.py", line 108, in download_library for _ in r: File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 609, in result_iterator yield fs.pop().result() File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 439, in result return self.__get_result() File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 391, in __get_result raise self._exception File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\library.py", line 99, in dl g.download(self.login, platform) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\game.py", line 91, in download self.do_download(d, token) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\game.py", line 120, in do_download if md5 == d["md5_hash"]: KeyError: 'md5_hash'

When restart downloading (so it will use local files?):

Downloaded You're having a normal day and OH NO, GOBLINS! (8 of 6320) Traceback (most recent call last): File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\downloader\__main__.py", line 75, in <module> main() File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\downloader\__main__.py", line 71, in main lib.download_library(args.platform) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\library.py", line 108, in download_library for _ in r: File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 609, in result_iterator yield fs.pop().result() File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 446, in result return self.__get_result() File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 391, in __get_result raise self._exception File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\library.py", line 99, in dl g.download(self.login, platform) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\game.py", line 91, in download self.do_download(d, token) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\game.py", line 143, in do_download filename.rename(old_dir / f"{timestamp}-{filename}") AttributeError: 'str' object has no attribute 'rename'

@N64Core
Copy link
Contributor Author

N64Core commented Apr 15, 2023

I used this branch today (pip install https://github.com/N64Core/itchio/archive/refs/heads/bugfix/unicode_support.zip) and try to download my full lib and get into this issues:

When downloading: Downloaded Moonlight on Roseville Beach | A Visitor's Guide to Cruisin! (180 of 6320) Traceback (most recent call last): File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\downloader\__main__.py", line 75, in <module> main() File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\downloader\__main__.py", line 71, in main lib.download_library(args.platform) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\library.py", line 108, in download_library for _ in r: File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 609, in result_iterator yield fs.pop().result() File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 439, in result return self.__get_result() File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 391, in __get_result raise self._exception File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\library.py", line 99, in dl g.download(self.login, platform) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\game.py", line 91, in download self.do_download(d, token) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\game.py", line 120, in do_download if md5 == d["md5_hash"]: KeyError: 'md5_hash'

When restart downloading (so it will use local files?):

Downloaded You're having a normal day and OH NO, GOBLINS! (8 of 6320) Traceback (most recent call last): File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\downloader\__main__.py", line 75, in <module> main() File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\downloader\__main__.py", line 71, in main lib.download_library(args.platform) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\library.py", line 108, in download_library for _ in r: File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 609, in result_iterator yield fs.pop().result() File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 446, in result return self.__get_result() File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 391, in __get_result raise self._exception File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\library.py", line 99, in dl g.download(self.login, platform) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\game.py", line 91, in download self.do_download(d, token) File "C:\Users\*\AppData\Local\Programs\Python\Python310\lib\site-packages\itchiodl\game.py", line 143, in do_download filename.rename(old_dir / f"{timestamp}-{filename}") AttributeError: 'str' object has no attribute 'rename'

I need to test this, but I think I understand what's going on here, it's trying to call rename on an object that still purely a string and not a Path

@N64Core N64Core requested a review from Emersont1 April 15, 2023 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants