pynfogen icon indicating copy to clipboard operation
pynfogen copied to clipboard

TypeError: string indices must be integers

Open LYS1THEA opened this issue 2 years ago • 4 comments

> nfo generate -tvdb 305074 -imdb tt5626028 My.Hero.Academia.S06E01.1080p.CR.WEB-DL.DDP2.0.H.264-GROUP.mkv episode 1 "My Hero Academia" 6
Traceback (most recent call last):
  File "C:\Users\username\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\username\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\Scripts\nfo.exe\__main__.py", line 7, in <module>
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1626, in _process_result
    value = ctx.invoke(self._result_callback, value, **ctx.params)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\pynfogen\cli\generate.py", line 122, in generator
    nfo_txt = nfo.run(template_text, art=artwork_text, **template_vars)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\pynfogen\nfo.py", line 116, in run
    template = CustomFormats().format(template, **variables)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\string.py", line 161, in format
    return self.vformat(format_string, args, kwargs)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\string.py", line 165, in vformat
    result, _ = self._vformat(format_string, args, kwargs, used_args, 2)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\string.py", line 205, in _vformat
    obj, arg_used = self.get_field(field_name, args, kwargs)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\string.py", line 278, in get_field
    obj = obj[i]
TypeError: string indices must be integers

LYS1THEA avatar Apr 11 '23 19:04 LYS1THEA

Same issue here

CitizenDev avatar Oct 04 '23 14:10 CitizenDev

This indicates an issue with one of the formatting variables inside the NFO Template. Though may also happen in your Description Template. The exact issue cannot be inferred from the log.

However, you can see it's having an error doing obj[i] where obj is a string and i is ALSO a string. E.g. foo = "Hello World"; foo["Hello"]. This is a Runtime error. It is not immediately clear as to why this occurred. In the example templates only the imdb is accessed via indexing ([...]), specifically to get the title and year. The Cinemageor project is used to talk with IMDb and has been having issues with IMDb's updates. Even the latest release is fairly broken. What's possible is the imdb variable exposed to templates is not as expected and is now a string or some other crap variable.

Therefore, this would be an upstream issue that I cannot fix here. A temporary solution is to install the latest code from the Cinemagoer GitHub repository, which is never really recommended for various reasons, but I have done this before and it worked fine.

rlaphoenix avatar Oct 05 '23 08:10 rlaphoenix

This indicates an issue with one of the formatting variables inside the NFO Template. Though may also happen in your Description Template. The exact issue cannot be inferred from the log.

However, you can see it's having an error doing obj[i] where obj is a string and i is ALSO a string. E.g. foo = "Hello World"; foo["Hello"]. This is a Runtime error. It is not immediately clear as to why this occurred. In the example templates only the imdb is accessed via indexing ([...]), specifically to get the title and year. The Cinemageor project is used to talk with IMDb and has been having issues with IMDb's updates. Even the latest release is fairly broken. What's possible is the imdb variable exposed to templates is not as expected and is now a string or some other crap variable.

Therefore, this would be an upstream issue that I cannot fix here. A temporary solution is to install the latest code from the Cinemagoer GitHub repository, which is never really recommended for various reasons, but I have done this before and it worked fine.

It's a stock example template movie.nfo from this repo.

CitizenDev avatar Oct 05 '23 12:10 CitizenDev

Then yeah it's likely the Cinemagoer project. I'll look further into it and see if I can find a solution.

rlaphoenix avatar Oct 05 '23 14:10 rlaphoenix