diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2020-12-30 19:12:40 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-30 19:12:40 -0500 |
| commit | eb084f9021b912903239750e48a0119127e4fa38 (patch) | |
| tree | 0ea098ed422fea7ef0b888df248ec482448e5f19 /Emby.Server.Implementations/Library/UserDataManager.cs | |
| parent | 4c291da45c57f1999868182490b55fb7872c26ba (diff) | |
| parent | f411353c8ca27eb17db4258d400a38721041c9a2 (diff) | |
Merge pull request #4891 from Artiume/patch-1
Diffstat (limited to 'Emby.Server.Implementations/Library/UserDataManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Library/UserDataManager.cs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs index f9e5e6bbc..d16275b19 100644 --- a/Emby.Server.Implementations/Library/UserDataManager.cs +++ b/Emby.Server.Implementations/Library/UserDataManager.cs @@ -14,6 +14,7 @@ using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using Book = MediaBrowser.Controller.Entities.Book; +using AudioBook = MediaBrowser.Controller.Entities.AudioBook; namespace Emby.Server.Implementations.Library { @@ -219,7 +220,7 @@ namespace Emby.Server.Implementations.Library var hasRuntime = runtimeTicks > 0; // If a position has been reported, and if we know the duration - if (positionTicks > 0 && hasRuntime) + if (positionTicks > 0 && hasRuntime && !(item is AudioBook)) { var pctIn = decimal.Divide(positionTicks, runtimeTicks) * 100; @@ -245,6 +246,23 @@ namespace Emby.Server.Implementations.Library } } } + else if (positionTicks > 0 && hasRuntime && item is AudioBook) + { + var minIn = TimeSpan.FromTicks(positionTicks).TotalMinutes; + var minOut = TimeSpan.FromTicks(runtimeTicks - positionTicks).TotalMinutes; + + if (minIn > _config.Configuration.MinAudiobookResume) + { + // ignore progress during the beginning + positionTicks = 0; + } + else if (minOut < _config.Configuration.MaxAudiobookResume || positionTicks >= runtimeTicks) + { + // mark as completed close to the end + positionTicks = 0; + data.Played = playedToCompletion = true; + } + } else if (!hasRuntime) { // If we don't know the runtime we'll just have to assume it was fully played |
