im85288 / service.upnext

GNU General Public License v2.0
81 stars 42 forks source link

Up Next + Jellyfin server #297

Closed tundrablasen closed 4 months ago

tundrablasen commented 1 year ago

Im using up next in kodi with the official jellyfin kodi addon to populate my media library. https://github.com/jellyfin/jellyfin-kodi

up next works fine with that setup for the first episode. (I play episode 1, and in the end of it up next comes up to ask if I wanna play episode 2.)

but when I continue watch episode 2, in the end of episode 2, no pop up comes, to ask for playing episode 3.

In the settings I have set it up that after 3 episodes it should ask if I’m still watching.

When I’m manually stopping the playback and start to play again, the cycle starts again.

did anybody notice this behaviour?

MoojMidge commented 1 year ago

The way Jellyfin syncs data to the Kodi library results in some odd issues.

Without a debug log it will be almost impossible to know what the issue is, but it may be because sometimes Jellyfin does not correctly update c18 (path to episode file) in the episodes table of the Kodi video library database and instead leaves the value as null, which can result in the multi-episode file check failing in Up Next.

K-Zawis commented 1 year ago

I have the same issue. When I play the series, the first episode plays out correctly, then the "up next" pop up shows up and plays the next episode. I do not have the "are you still watching?" pop up after 3 videos so I should be seeing the "Up next" instead.

Same behaviour. Nothing shows up and the previous episode starts playing instead which I have to manually turn off, and then start up the next episode. The Episodes I was watching are roughly ~1min long and have no end credits so I was able to see this additional behaviour.

The last few occurences of upnext in the log shows the following lines:

2023-05-21 23:59:32.890 T:20790   error <general>: EXCEPTION: Kodi is not playing any file
2023-05-21 23:59:32.891 T:20790   debug <CAddonSettings[0@service.upnext]>: trying to load setting definitions from old format...
2023-05-21 23:59:32.895 T:20790   debug <general>: [service.upnext] UpNextMonitor -> Up Next tracking stopped, failed player.getPlayingFile()
2023-05-21 23:59:33.074 T:21748    info <general>: thread end: CVideoPlayerAudio::OnExit()

Which seems to be where it dies only appearing once more after this with same old format log.

Hope this helps.

MoojMidge commented 1 year ago

Thanks for the debug log. Unfortunately they don't seem to show anything too unusual with Up Next.

Four videos are played in the debug log.

The last playback is stopped which is why Up Next tracking is stopped and no popup is shown.

The first three playback events have data sent from Jellyfin to Up Next providing details of the video being played and the next video to play.

The first two playback events have data sent back from Up Next to Jellyfin to play the next video. At this point Up Next is no longer involved with playback and I am not really sure what Jellyfin is doing here, but the playback appears to be working.

The third playback event has Up Next start processing the data sent from Jellyfin, but for some reason a playlist has been created by Jellyfin and you have disabled playlist handling in the Up Next settings. As a result Up Next stops because it has been set not to work with playlists.

A similar thing happens in your non-debug log. Jellyfin sends data to Up Next, and Up Next sends it back the first time, however after this a playlist is created, and then Up Next does what it has been set to do, which is nothing.

Don't know why this playlist is being created, but that is the source of the problem, and also why the video gets re-played.

Note that simply enabling playlist handling in Up Next is unlikely to resolve the problem because of the way Jellyfin integrates with Up Next, but you can give it a try and see what happens.

K-Zawis commented 1 year ago

Yeah sadly this is the case.

While enabling playlists now shows the Up Next widget on the second episode, it's still the same behavior of playing the originally opened episode once it finishes. I can see that the OP has also opened a ticket on the Jellyfin4Kodi github page so we'll just have to wait and see how, and if, they respond.

Thanks anyways!

MoojMidge commented 1 year ago

I can see that the OP has also opened a ticket on the Jellyfin4Kodi github page so we'll just have to wait and see how, and if, they respond.

You can point them to this issue, as the following may be of help.

The issue with the playlist is likely stemming from this bit of code in Jellyfin for Kodi

There are a few edge cases where the logic being used here won't work reliably. My memory is hazy, but amongst other things the following could happen with Player event messaging which may cause issues:

Jellyfin for Kodi looks like it tries to add the next video at the start of the playlist here, if the playlist was meant to be cleared. However it doesn't actually check that the playlist was cleared, so when it tries to play the playlist it continues playing at the current point in the playlist, which is now the start of the episode that was just played, because the new episode has been inserted before the previous episode.

There are a few things that could be done to improve the event monitoring, but perhaps the simplest way to fix this particular problem you are having, would be some combination of the following:

tundrablasen commented 1 year ago

I can see that the OP has also opened a ticket on the Jellyfin4Kodi github page so we'll just have to wait and see how, and if, they respond.

You can point them to this issue, as the following may be of help.

The issue with the playlist is likely stemming from this bit of code in Jellyfin for Kodi

There are a few edge cases where the logic being used here won't work reliably. My memory is hazy, but amongst other things the following could happen with Player event messaging which may cause issues:

  • Player.OnStop may not fire if resuming the next video being played. Instead Player.OnResume fires for the current video being played, when it stops. This seems like a bug, but has been like this for a long time.
  • Player.OnStop may not fire when changing streams. Most commonly an issue with the PVR component of Kodi, but can also occur with streams or plugin urls in a playlist.
  • Kodi may have started playing the next video before the 3s delay has elapsed, and in some instances Player.Stop may only fire after the next video has started playing. Both situations will mean that the playlist that Jellyfin is creating on the fly doesn't get cleared.

Jellyfin for Kodi looks like it tries to add the next video at the start of the playlist here, if the playlist was meant to be cleared. However it doesn't actually check that the playlist was cleared, so when it tries to play the playlist it continues playing at the current point in the playlist, which is now the start of the episode that was just played, because the new episode has been inserted before the previous episode.

There are a few things that could be done to improve the event monitoring, but perhaps the simplest way to fix this particular problem you are having, would be some combination of the following:

  • Check whether the current position of the playlist is at the start to identify whether the playlist was cleared, and if not, clear it properly.
  • Always insert a new video at the current position of the playlist.
  • Play the playlist with a startpos parameter set to the index where the new video was inserted, rather than the default current position of the playlist.

Done,

linked your post to To the issue in their repo https://github.com/jellyfin/jellyfin-kodi/issues/717#issuecomment-1558919025

qwerty12 commented 11 months ago

For what it's worth, when I upgraded from Kodi 20.2, with Jellyfin 0.7.11+py3 (not Jellycon) and Up Next 1.1.9+matrix.1 already installed, to prerelease build v21 Alpha 3, without me changing a thing, Next Up suddenly started working with episodes already in Kodi's local database (via JF) and episodes added to my JF server afterwards. No matter which episode I start playback from, I will see Next Up's prompt at the end - and it shows up again at the end when playing the next episode and so on.

tundrablasen commented 11 months ago

Nice. Let’s hope it stays like that

MoojMidge commented 11 months ago

@qwerty12 - can you provide a debug log showing it working? It would be interesting to see what has changed.

qwerty12 commented 11 months ago

@MoojMidge I'm sorry, I'd very much like to; however, with <advancedsettings><loglevel hide="true">2</loglevel></advancedsettings> in my advancedsettings.xml file and with Up Next's Log level setting set to Debug, kodi.log isn't written to and its file size remains 3B no matter how many times I fully exit Kodi and restart it.

MoojMidge commented 11 months ago

That is strange. What platform are you on? Does the same thing happen when you don't have the loglevel entry in your advancedsettings.xml file, and instead enable debug logging via Kodi settings?

The 3 byte log file means that Kodi is writing the UTF-8 BOM to the log file, but not any actual log messages.

CeruleanRed commented 4 months ago

Has there been any movement on this since it was originally posted? Have also run into this issue, but unlike the original poster my issue started when upgrading to Kodi 21 and Jellyfin for Kodi 1.0.3

MoojMidge commented 4 months ago

There is nothing to be done about this in Up Next. The issue needs to be resolved in the Jellyfin plugin

Schaka commented 1 month ago

I came across this issue when trying to identify my issue. Jellyfin 10.9.9, Jellyfin for Kodi 1.0.4 and Kodi 21.

When using the native Kodi functionality to automatically play the next episode, it never does anything. Using the Up Next plugin, I've not had any issues with it showing the pop up.

However, I've basically never actually gotten it to play the next episode. It shows the preview correctly and once I click on it to play the next episode, I see a pop up in the top right that the playlist item couldn't be found and nothing happens.

Is this related? Has anyone else experienced anything like it?

MoojMidge commented 1 month ago

Afaik this was already resolved in the Jellyfin plugin, so it is unlikely to be related to this specific issue.

If you believe there is a problem with Up Next then you will should create a new issue and provide a debug log in order for it to be investigated.