Skip to content

IndexError: list index out of range - File "jellyfin_kodi\helper\playutils.py", line 641, in get_track_title #948

Open
@Electry

Description

With some of my media files I'm getting an error before playback start, and the subtitle selection dialog doesn't show up.

2024-11-29 21:04:06.424 T:5108     info <general>: JELLYFIN.__main__ -> ERROR::default.py:23 list index out of range
                                                   Traceback (most recent call last):
                                                     File "default.py", line 21, in <module>
                                                       Events()
                                                     File "jellyfin_kodi\entrypoint\default.py", line 108, in __init__
                                                       Actions(server, api_client).play(
                                                     File "jellyfin_kodi\objects\actions.py", line 78, in play
                                                       source = play.select_source(play.get_sources())
                                                     File "jellyfin_kodi\helper\playutils.py", line 126, in select_source
                                                       self.get(source, audio, subtitle)
                                                     File "jellyfin_kodi\helper\playutils.py", line 214, in get
                                                       self.transcode(source, audio, subtitle)
                                                     File "jellyfin_kodi\helper\playutils.py", line 270, in transcode
                                                       manual_tracks = self.get_audio_subs(source, audio, subtitle)
                                                     File "jellyfin_kodi\helper\playutils.py", line 690, in get_audio_subs
                                                       selection = list(["No subtitles"]) + list(
                                                     File "jellyfin_kodi\helper\playutils.py", line 641, in get_track_title
                                                       return streams[track_index]["DisplayTitle"] or ("Track %s" % track_index)
                                                   IndexError: list index out of range

It seems like the key/index within the streams list isn't necessary the same as value in streams[k]['Index'] which is used to populate subs_streams list. This results in out-of-range error while getting the track titles for the subtitle selection dialog.

On my JF instance, the error shows up for some media files that contain embedded subtitles, while also having external .srt subtitle files right next to the video file. I haven't looked how/where the 'Index' value is sourced in the jf server response.

Similar issue might occur with audio_streams and the audio selection dialog (by looking at the source code), but I wasn't able to produce an example.

Dirty and suboptimal fix that I quickly applied to my Kodi device is to loop the streams list and search for the real index.

        def get_track_title(track_index):
            for s in streams:
                if s['Index'] == track_index:
                    return s["DisplayTitle"] or ("Track %s" % track_index)
            return "Track %s" % track_index

But there might be more places where the streams list is accessed incorrectly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions