Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch State Not Synced When Using an External Player #932

Open
RNostrand opened this issue Oct 23, 2024 · 10 comments
Open

Watch State Not Synced When Using an External Player #932

RNostrand opened this issue Oct 23, 2024 · 10 comments

Comments

@RNostrand
Copy link

RNostrand commented Oct 23, 2024

Describe the bug
Watch state is only synced from Jellyfin to Kodi. After watching an episode on Kodi, it gets marked as completed, but moments later will be overwritten by the state on Jellyfin and will be marked as unwatched.

To Reproduce

  1. On Kodi, click to play an episode
  2. Watch any amount of that episode
  3. After playing the episode, wait a few seconds
  4. On Kodi, see status of episode change from watched to unwatched
  5. On Jellyfin, see that watch status is unchanged (still unwatched)

Expected behavior
After watching an episode in Kodi, watch status is synced from Kodi -> Jellyfin. Episode should be marked as watched in both Kodi and Jellyfin.

Logs
Logs

Screenshots
N/A

System (please complete the following information):

  • OS: Windows 10
  • Jellyfin Version: 10.9.11
  • Kodi Version: 21.1.0
  • Addon Version: 1.0.5+py3
  • Playback Mode: Add-On

Additional context
Aside from this add-on, I only have Arctic Horizon 2 as my skin for Kodi.
I am also using mpv as an external player.

@oddstr13
Copy link
Member

Works for me, with the caveat that it blinks back for a bit before finally settling.

Episode done and marked as watched in Kodi -> Episode syncs from Jellyfin, marking as unwatched -> Watched state gets synced as watched.

I have not yet looked into why this is.

@RNostrand RNostrand changed the title Watch State is Only Synced One-Way (Jellyfin -> Kodi) Watch State Not Synced When Using an External Player Oct 28, 2024
@RNostrand
Copy link
Author

It looks like this is due to using an external player. I am able have the status synced if I manually marked the episode as watched in the UI for Kodi. However, after being played with mpv, it does not sync. This is strange because it does update it as watched in Kodi, before being overwritten by the status from Jellyfin.

I do see the playcount being incremented in the logs, so I guess the question is why is the sync not being triggered with the new status in Kodi as the correct status to update in jellyfin.

@it5c0z1mG
Copy link

I use native playback method j4k, it seems new jellyfin update now doesnt recognise the smb network path specified in the library data options file, its broken native as now it only shows the jellyfin data path, ive looked through the updated files but cant see where theyve changed it, i would imagine these 2 issues are linked as it cant locate the file for watched state on external either as there are a few lines in the utils.py kodi file that now error and cannot sync according to the log,

Ive reverted jellyfin back to the previous version and done a library repair and all is back working.

If anyone can work out what theyve changed to cause this hopefully both issues will be fixed together

@RNostrand
Copy link
Author

RNostrand commented Nov 4, 2024

New logs: here
These are what pop out to me as relevant

debug <general>: CSaveFileState::DoWork - Saving file state for video item plugin://plugin.video.jellyfin/0c41907140d802bb58430fed7e2cd79e/2ba47bd38b16cce086c14fde39ad0e9d/?filename=Blue+Box+%282024%29+-+S01E06+-+006+-+Wish+Me+Luck+%5BNF+WEBDL-1080p%5D%5B8bit%5D%5Bx264%5D%5BEAC3+5.1%5D%5BJA%5D-VARYG.mkv&id=ItemId&dbid=10508&mode=play
debug <general>: CSaveFileState::DoWork - Marking video item plugin://plugin.video.jellyfin/0c41907140d802bb58430fed7e2cd79e/2ba47bd38b16cce086c14fde39ad0e9d/?filename=Blue+Box+%282024%29+-+S01E06+-+006+-+Wish+Me+Luck+%5BNF+WEBDL-1080p%5D%5B8bit%5D%5Bx264%5D%5BEAC3+5.1%5D%5BJA%5D-VARYG.mkv&id=ItemId&dbid=10508&mode=play as watched
info <general>: JELLYFIN.jellyfin_kodi.monitor -> DEBUG::jellyfin_kodi\monitor.py:111 [ xbmc: VideoLibrary.OnUpdate ] {
            "item": {
                "id": 10508,
                "type": "episode"
            },
            "playcount": 1
        }

info <general>: JELLYFIN.jellyfin_kodi.objects.actions -> INFO::jellyfin_kodi\objects\actions.py:819  [ update/1 ] kodi_id: 10508 media: episode
...
info <general>: JELLYFIN.jellyfin_kodi.monitor -> DEBUG::jellyfin_kodi\monitor.py:111 [ xbmc: VideoLibrary.OnUpdate ] {
            "id": 10508,
            "type": "episode"
        }

info <general>: JELLYFIN.jellyfin_kodi.objects.actions -> DEBUG::jellyfin_kodi\objects\actions.py:821 Invalid playstate update
info <general>: JELLYFIN.jellyfin_kodi.player -> INFO::jellyfin_kodi\player.py:406 Played info: {'https://{jellyfin-server}/Videos/ItemId/stream?static=true&MediaSourceId=ItemId&api_key={jellyfin-token}': {'Type': 'Episode', 'Id': 'ItemId', 'Path': 'https://{jellyfin-server}/Videos/ItemId/stream?static=true&MediaSourceId=ItemId&api_key={jellyfin-token}', 'PlayMethod': 'DirectStream', 'PlayOption': 'Addon', 'MediaSourceId': 'ItemId', 'Runtime': 14172800000, 'PlaySessionId': '43c7a712f3924e5481d0246290a5c6a6', 'ServerId': None, 'DeviceId': 'DeviceId', 'SubsMapping': {}, 'AudioStreamIndex': 1, 'SubtitleStreamIndex': 2, 'CurrentPosition': 0,  'CurrentEpisode': ... 'playcount': 0, ...
info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> DEBUG::jellyfin_kodi\entrypoint\service.py:208 [ plugin.video.jellyfin: UserDataChanged ] {
            "UserDataList": [
                {
                    "IsFavorite": false,
                    "ItemId": "ItemId",
                    "Key": "429934001006",
                    "LastPlayedDate": "2024-11-04T03:17:23.5036758Z",
                    "PlayCount": 1,
                    "PlaybackPositionTicks": 0,
                    "Played": false
                },
                {
                    "IsFavorite": false,
                    "ItemId": "1a6278185fc15f0a50be4b7bf26809e7",
                    "Key": "429934001",
                    "PlayCount": 0,
                    "PlaybackPositionTicks": 0,
                    "Played": false,
                    "UnplayedItemCount": 1
                }
            ],
            "UserId": "UserId"
        }

What I see from this is this flow:
Playback finishes -> Kodi marks item as watched -> 2 on_update events, one yields "Invalid playstate update" -> Played Info: has that 'CurrentPosition' and 'playcount' as 0 -> add-on writes to Jellyfin with "PlayCount": 1, "PlaybackPositionTicks": 0, "Played": false. -> Kodi reads from Jellyfin, marks item as unwatched

So kodi is writing to Jellyfin, it is just writing incorrect information; namely "Played" being set to 'false' even though the playCount correctly increments.

@fcr
Copy link

fcr commented Nov 8, 2024

I have the same problem.

If it helps isolate the cause, I am using native mode path replacement #926 with Jellyfin 10.10. I also had the problem using the library native paths in Jellyfin 10.9

@fcr
Copy link

fcr commented Nov 15, 2024

After installing #938 I continue to have this problem if I leave the Sync Playback mode as "add-on (default)" so I am pretty sure that this mode is the key to the problem.

That is, watch state is not passed from Kodi to Jellyfin when in "add-on" mode after using an external player or after playing a video with native paths defined for that video library.

@oddstr13
Copy link
Member

After installing #938 I continue to have this problem if I leave the Sync Playback mode as "add-on (default)" so I am pretty sure that this mode is the key to the problem.

That is, watch state is not passed from Kodi to Jellyfin when in "add-on" mode after using an external player or after playing a video with native paths defined for that video library.

Am I understanding you correctly in that you configure jf4kodi in add-on mode, and then add the media directly to Kodi with Kodi's own media scanner?

If so, that is very much not a supported setup configuration.

@fcr
Copy link

fcr commented Nov 16, 2024

Am I understanding you correctly in that you configure jf4kodi in add-on mode, and then add the media directly to Kodi with Kodi's own media scanner?

If so, that is very much not a supported setup configuration.

You misunderstand. I have installed #938 and though j4kodi is in "add-on" Playback mode, I have set a few video folders using the path replacement of #938. I still use Jellyfin's media metadata in Kodi.

What I am trying to say is that the problems that others and i are experiencing with the watched status seems to be due to playing videos from Jellyfin with external or in my case the Kodi player directly. Please note, that in my as as well, manually setting the watched state in Kodi does update Jellyfin.

@Ulrar
Copy link

Ulrar commented Nov 17, 2024

I'm getting (and have forever) the same kind of behavior using native mode. It's a bit difficult sometimes to get rid of the in progress marker on a video, doing a reset progress then a mark as watch gets reverted after a few seconds, most of the time.

I've found that playing the episode to the end (skipping to near the end and waiting for it to complete naturally) is more likely to clear it, although not every time so I could be wrong. Often I just go fix it using the jellyfin app, and let that sync down to Kodi

@oddstr13
Copy link
Member

I'm getting (and have forever) the same kind of behavior using native mode. It's a bit difficult sometimes to get rid of the in progress marker on a video, doing a reset progress then a mark as watch gets reverted after a few seconds, most of the time.

I've found that playing the episode to the end (skipping to near the end and waiting for it to complete naturally) is more likely to clear it, although not every time so I could be wrong. Often I just go fix it using the jellyfin app, and let that sync down to Kodi

Your description here matches #538, and is something I also see with addon mode, altho possibly less frequently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants