jellyfin / jellyfin-kodi

Jellyfin Plugin for Kodi
https://jellyfin.org
GNU General Public License v3.0
815 stars 109 forks source link

Missing Episode Thumbnails prior to playback #505

Open hideYourPretzels opened 3 years ago

hideYourPretzels commented 3 years ago

Describe the bug When a show's episode is added to Kodi the episode thumbnail, although available in Jellyfin, is not loaded in Kodi. Other metadata are loaded properly. After a few seconds of playback and stopping, the thumbnail is available in Kodi.

To Reproduce

  1. Browse to TV Show > Show > Season X
  2. Witness none of the episode has a thumbnail available.
  3. Start playback for 5-10 sec.
  4. Stop playback.
  5. The thumbnail for the played episode only is now available.

Expected behavior Episodes thumbnails should be available in Kodi as soon as they become available in Jellyfin, regardless if the episode has been started or not.

Logs

logs

Screenshots

Before playback After playback

System (please complete the following information):

Additional context

EDIT: Addon version

mcarlton00 commented 3 years ago

I can't replicate this. All episode thumbnails are loading correctly for me. I have a suspicion it may be related to your "unverified https" requests that the logs are mentioning. It's possible that some of our requests are missing the right flag to properly ignore that, so you have some connection attempts to retrieve images are failing. Can you try with IP:port, or is this the only connection method to this server that you have?

hideYourPretzels commented 3 years ago

@mcarlton00 : thank you for your reply. This morning I cannot find any occurrence of https issues on the CoreELEC box.

I went ahead an tried on another device, both connecting on the same server :

It is very strange because the thumbnails are loading now, on this 2nd box. Checking the logs on the Ubuntu laptop, there is no trace of the unverified https requests either. I have enabled DEBUG logs on both side.

Below are logs for the same jellyfin item. Ubuntu box loads fine, the CoreELEC one fails when trying to fetch the file and to extract from the video file. When using cURL or wget, the file is downloaded. I can also view the file fine in firefox using the same URL.

The CFileCache process would start when the file is read, but not before. >> After playback log

2021-05-01 11:04:28.985 T:3979010944 DEBUG: CCurlFile::GetMimeType - https://media.domain.com/Items/76ecc078aa84321764ae9c47dec9756e/Images/Primary/0?Format=original&Tag=980c39e6d33a42115906c565d35df5f3 -> 2021-05-01 11:04:28.986 T:3979010944 DEBUG: CFileCache::Open - opening <Items/76ecc078aa84321764ae9c47dec9756e/Images/Primary/0> using cache 2021-05-01 11:04:28.986 T:3979010944 DEBUG: CurlFile::Open(0x2013d68) https://media.domain.com/Items/76ecc078aa84321764ae9c47dec9756e/Images/Primary/0?Format=original&Tag=980c39e6d33a42115906c565d35df5f3

What could be the issue?

From Ubuntu Box

ubuntu kodi logs

From CoreELEC Box

coreelec kodi logs

[From CoreELEC Box] Trying to cURL or wget the file from Jellyfin Server - it works

curl -o thumb1.jpg https://media.domain.com/Items/76ecc078aa84321764ae9c47dec9756e/Images/Primary/0?Format=original&Tag=980c39e6d33a42115906c565d35df5f3 wget -O thumb1.jpg https://media.domain.com/Items/76ecc078aa84321764ae9c47dec9756e/Images/Primary/0?Format=original&Tag=980c39e6d33a42115906c565d35df5f3

mcarlton00 commented 3 years ago

Well that doesn't make much sense. Why would it be complaining about unverified https requests but now it isn't? Something must have changed along the way.

Does this happen for movies too, or only episodes? Also, when you've gotten a thumbnail to appear, when you restart Kodi is it still there, or has it gone away?

hideYourPretzels commented 3 years ago

I did not update the CoreELEC box since. However, I ran a few times a db clean up and a jellyfin full re-sync, to no avail.

This issue only impacts TV Shows Episode Thumbnails. Movies are fine, even TV Shows other artwork are showing fine... When the thumbnail appears after start of playback, it persists after reboot.

Thanks very much, I appreciate the help :)

toxic0berliner commented 3 years ago

Pithing in since I was redirected from anothe thread where I had a few fiwes to do to my traefik reverse proxy, now I'm having a similar issue : no thumbnail for any tv show can be displayed, and I only get 2 kind of errors in the log :

2021-05-02 17:49:14.731 T:1408    ERROR <general>: CCurlFile::Stat - Failed: Timeout was reached(28) for https://jellyfin.example.com/Items/4746041c2651835e7efc0fc87ad0dac0/Images/Backdrop/0?Format=original&Tag=a60be7877f7cd1a312e1c2a525584d9a
2021-05-02 17:50:02.830 T:17092    INFO <general>: JELLYFIN -> INFO::jellyfin_kodi\jellyfin\__init__.py:100 ---[ START JELLYFINCLIENT ]---
2021-05-02 17:50:02.832 T:17092    INFO <general>: JELLYFIN.entrypoint.default -> INFO::jellyfin_kodi\entrypoint\default.py:73 path: ?filename=04x16+-+A+Second+Prodigy+and+the+Hottest+Tips+for+Pouty+Lips.mkv&id=2924fb6dd0b443334105cb8e80f93eba&dbid=6982&mode=play params: {
                                                       "filename": "04x16 - A Second Prodigy and the Hottest Tips for Pouty Lips.mkv",
                                                       "id": "2924fb6dd0b443334105cb8e80f93eba",
                                                       "dbid": "6982",
                                                       "mode": "play"
                                                   }
2021-05-02 17:50:02.906 T:17092   ERROR <general>: C:\Users\Etienne\AppData\Roaming\Kodi\addons\script.module.urllib3\lib\urllib3\connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'jellyfin.example.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
                                                     warnings.warn(

2021-05-02 17:50:02.946 T:17092    INFO <general>: JELLYFIN.objects.actions -> INFO::jellyfin_kodi\objects\actions.py:67 [ play/2924fb6dd0b443334105cb8e80f93eba ] A Second Prodigy and the Hottest Tips for Pouty Lips
2021-05-02 17:50:03.161 T:17092    INFO <general>: JELLYFIN.helper.playutils -> INFO::jellyfin_kodi\helper\playutils.py:75 {'MediaSources': [{'Protocol': 'File', 'Id': '2924fb6dd0b443334105cb8e80f93eba', 'Path': '\\\\mynas.lan\\video\\Series\\Young Sheldon\\Season 04\\04x16 - A Second Prodigy and the Hottest Tips for Pouty Lips.mkv', 'Type': 'Default', 'Container': 'mkv', 'Size': 119621160, 'Name': '04x16 - A Second Prodigy and the Hottest Tips for Pouty Lips', 'IsRemote': False, 'ETag': '7948aaa1eea9953512dcb2fa1c81660b', 'RunTimeTicks': 10730240000, 'ReadAtNativeFramerate': False, 'IgnoreDts': False, 'IgnoreIndex': False, 'GenPtsInput': False, 'SupportsTranscoding': True, 'SupportsDirectStream': True, 'SupportsDirectPlay': True, 'IsInfiniteStream': False, 'RequiresOpening': False, 'RequiresClosing': False, 'RequiresLooping': False, 'SupportsProbing': True, 'VideoType': 'VideoFile', 'MediaStreams': [{'Codec': 'hevc', 'Language': 'eng', 'TimeBase': '1/1000', 'CodecTimeBase': '1001/24000', 'VideoRange': 'SDR', 'DisplayTitle': '720p HEVC SDR', 'IsInterlaced': False, 'BitRate': 891843, 'RefFrames': 1, 'IsDefault': True, 'IsForced': False, 'Height': 718, 'Width': 1280, 'AverageFrameRate': 23.976025, 'RealFrameRate': 23.976025, 'Profile': 'Main 10', 'Type': 'Video', 'AspectRatio': '16:9', 'Index': 0, 'IsExternal': False, 'IsTextSubtitleStream': False, 'SupportsExternalStream': False, 'PixelFormat': 'yuv420p10le', 'Level': 93}, {'Codec': 'ac3', 'TimeBase': '1/1000', 'CodecTimeBase': '1/48000', 'DisplayTitle': 'Dolby Digital - 5.1 - Default', 'IsInterlaced': False, 'ChannelLayout': '5.1', 'BitRate': 384000, 'Channels': 6, 'SampleRate': 48000, 'IsDefault': True, 'IsForced': False, 'Type': 'Audio', 'Index': 1, 'IsExternal': False, 'IsTextSubtitleStream': False, 'SupportsExternalStream': False, 'Level': 0}], 'MediaAttachments': [], 'Formats': [], 'Bitrate': 1275843, 'RequiredHttpHeaders': {}, 'TranscodingContainer': 'mkv', 'DefaultAudioStreamIndex': 1}], 'PlaySessionId': '6adbdb9becdb4800944c09e23367fb54'}
2021-05-02 17:50:03.163 T:17092    INFO <general>: JELLYFIN.helper.playutils -> INFO::jellyfin_kodi\helper\playutils.py:92 Skip source selection.
2021-05-02 17:50:03.166 T:17092    INFO <general>: JELLYFIN.helper.playutils -> INFO::jellyfin_kodi\helper\playutils.py:197 --[ direct stream ]
2021-05-02 17:50:03.213 T:17092   ERROR <general>: C:\Users\Etienne\AppData\Roaming\Kodi\addons\script.module.urllib3\lib\urllib3\connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'jellyfin.example.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
                                                     warnings.warn(

2021-05-02 17:50:03.358 T:17092    INFO <general>: JELLYFIN.__main__ -> INFO::default.py:39 ---<[ default ]

The first timeout is made to an url that works flawlessly in my browser or even with a local curl command running.

I'm running kodi matrix on Windows 10, but encounter the same issue on kodi matrix for Android TV for example... Http playback works flawlessly. And in fact, I'm having a lot of troubles playing anything in kodi with the jellyfin plugin.

I'm using a valid letsencrypt https certificate with a wildcard, should not impact this, but thought I needed to say cert is valid at least ;)

Looking at urllib3 doc where they actually give us the precise link to their doc, I think this should only be a warning anyway, but as you see it reports as an error in kodi, so maybe something is wrong in the way jellyfin plugin calls it ?

Any help is very appreciated !

Edit: little clarification : using the direct path mode, I am able to play everything and am even seeing the thumbnails. But the progress playing a file is not beeing transmitted back to jellyfin server, a movie started in kodi and half-watched keeps as unwatched an no option to restart where I left out. This has probably something to do with the spinner that stays in front of the playing movie when starting it and I have to press escape for it to go away... Also probably linked to this in the logs :

2021-05-02 18:12:39.437 T:11404    INFO <general>: JELLYFIN.player -> INFO::jellyfin_kodi\player.py:159 -->[ play/fba4056927e98d8843dcb35a33d166b7 ] {'Type': 'Episode', 'Id': 'fba4056927e98d8843dcb35a33d166b7', 'Path': 'smb://mynas.lan/video/Series/How I Met Your Mother/Season 09/09x07 - No Questions Asked.avi', 'PlayMethod': 'DirectPlay', 'PlayOption': 'Native', 'MediaSourceId': 'fba4056927e98d8843dcb35a33d166b7', 'Runtime': 12969205760, 'PlaySessionId': '96c24dc98ad841b3a3caea746fb8f99d', 'ServerId': None, 'DeviceId': 'c206d796-6203-4834-b071-62f288e8a1f9', 'SubsMapping': None, 'AudioStreamIndex': None, 'SubtitleStreamIndex': None, 'CurrentPosition': 1, 'CurrentEpisode': None, 'File': 'smb://mynas.lan/video/Series/How I Met Your Mother/Season 09/09x07 - No Questions Asked.avi', 'Muted': False, 'Volume': 100, 'Server': <jellyfin.client.JellyfinClient object at 0x000001926B8F0700>, 'Paused': False}
2021-05-02 18:13:30.191 T:12828    INFO <general>: Loading skin file: VideoOSD.xml, load type: KEEP_IN_MEMORY
2021-05-02 18:13:31.526 T:12828    INFO <general>: CVideoPlayer::CloseFile()
2021-05-02 18:13:31.528 T:16696    INFO <general>: CVideoPlayer::OnExit()
2021-05-02 18:13:31.529 T:16696    INFO <general>: Closing stream player 1
2021-05-02 18:13:31.529 T:16696    INFO <general>: Waiting for audio thread to exit
2021-05-02 18:13:31.529 T:12828    INFO <general>: VideoPlayer: waiting for threads to exit
2021-05-02 18:13:31.536 T:11908    INFO <general>: thread end: CVideoPlayerAudio::OnExit()
2021-05-02 18:13:31.536 T:16696    INFO <general>: Closing audio device
2021-05-02 18:13:31.553 T:16696    INFO <general>: Deleting audio codec
2021-05-02 18:13:31.553 T:16696    INFO <general>: Closing stream player 2
2021-05-02 18:13:31.553 T:16696    INFO <general>: waiting for video thread to exit
2021-05-02 18:13:31.560 T:15684 WARNING <general>: CVideoPlayerVideo::OutputPicture - timeout waiting for buffer
2021-05-02 18:13:31.560 T:15684    INFO <general>: thread end: video_thread
2021-05-02 18:13:31.560 T:16696    INFO <general>: deleting video codec
2021-05-02 18:13:31.564 T:16696    INFO <general>: Closing stream player 3
2021-05-02 18:13:31.565 T:12828    INFO <general>: VideoPlayer: finished waiting
2021-05-02 18:13:31.565 T:12828    INFO <general>: CVideoPlayer::CloseFile()
2021-05-02 18:13:31.565 T:12828    INFO <general>: VideoPlayer: waiting for threads to exit
2021-05-02 18:13:31.565 T:12828    INFO <general>: VideoPlayer: finished waiting
2021-05-02 18:13:35.193 T:11404   ERROR <general>: EXCEPTION: XBMC is not playing any file
2021-05-02 18:13:35.205 T:11404    INFO <general>: JELLYFIN.player -> ERROR::jellyfin_kodi\player.py:34 XBMC is not playing any file
                                                   Traceback (most recent call last):
                                                     File "jellyfin_kodi\player.py", line 32, in get_playing_file
                                                       return self.getPlayingFile()
                                                   RuntimeError: XBMC is not playing any file

(I was playing something at the time...)

But when using direct plugin method to play, it's even worse, I almos never get to watch a movie, and never get any thumbnail. Sometime the proper timing in hitting the escapt button after starting a play will result in the movie playing, but I can't reproduce easily.

if a dev wants to messege me I could create him/her an account on my jellyfin server that is exposed to the internet if you don't manage to reproduce. I'm running the ghcr.io/linuxserver/jellyfin docker image behing the latest traefik2.4 proxy running in the same docker host.

mcarlton00 commented 3 years ago

So the thumbnails are a bit of a weird case in that we don't download them directly. We put the URLs into the database and then Kodi itself loads them when it's needed. So in that regard it's not something that can be modified or debugged on our end very easily (or possibly at all).

The fact that it doesn't work before playback but does work after is a super odd detail that doesn't make any sense to me. Something else to check is when you view an item info if they show up there or not. (Long click/Right click/C on keyboard) and select "Information".

I'm beginning to wonder if this is perhaps something platform specific, and different builds of Kodi are behaving differently. ie: it's working correctly on my Arch Linux install, but maybe Android based builds aren't loading properly.

toxic0berliner commented 3 years ago

Contrary to the beginning of this issue, I never get the thumbnail working at all, neither before nor after playing, and nothing on the item info as well.

Could very well be platform specific indeed, but at least it affects windows and android builds. I can check on my Ubuntu if I find a package.

I'm really no expert in Kodi plugin, but if I understand well and you simply put the url of the thumbnail in the Kodi DB and let it handle everything else, I'm wondering if it's really the way to go since it will cut the jellyfin plugin out of anything to deal with thumbnails. I thought there would be authentication required to access the thumbnails, and indeed if there isn't I would like to add some... In my sense jellyfin plugin should download the thumbnails and pass the file to Kodi not the raw unauthenticated url. Should/could it be an enhancement ?

Note: I already managed to get the thumbnail working using http (no TLS) and bypassing traefik, but of course this works only on the local network and lets any password and such be transferred in clear text...

Will test the Ubuntu version 9f Kodi, but I expect the same error since I already got it on 2 unrelated versions, I doubt I'm just so unlucky. Meanwhile do you want access onto my jellyfin remotely to test this out ?

mcarlton00 commented 3 years ago

There's a lot of nuance here that I'm trying to skip over for the sake of keeping this for relevant information only. There's already a lot of unnecessary and offtopic things here that make it hard to sort though, and we have multiple issues that are bleeding together which isn't helping keeps things straight (traefik, thumbnails, playback, etc). Because there's only one of me, and about half a dozen issues that I'm trying to juggle through, please keep each issue separate and on topic.

But yes, the images endpoint is unauthenticated in the server. No, you can't add authentication to that, it will break most clients. It has to be that way right now for other features to work properly. We're not going to get into here anymore than that here. We can change it so that images are downloaded via our addon instead. Eventually we might as the server evolves, but that's a lot of work involving more infrastructure code and database migrations for nearly no benefit right now.

The fundamental issue here seems to be some disconnect between Kodi's internal URL retrieval mechanism and the reverse proxy/https endpoint for your servers. Given our previous discussions, I can only assume that traefik isn't behaving properly for some reason that I can't even begin to imagine, and I don't have the time to learn how it works to debug that part for you. I run nginx and everything works perfectly. Tried several linux machines and an android phone. Both https and http. But @hideYourPretzels can replicate it on coreelec, but ubuntu works fine. So that seems to indicate that it's not the reverse proxy itself, but the client device. But if I can't replicate it, I can't fix it. Nothing here makes sense, and since it's not a mission critical feature to have these images load, this is probably going to get sidelined while I try to deal with other more important issues instead.

toxic0berliner commented 3 years ago

I completely understand. Sorry for mixing many topics together, I tend do to that when I'm excited, sorry, and thanks a lot for your clear and calm explanations that completely make sense to me. I'm going to try a few things first on my side, probably even bypass traefik to see how it's doing and patiently wait for you to first deal with the other more important stuff! When I know more I'll probably open a more specific issue for playback since that is indeed more important than thumbnails, and I'll leave this issue just for thumbnails and stop polluting.

Thanks again for the incredible reactivity and clarity despite conciseness which I seem not to be able to these days 😉

hideYourPretzels commented 3 years ago

The fact that it doesn't work before playback but does work after is a super odd detail that doesn't make any sense to me. Something else to check is when you view an item info if they show up there or not. (Long click/Right click/C on keyboard) and select "Information".

When go in Information > Choose art, I get "Thumbnail" and when I click that item, the first item of the next list is "No art", second is "Browse", so Kodi doesn't seem to see anything really. Bottom of the window says "thumb://None". So no luck here.

But if I can't replicate it, I can't fix it. Nothing here makes sense, and since it's not a mission critical feature to have these images load, this is probably going to get sidelined while I try to deal with other more important issues instead.

I have to agree with you. I too appreciate the time you are taking in debugging this.

I tried again tonight to see if reinstalling CoreELEC from scratch would help. It did not. I got the exact same behavior. As I am short on time this week, I will probably have some time over the weekend to see if I can install a previous build. I will report back once I complete the test, because as you said, the client seems to be faulty here.

Meanwhile, I am unexpectedly getting some more life out of this Wetek Hub while I still can, which is a bonus. And if that's the only hick up, oh well !

hideYourPretzels commented 3 years ago

By the way, I also tried installing on an Samsung Galaxy Tab S2 running LineageOS 16.1, Kodi Matrix 19.0 and Addon 0.7.3+py3 and everything is also fine: Thumbs are loading as expected...

lukefor commented 2 years ago

This was driving me mad - on certain platforms (CoreELEC), episode art and fullscreen fanart were randomly not displaying (some art worked, some didn't, and as the OP describes, playing an item encourages the art to load). On other platforms (Android/Windows) everything just worked.

It turned out to be an issue with HTTP 2.0 being enabled on my nginx reverse proxy. I thought I had disabled this, but didn't realise that if HTTP 2.0 is enabled for any server block, it is forcibly enabled for all of them (per IP/port?). Disabling HTTP 2.0 resolved all issues, even including another issue where Kodi on an Amazon Fire Stick could not play anything without buffering or terminating playback at random

Raised a documentation issue as the example for nginx uses http2: https://github.com/jellyfin/jellyfin-docs/issues/602

Based on the platform variation and the fire stick issue (and considering that also happened when using native mode with 'Shared network folder' set to a HTTPS URL), I don't think this is a Jellyfin-Kodi bug, but instead a Kodi bug