jkwill87 / mnamer

media file renaming and organizing tool
https://pypi.org/project/mnamer
MIT License
784 stars 67 forks source link

mnamer crashed #289

Open icountu opened 8 months ago

icountu commented 8 months ago

======================= --------------------------------- environment ----------------------------------

HoLuLuLu commented 8 months ago

I have same issue with python version 3.12.1. I think this issue also could relate to #203

frank42hh commented 4 months ago

Hi, I seem to have the same problem:

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

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

 - date = 2024-05-18
 - platform = Linux-6.1.90-1-MANJARO-x86_64-with-glibc2.39
 - arguments = ['Dr.House 8x04 Arzt und Glücksritter.mkv', 'Dr.House 8x15 Hetzen und Petzen.mkv', 'Dr.House 8x17 Henry und die Frauen.mkv', 'Dr.House 8x18 Trug und Schluß.mkv']
 - cache location = /home/freddy/.cache/mnamer-py3.12.sqlite
 - python version = 3.12.3
 - mnamer version = 2.5.5
 - appdirs version = 1.4.4
 - guessit version = 3.8.0
 - requests version = 2.31.0
 - requests cache version = 1.2.0
 - teletype version = 1.3.4

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

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/mnamer/__main__.py", line 22, in main
    frontend = Cli(settings)
               ^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/mnamer/frontends.py", line 68, in __init__
    super().__init__(settings)
  File "/usr/lib/python3.12/site-packages/mnamer/frontends.py", line 24, in __init__
    self.targets = Target.populate_paths(self.settings)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/mnamer/target.py", line 66, in populate_paths
    targets = [cls(file_path, settings) for file_path in file_paths]
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/mnamer/target.py", line 49, in __init__
    self._parse(file_path)
  File "/usr/lib/python3.12/site-packages/mnamer/target.py", line 167, in _parse
    self.metadata.language = path_data.get("language")
    ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/mnamer/metadata.py", line 177, in __setattr__
    super().__setattr__(key, value)
  File "/usr/lib/python3.12/site-packages/mnamer/metadata.py", line 69, in __setattr__
    value = converter(value)
            ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/mnamer/language.py", line 63, in parse
    raise MnamerException("Could not determine language")
mnamer.exceptions.MnamerException: Could not determine language

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

Interestingly, this happens only with few episode files, not with all. I don't see a pattern yet. And it doesn't matter if language is set to null or to "de".

frank42hh commented 4 months ago

Additional input: I don't know why, but it seems to relate to the filename, because I just had the same problem and was able to circumvent it by renaming the file in question:

freddy@hades Dr. House % mnamer -b --id-tvdb=73255 --language=de Dr.House.2x01.Ihr.Ich.und.Hyppokrates.mkv

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

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

 - date = 2024-06-05
 - platform = Linux-6.1.90-1-MANJARO-x86_64-with-glibc2.39
 - arguments = ['-b', '--id-tvdb=73255', '--language=de', 'Dr.House.2x01.Ihr.Ich.und.Hyppokrates.mkv']
 - cache location = /home/freddy/.cache/mnamer-py3.12.sqlite
 - python version = 3.12.3
 - mnamer version = 2.5.5
 - appdirs version = 1.4.4
 - guessit version = 3.8.0
 - requests version = 2.32.2
 - requests cache version = 1.2.0
 - teletype version = 1.3.4

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

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/mnamer/__main__.py", line 22, in main
    frontend = Cli(settings)
               ^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/mnamer/frontends.py", line 68, in __init__
    super().__init__(settings)
  File "/usr/lib/python3.12/site-packages/mnamer/frontends.py", line 24, in __init__
    self.targets = Target.populate_paths(self.settings)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/mnamer/target.py", line 66, in populate_paths
    targets = [cls(file_path, settings) for file_path in file_paths]
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/mnamer/target.py", line 49, in __init__
    self._parse(file_path)
  File "/usr/lib/python3.12/site-packages/mnamer/target.py", line 167, in _parse
    self.metadata.language = path_data.get("language")
    ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/mnamer/metadata.py", line 177, in __setattr__
    super().__setattr__(key, value)
  File "/usr/lib/python3.12/site-packages/mnamer/metadata.py", line 69, in __setattr__
    value = converter(value)
            ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/mnamer/language.py", line 63, in parse
    raise MnamerException("Could not determine language")
mnamer.exceptions.MnamerException: Could not determine language

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

Fix it by removing the episode description from the filename: freddy@hades Dr. House % mv Dr.House.2x01.Ihr.Ich.und.Hyppokrates.mkv Dr.House.2x01.mkv

Result:

freddy@hades Dr. House % mnamer -b --id-tvdb=73255 --language=de Dr.House.2x01.mkv                        
Starting mnamer

Processing Episode "Dr.House.2x01.mkv" (1.57GB)
moving to /net/lager/videos/Serien/Andere/Dr. House/Dr. House - S02E01 - Ihr, Ich Und Hippokrates.mkv
OK!

1 out of 1 files processed successfully
HoLuLuLu commented 3 months ago

The problem

The exception occurs because the guessit module used by mnamer identifies some words in the title as language indicators and tries to convert them. This produces a crash with an exception. I already made a pull request to fix that problem, but @jkwill87 seems not to be active in this repository for a while.

Workaround approach

You can replace the target.py file in mnamer with the fixed version of mine. This change will be overwritten with the next update, but hopefully it will be fixed then.

Steps for workaround approach

  1. Download the fixed target.py from Github
  2. Localize your mnamer package. Use this command: python -c "import mnamer; print(mnamer.__file__[:-12])"
  3. Replace target.py from the mnamer package location with the fixed one.
  4. You're done! The exception shouldn't be thrown anymore, but the language detection could be wrong.