From 9e2e04f1684a8d10ed22fcb649f6171394831f28 Mon Sep 17 00:00:00 2001 From: Chaphasilor Date: Sun, 1 Jan 2023 19:04:14 +0100 Subject: [PATCH] tried fixing NaN bug - also updated the playback reporting overlay text --- src/aggregate.js | 8 ++++---- src/features.js | 6 +++--- src/rewind.js | 15 +++++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/aggregate.js b/src/aggregate.js index 6dbc338..9a43cd4 100644 --- a/src/aggregate.js +++ b/src/aggregate.js @@ -29,7 +29,7 @@ export function generateTopTrackInfo(itemInfo, playbackReportJSON) { blurhash: item.ImageBlurHashes?.Primary?.[item.ImageTags?.Primary], }), year: item.PremiereDate ? new Date(item.PremiereDate).getFullYear() : null, - duration: Math.round(item.RunTimeTicks / 10000000), + duration: !isNaN(Math.round(item.RunTimeTicks / 10000000)) ? Math.round(item.RunTimeTicks / 10000000) : 0, playCount: { jellyfin: item.UserData?.PlayCount || 0, // playbackReport: Number(playbackReportItem?.TotalPlayCount) || 0, @@ -40,9 +40,9 @@ export function generateTopTrackInfo(itemInfo, playbackReportJSON) { mostSuccessivePlays: playbackReportItem?.MostSuccessivePlays || null, lastPlayed: item.UserData?.LastPlayedDate ? new Date(item.UserData.LastPlayedDate) : new Date(0), totalPlayDuration: { - jellyfin: Number(item.UserData?.PlayCount) * (Number(item.RunTimeTicks) / (10000000 * 60)), // convert jellyfin's runtime ticks to minutes (https://learn.microsoft.com/en-us/dotnet/api/system.datetime.ticks?view=net-7.0) - playbackReport: Number(playbackReportItem?.TotalDuration) / 60 || 0, // convert to minutes - average: Math.ceil(((Number(item.UserData?.PlayCount) * (Number(item.RunTimeTicks) / (10000000 * 60))) + (Number(playbackReportItem?.TotalDuration) / 60 || 0))/2), + jellyfin: !isNaN(Number(item.UserData?.PlayCount) * (Number(item.RunTimeTicks) / (10000000 * 60))) ? Number(item.UserData?.PlayCount) * (Number(item.RunTimeTicks) / (10000000 * 60)) : 0, // convert jellyfin's runtime ticks to minutes (https://learn.microsoft.com/en-us/dotnet/api/system.datetime.ticks?view=net-7.0) + playbackReport: !isNaN(Number(playbackReportItem?.TotalDuration) / 60 || 0) ? (Number(playbackReportItem?.TotalDuration) / 60 || 0) : 0, // convert to minutes + average: !isNaN(Math.ceil(((Number(item.UserData?.PlayCount) * (Number(item.RunTimeTicks) / (10000000 * 60))) + (Number(playbackReportItem?.TotalDuration) / 60 || 0))/2)) ? Math.ceil(((Number(item.UserData?.PlayCount) * (Number(item.RunTimeTicks) / (10000000 * 60))) + (Number(playbackReportItem?.TotalDuration) / 60 || 0))/2) : 0, }, isFavorite: item.UserData?.IsFavorite, }) diff --git a/src/features.js b/src/features.js index a825708..5d5dad0 100644 --- a/src/features.js +++ b/src/features.js @@ -117,11 +117,11 @@ state.features = [

Jellyfin doesn't save any information about played tracks other than the number of times they were played. This means that e.g. the total playtime is only an approximation. It also means that it is not possible to limit the data to ${() => state.rewindReport.year} only!

However, if you have the "Playback Reporting" plugin installed, significantly more information can be collected, such as the date and durations of each playback. This will results in better stats, although it isn't perfect either. Playback reporting depends on applications properly reporting the current playback states, and currently most music players that are compatible with Jellyfin seem to struggle with this in one way or another. Especially offline playback is challenging, because the players have to "simulate" the playback after the device reconnects to the server.

-

Alternatively, an even better solution would be to install the Playback Reporting plugin into your Jellyfin server. It won't take longer than 5 minutes, so why not do it right now? Your Jellyfin Rewind isn't going anywhere!

+

Still, the best solution is to install the Playback Reporting plugin into your Jellyfin server if you haven't done so already. It won't take longer than 2 minutes, so why not do it right now? Your Jellyfin Rewind isn't going anywhere!

Open Plugins Page! +

For more information about the Playback Reporting plugin, you can visit its entry in the official Jellyfin Docs.

So, please treat all of this information with a grain of salt. You can take a look at the settings in order to choose which data will be used, but any information that needs to be interpolated will have a negative influence on the quality of these stats.

I will try to offer a way to import this year's Rewind data into next year's Jellyfin Rewind, so that more information can be used and the used data can be properly limited to the current year only. Because of this, please make sure to download a copy of your Rewind data at the end and store it until next year!

-

For more information about the Playback Reporting plugin, you can visit its entry in the official Jellyfin Docs.

`, }))}"> @@ -149,7 +149,7 @@ state.features = [ ${() => state.extraFeatures.totalPlaytimeGraph ? html`
` : html`
- Unavailable + Unavailable