Montellese / mediaimporter.emby

Media importer add-on for Kodi to import items from Emby servers into Kodi
GNU General Public License v2.0
12 stars 3 forks source link

TV Shows unable to synchronize: TypeError: 'dict_keys' object is not subscriptable #38

Closed mikekatica closed 3 years ago

mikekatica commented 3 years ago

Bug report

Describe the bug

When adding a TV Shows media source from Emby, the sync fails with an error message relating to subscribing to a "dict_keys" object.

Expected Behavior

Here is a clear and concise description of what was expected to happen:

The sync should succeed, adding all the TV shows in the Emby library to Kodi.

Actual Behavior

The sync fails, with the above error message.

Possible Fix

Fix the code issue with treating a dict_keys object like a dictionary, I'll probably just submit a PR for this.

To Reproduce

Steps to reproduce the behavior:

  1. Add an emby media source
  2. Add a TV show library
  3. try to synchronize it
  4. Error message shows up.

Debuglog

The debuglog can be found here:

2021-01-20 18:59:01.238 T:7692     INFO <general>: [mediaimporter.emby] Emby Media Import importer started
2021-01-20 18:59:01.272 T:7692     INFO <general>: CPythonInvoker(24, C:\Users\kodi\AppData\Roaming\Kodi\addons\mediaimporter.emby\importer.py): script successfully run
2021-01-20 18:59:01.337 T:7692     INFO <general>: Python interpreter stopped
2021-01-20 18:59:03.321 T:8636     INFO <general>: initializing python engine.
2021-01-20 18:59:03.974 T:8636     INFO <general>: [mediaimporter.emby] Emby Media Import importer started
2021-01-20 18:59:05.890 T:8636     INFO <general>: CPythonInvoker(25, C:\Users\kodi\AppData\Roaming\Kodi\addons\mediaimporter.emby\importer.py): script successfully run
2021-01-20 18:59:05.968 T:8636     INFO <general>: Python interpreter stopped
2021-01-20 18:59:13.853 T:9028     INFO <CGUIDialogMediaImportInfo>: settings for import emby://b95257e0977749e7a4b4beff699e05ab/ (tvshow, season, episode) saved
2021-01-20 18:59:13.870 T:8672     INFO <general>: [mediaimporter.emby] [observer] media import emby://b95257e0977749e7a4b4beff699e05ab/ (['tvshow', 'season', 'episode']) from "emby" (emby://b95257e0977749e7a4b4beff699e05ab/) updated
2021-01-20 18:59:16.257 T:9028     INFO <general>: Loading skin file: DialogContextMenu.xml, load type: KEEP_IN_MEMORY
2021-01-20 18:59:19.028 T:9028     INFO <CMediaImportManager>: import task for emby://b95257e0977749e7a4b4beff699e05ab/ (tvshow, season, episode) started
2021-01-20 18:59:19.028 T:8844     INFO <CMediaImportTaskProcessorJob>: starting local items retrieval task for items from emby://b95257e0977749e7a4b4beff699e05ab/ (tvshow, season, episode)...
2021-01-20 18:59:19.171 T:8844     INFO <CMediaImportTaskProcessorJob>: starting import items retrieval task for items from emby://b95257e0977749e7a4b4beff699e05ab/ (tvshow, season, episode)...
2021-01-20 18:59:19.171 T:4844     INFO <general>: initializing python engine.
2021-01-20 18:59:19.822 T:4844     INFO <general>: [mediaimporter.emby] Emby Media Import importer started
2021-01-20 18:59:19.823 T:4844     INFO <general>: [mediaimporter.emby] importing ['tvshow', 'season', 'episode'] items from "emby" (emby://b95257e0977749e7a4b4beff699e05ab/)...
2021-01-20 18:59:19.853 T:4844     INFO <general>: [mediaimporter.emby] forcing a full synchronization to import ['tvshow', 'season', 'episode'] items from "emby" (emby://b95257e0977749e7a4b4beff699e05ab/) because some related settings have changed
2021-01-20 18:59:19.853 T:4844     INFO <general>: [mediaimporter.emby] importing tvshow items from "emby" (emby://b95257e0977749e7a4b4beff699e05ab/)...
2021-01-20 18:59:19.853 T:4844     INFO <general>: [mediaimporter.emby] importing tvshow items from "Anime" view from "emby" (emby://b95257e0977749e7a4b4beff699e05ab/)...
2021-01-20 18:59:20.805 T:4844     INFO <general>: [mediaimporter.emby] importing tvshow items from "TV shows" view from "emby" (emby://b95257e0977749e7a4b4beff699e05ab/)...
2021-01-20 18:59:20.909 T:4844     INFO <general>: [mediaimporter.emby] 134 tvshow items imported from "emby" (emby://b95257e0977749e7a4b4beff699e05ab/)
2021-01-20 18:59:20.910 T:4844     INFO <general>: [mediaimporter.emby] importing season items from "emby" (emby://b95257e0977749e7a4b4beff699e05ab/)...
2021-01-20 18:59:20.911 T:4844     INFO <general>: [mediaimporter.emby] importing season items from "Anime" view from "emby" (emby://b95257e0977749e7a4b4beff699e05ab/)...
2021-01-20 18:59:22.089 T:4844     INFO <general>: [mediaimporter.emby] importing season items from "TV shows" view from "emby" (emby://b95257e0977749e7a4b4beff699e05ab/)...
2021-01-20 18:59:22.468 T:4844     INFO <general>: [mediaimporter.emby] 198 season items imported from "emby" (emby://b95257e0977749e7a4b4beff699e05ab/)
2021-01-20 18:59:22.468 T:4844     INFO <general>: [mediaimporter.emby] importing episode items from "emby" (emby://b95257e0977749e7a4b4beff699e05ab/)...
2021-01-20 18:59:22.468 T:4844     INFO <general>: [mediaimporter.emby] importing episode items from "Anime" view from "emby" (emby://b95257e0977749e7a4b4beff699e05ab/)...
2021-01-20 18:59:22.656 T:4844    ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'TypeError'>
                                                   Error Contents: 'dict_keys' object is not subscriptable
                                                   Traceback (most recent call last):
                                                     File "C:\Users\kodi\AppData\Roaming\Kodi\addons\mediaimporter.emby\importer.py", line 17, in <module>
                                                       importer.run(sys.argv)
                                                     File "C:\Users\kodi\AppData\Roaming\Kodi\addons\mediaimporter.emby\lib\importer.py", line 999, in run
                                                       actionMethod(handle, options)
                                                     File "C:\Users\kodi\AppData\Roaming\Kodi\addons\mediaimporter.emby\lib\importer.py", line 779, in execImport
                                                       items.extend(importItems(handle, embyServer, url, mediaType, view.id, embyMediaType=embyMediaType,
                                                     File "C:\Users\kodi\AppData\Roaming\Kodi\addons\mediaimporter.emby\lib\importer.py", line 449, in importItems
                                                       item = kodi.Api.toFileItem(embyServer, itemObj, mediaType, embyMediaType, viewName,
                                                     File "C:\Users\kodi\AppData\Roaming\Kodi\addons\mediaimporter.emby\lib\kodi.py", line 277, in toFileItem
                                                       Api.fillVideoInfos(embyServer, itemId, itemObj, mediaType, item,
                                                     File "C:\Users\kodi\AppData\Roaming\Kodi\addons\mediaimporter.emby\lib\kodi.py", line 536, in fillVideoInfos
                                                       defaultUniqueId = Api._mapDefaultUniqueId(uniqueIds, mediaType)
                                                     File "C:\Users\kodi\AppData\Roaming\Kodi\addons\mediaimporter.emby\lib\kodi.py", line 764, in _mapDefaultUniqueId
                                                       return uniqueIdKeys[0]
                                                   TypeError: 'dict_keys' object is not subscriptable
                                                   -->End of Python script error report<--

2021-01-20 18:59:22.730 T:4844     INFO <general>: Python interpreter stopped
2021-01-20 18:59:22.736 T:8844  WARNING <CMediaImportTaskProcessorJob>: import items retrieval task for items from emby://b95257e0977749e7a4b4beff699e05ab/ (tvshow, season, episode) failed

Your Environment

Used Operating system:

note: Once the issue is made we require you to update it with new information or Kodi versions should that be required. Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.

mikekatica commented 3 years ago

This looks to be an issue with just 0.0.9 plugin version. 0.0.10 is working. Might want to note somewhere that Emby 0.0.9 is broken.

Montellese commented 3 years ago

Thanks for the report. Yeah, this is a known issue but it has only been reported by 2 ppls (plus myself) so I assumed it wasn't that critical. Sorry for the inconvenience.

mikekatica commented 3 years ago

Yeah, it seems to only happen if you try to import multiple TV Show libraries from Emby, hence the dictionary of libraries returned. Now that it's fixed, shouldn't be an issue, but it makes the plugin version in the repo unusable if you have multiple TV show libraries.

Montellese commented 3 years ago

Yeah, it seems to only happen if you try to import multiple TV Show libraries from Emby, hence the dictionary of libraries returned. Now that it's fixed, shouldn't be an issue, but it makes the plugin version in the repo unusable if you have multiple TV show libraries.

Thanks for that hint. That makes sense.