mnamer icon indicating copy to clipboard operation
mnamer copied to clipboard

Literally does not work with Windows paths.

Open kris3713 opened this issue 1 year ago • 4 comments

When I attempt to utilize mnamer within an MS Windows environment, I encounter the following error message:

============================== CRASH REPORT BEGIN ==============================

--------------------------------- environment ----------------------------------

 - date = 2024-11-21
 - platform = Windows-11-10.0.22631-SP0
 - arguments = ['.\\Videos\\Arcane (2021-2024)\\', '-r']
 - cache location = C:\Users\krist\AppData\Local\mnamer-py3.13.sqlite
 - python version = 3.13.0
 - mnamer version = 2.5.5
 - appdirs version = 1.4.4
 - guessit version = 3.7.1
 - requests version = 2.32.3
 - requests cache version = 0.9.8
 - teletype version = 1.3.4

--------------------------------- stack trace ----------------------------------

Traceback (most recent call last):
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\guessit\api.py", line 200, in guessit
    config = self.configure(options, sanitize_options=False)
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\guessit\api.py", line 175, in configure
    self.rebulk = rules_builder(advanced_config)
                  ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\guessit\rules\__init__.py", line 62, in rebulk_builder
    rebulk.rebulk(website(_config('website')))
                  ~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\guessit\rules\properties\website.py", line 34, in website
    with files('guessit.data') as data_files:
         ~~~~~^^^^^^^^^^^^^^^^
TypeError: 'WindowsPath' object does not support the context manager protocol

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\mnamer\__main__.py", line 22, in main
    frontend = Cli(settings)
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\mnamer\frontends.py", line 68, in __init__
    super().__init__(settings)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\mnamer\frontends.py", line 24, in __init__
    self.targets = Target.populate_paths(self.settings)
                   ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\mnamer\target.py", line 66, in populate_paths
    targets = [cls(file_path, settings) for file_path in file_paths]
               ~~~^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\mnamer\target.py", line 49, in __init__
    self._parse(file_path)
    ~~~~~~~~~~~^^^^^^^^^^^
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\mnamer\target.py", line 126, in _parse
    raw_data = dict(guessit(str(file_path), options))
                    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\guessit\api.py", line 74, in guessit
    return default_api.guessit(string, options)
           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\guessit\api.py", line 225, in guessit
    raise GuessitException(string, options) from err
guessit.api.GuessitException: An internal error has occurred in guessit.
===================== Guessit Exception Report =====================
version=3.7.1
string=C:\Users\krist\Videos\Arcane (2021-2024)\Season 2 (2024)\S02E01\Arcane League of Legends - S02E01 - Heavy is the Crown.eng.sdh.srt
options={'type': None, 'language': None}
--------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\guessit\api.py", line 200, in guessit
    config = self.configure(options, sanitize_options=False)
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\guessit\api.py", line 175, in configure
    self.rebulk = rules_builder(advanced_config)
                  ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\guessit\rules\__init__.py", line 62, in rebulk_builder
    rebulk.rebulk(website(_config('website')))
                  ~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\krist\scoop\apps\python\current\Lib\site-packages\guessit\rules\properties\website.py", line 34, in website
    with files('guessit.data') as data_files:
         ~~~~~^^^^^^^^^^^^^^^^
TypeError: 'WindowsPath' object does not support the context manager protocol
--------------------------------------------------------------------
Please report at https://github.com/guessit-io/guessit/issues.
====================================================================

=============================== CRASH REPORT END ===============================

Dang, it looks like mnamer crashed! Please consider filling an issue at
https://github.com/jkwill87/mnamer/issues along with this report.

kris3713 avatar Nov 22 '24 01:11 kris3713

I think I fixed this issue by manually updating the guessit dependency to 3.8.0

pip install guessit --upgrade

hope this helps @FlawlessCasual17

atilford avatar Jan 21 '25 01:01 atilford

I'll try it out when I get back on my windows machine.

kris3713 avatar Jan 24 '25 05:01 kris3713

Nice, this resolved it for me despite a warning that the new version was incompatible. Thanks!

mangobu avatar Jul 13 '25 17:07 mangobu

I think I fixed this issue by manually updating the guessit dependency to 3.8.0

pip install guessit --upgrade

hope this helps @FlawlessCasual17

for people who installed with uv like me,

  1. Use uv tool dir to find the tools/venv directory for mnamer.
  2. cd to it and mount the venv: .\Scripts\activate
  3. uv pip install guessit --upgrade

santarl avatar Sep 21 '25 21:09 santarl