Items appear in "Unplayed" folder listing despite being recently played #7825

Open
opened 2025-12-22 06:25:49 +01:00 by backuprepo · 4 comments
Owner

Originally created by @mthaddon on GitHub (Nov 23, 2025).

Description of the bug

I'm using 10.11.3+ubu2404. I have a folder with a large number of "Home Videos and Photos" (335 currently). I have a web client and Android TV client that both have the same folder set with the "Unplayed" filter, but after watching a video, that video will still sometimes appear in both clients.

I've confirmed in the SQLITE backend the content in question is correctly marked as watched/played:

sqlite3 jellyfin.db "SELECT UserData.Played, UserData.PlayCount, UserData.PlaybackPositionTicks, UserData.LastPlayedDate FROM UserData, BaseItems WHERE UserData.ItemId = BaseItems.Id AND UserData.UserId = '3C78E926-89D6-4BFC-9133-657ADCC33D13' AND BaseItems.Id = 'E0D424CD-3257-5297-8F14-999D654FD8AF';"
1|1|0|2025-11-23 15:21:30.2429039

If I run "Scan all libraries" from the Dashboard the issues no longer presents itself.

Reproduction steps

  1. Have a large number of items in a "Home Videos and Photos" media library.
  2. Set the filter to "Unplayed".
  3. Watch a video and confirm it's marked as "Watched".
  4. See that it still shows in the media library, but when you navigate to the item detail page the "watched" check mark is checked.
  5. Confirm via SQL that it has been watched (as above).

What is the current bug behavior?

The item is still visible in an "Unplayed" filter, when it shouldn't be.

What is the expected correct behavior?

The item should be hidden from an "Unplayed" filter.

Jellyfin Server version

10.11.3

Specify commit id

No response

Specify unstable release number

No response

Specify version number

No response

Specify the build version

10.11.3

Environment

- OS: Ubuntu 24.04
- Linux Kernel: 6.8.0-86-generic
- Virtualization: N/A
- Clients: Web and Android TV
- Browser: Chrome
- FFmpeg Version: jellyfin-ffmpeg7 7.1.2-4-noble          
- Playback Method: Direct Play
- Hardware Acceleration: none
- GPU Model: none
- Plugins: none
- Reverse Proxy: none
- Base URL: none
- Networking: N/A
- Jellyfin Data Storage: local HDD
- Media Storage: external USB drive, mounted to `/srv/jellyfin` via `/etc/fstab` using ext4 filesystem
- External Integrations: None

Jellyfin logs

N/A

FFmpeg logs

N/A

Client / Browser logs

N/A

Relevant screenshots or videos

N/A

Additional information

N/A

Originally created by @mthaddon on GitHub (Nov 23, 2025). ### Description of the bug I'm using `10.11.3+ubu2404`. I have a folder with a large number of "Home Videos and Photos" (335 currently). I have a web client and Android TV client that both have the same folder set with the "Unplayed" filter, but after watching a video, that video will still sometimes appear in both clients. I've confirmed in the SQLITE backend the content in question is correctly marked as watched/played: ``` sqlite3 jellyfin.db "SELECT UserData.Played, UserData.PlayCount, UserData.PlaybackPositionTicks, UserData.LastPlayedDate FROM UserData, BaseItems WHERE UserData.ItemId = BaseItems.Id AND UserData.UserId = '3C78E926-89D6-4BFC-9133-657ADCC33D13' AND BaseItems.Id = 'E0D424CD-3257-5297-8F14-999D654FD8AF';" 1|1|0|2025-11-23 15:21:30.2429039 ``` If I run "Scan all libraries" from the Dashboard the issues no longer presents itself. ### Reproduction steps 1. Have a large number of items in a "Home Videos and Photos" media library. 2. Set the filter to "Unplayed". 3. Watch a video and confirm it's marked as "Watched". 4. See that it still shows in the media library, but when you navigate to the item detail page the "watched" check mark is checked. 5. Confirm via SQL that it has been watched (as above). ### What is the current _bug_ behavior? The item is still visible in an "Unplayed" filter, when it shouldn't be. ### What is the expected _correct_ behavior? The item should be hidden from an "Unplayed" filter. ### Jellyfin Server version 10.11.3 ### Specify commit id _No response_ ### Specify unstable release number _No response_ ### Specify version number _No response_ ### Specify the build version 10.11.3 ### Environment ```markdown - OS: Ubuntu 24.04 - Linux Kernel: 6.8.0-86-generic - Virtualization: N/A - Clients: Web and Android TV - Browser: Chrome - FFmpeg Version: jellyfin-ffmpeg7 7.1.2-4-noble - Playback Method: Direct Play - Hardware Acceleration: none - GPU Model: none - Plugins: none - Reverse Proxy: none - Base URL: none - Networking: N/A - Jellyfin Data Storage: local HDD - Media Storage: external USB drive, mounted to `/srv/jellyfin` via `/etc/fstab` using ext4 filesystem - External Integrations: None ``` ### Jellyfin logs ```shell N/A ``` ### FFmpeg logs ```shell N/A ``` ### Client / Browser logs N/A ### Relevant screenshots or videos N/A ### Additional information N/A
backuprepo added the
bug
confirmed
labels 2025-12-22 06:25:49 +01:00
Author
Owner

@mthaddon commented on GitHub (Nov 26, 2025):

If I look at the web client, I see that it's using the following URL for the folder view which is displaying this problem:

http://127.0.0.1:8096/Users/{userId}/Items?StartIndex=0&Limit=100&Fields=PrimaryImageAspectRatio%2CSortName%2CPath%2CChildCount%2CMediaSourceCount%2CPrimaryImageAspectRatio&ImageTypeLimit=1&ParentId={folderId}&SortBy=SortName&SortOrder=Ascending&Filters=IsUnplayed

If I visit this URL when the problem is presenting, I see the items in it which I've recently played and expect to be marked as Played and not included in this view. They have the following properties:

...
      "UserData": {
        "PlaybackPositionTicks": 0,
        "PlayCount": 0,
        "IsFavorite": false,
        "Played": false,
...

However, if I run the following query I see in the database that they have been marked as Played:

sqlite3 jellyfin.db "SELECT BaseItems.Name, UserData.Played, UserData.PlayCount, UserData.PlaybackPositionTicks, UserData.LastPlayedDate FROM UserData, BaseItems WHERE UserData.ItemId = BaseItems.Id AND UserData.UserId = '{userId}' AND UserData.LastPlayedDate > '2025-11-25';"
{videoName}|1|1|0|2025-11-25 20:55:01.4055306

So I think there might be some kind of caching layer in place which is causing the API query above to return incorrect results. I'll see if I can find something related to this.

@mthaddon commented on GitHub (Nov 26, 2025): If I look at the web client, I see that it's using the following URL for the folder view which is displaying this problem: http://127.0.0.1:8096/Users/{userId}/Items?StartIndex=0&Limit=100&Fields=PrimaryImageAspectRatio%2CSortName%2CPath%2CChildCount%2CMediaSourceCount%2CPrimaryImageAspectRatio&ImageTypeLimit=1&ParentId={folderId}&SortBy=SortName&SortOrder=Ascending&Filters=IsUnplayed If I visit this URL when the problem is presenting, I see the items in it which I've recently played and expect to be marked as Played and not included in this view. They have the following properties: ``` ... "UserData": { "PlaybackPositionTicks": 0, "PlayCount": 0, "IsFavorite": false, "Played": false, ... ``` However, if I run the following query I see in the database that they have been marked as Played: ``` sqlite3 jellyfin.db "SELECT BaseItems.Name, UserData.Played, UserData.PlayCount, UserData.PlaybackPositionTicks, UserData.LastPlayedDate FROM UserData, BaseItems WHERE UserData.ItemId = BaseItems.Id AND UserData.UserId = '{userId}' AND UserData.LastPlayedDate > '2025-11-25';" {videoName}|1|1|0|2025-11-25 20:55:01.4055306 ``` So I think there might be some kind of caching layer in place which is causing the API query above to return incorrect results. I'll see if I can find something related to this.
Author
Owner

@mthaddon commented on GitHub (Dec 8, 2025):

I'm making very slow (if any) progress on this as I'm totally new to C#, but what I've found so far is that in MediaBrowser.Controller/Entities/BaseItem.cs as part of public virtual bool IsPlayed(User user, UserItemData userItemData) we're passing in a userItemData that has the incorrect status when we run the /Users/UserId/Items API call. The cache seems to be updated correctly in Emby.Server.Implementations/Library/UserDataManager.cs as part of the SaveUserData function. I need to to figure out why the API call is triggering IsPlayed but passing in userItemData with the incorrect status for the item in question.

@mthaddon commented on GitHub (Dec 8, 2025): I'm making very slow (if any) progress on this as I'm totally new to C#, but what I've found so far is that in `MediaBrowser.Controller/Entities/BaseItem.cs` as part of `public virtual bool IsPlayed(User user, UserItemData userItemData)` we're passing in a `userItemData` that has the incorrect status when we run the `/Users/UserId/Items` API call. The cache seems to be updated correctly in `Emby.Server.Implementations/Library/UserDataManager.cs` as part of the `SaveUserData` function. I need to to figure out why the API call is triggering `IsPlayed` but passing in `userItemData` with the incorrect status for the item in question.
Author
Owner

@theguymadmax commented on GitHub (Dec 8, 2025):

It's a caching issue on the server; you can apply my PR to fix the issue: #15048

@theguymadmax commented on GitHub (Dec 8, 2025): It's a caching issue on the server; you can apply my PR to fix the issue: #15048
Author
Owner

@mthaddon commented on GitHub (Dec 8, 2025):

Thanks, I can confirm that fixes it for me

@mthaddon commented on GitHub (Dec 8, 2025): Thanks, I can confirm that fixes it for me
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: starred/jellyfin#7825
No description provided.