Jump to content

Calculate User Statistics fails


Go to solution Solved by Junglejim,

Recommended Posts

Eigeplackter
Posted

Hi,

can't say for sure when it started happening, but I cannot get fresh statistics.

 

2023-02-10 15:12:29.423 Error TaskManager: Error
*** Error Report ***
Version: 4.8.0.21
Command line: /volume4/@appstore/EmbyServer/system/EmbyServer.dll -programdata /var/packages/EmbyServer/var -ffdetect /var/packages/EmbyServer/target/bin/ffdetect -ffmpeg /var/packages/EmbyServer/target/bin/ffmpeg -ffprobe /var/packages/EmbyServer/target/bin/ffprobe -nolocalportconfig -ignore_vaapi_enabled_flag -pidfile /var/packages/EmbyServer/var/EmbyServer.pid -defaultdirectory /volume1/Public -updatepackage emby-server-synology7_{version}_x86_64.spk
Operating system: Linux version 4.4.180+ (root@build13) (gcc version 8.5.0 (GCC) ) #42962 SMP Tue Sep 20 22:35:56 CST 2022
Framework: .NET 6.0.8
OS/Process: x64/x64
Runtime: volume4/@appstore/EmbyServer/system/System.Private.CoreLib.dll
Processor count: 4
Data path: /var/packages/EmbyServer/var
Application path: /volume4/@appstore/EmbyServer/system
System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
at Statistics.Helpers.Calculator.CalculateMovieQualities()
at Statistics.ScheduledTasks.CalculateStatsTask.MediaBrowser.Model.Tasks.IScheduledTask.Execute(CancellationToken cancellationToken, IProgress`1 progress)
at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)
Source: statistics
TargetSite: statistics.Models.Configuration.ValueGroup CalculateMovieQualities()

The attached log is full of errors.

 

embyserver.txt

Happy2Play
Posted

My guess it is about unknown Seriesnames.

As the error is the same as all the discussion in the topic around that time.

Eigeplackter
Posted

Didn't work for me, running plugin in version 3.0.5.1

SQL returns:

Ausführung wurde ohne Fehler beendet.
Ergebnis: 0 Zeilen in 42ms zurückgegeben
In Zeile 1:
select Path, Name, SeriesName, ProviderIds from MediaItems where type=8 and SeriesName is null

Did another library scan (120 secs) and started calculate manually.

Fails after 110 secs.

Same error in debug log (can be provided via pn)

2023-02-10 23:25:46.952 Error TaskManager: Error
	*** Error Report ***
	Version: 4.8.0.21
	Command line: /volume4/@appstore/EmbyServer/system/EmbyServer.dll -programdata /var/packages/EmbyServer/var -ffdetect /var/packages/EmbyServer/target/bin/ffdetect -ffmpeg /var/packages/EmbyServer/target/bin/ffmpeg -ffprobe /var/packages/EmbyServer/target/bin/ffprobe -nolocalportconfig -ignore_vaapi_enabled_flag -pidfile /var/packages/EmbyServer/var/EmbyServer.pid -defaultdirectory /volume1/Public -updatepackage emby-server-synology7_{version}_x86_64.spk
	Operating system: Linux version 4.4.180+ (root@build13) (gcc version 8.5.0 (GCC) ) #42962 SMP Tue Sep 20 22:35:56 CST 2022
	Framework: .NET 6.0.8
	OS/Process: x64/x64
	Runtime: volume4/@appstore/EmbyServer/system/System.Private.CoreLib.dll
	Processor count: 4
	Data path: /var/packages/EmbyServer/var
	Application path: /volume4/@appstore/EmbyServer/system
	System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
	   at Statistics.Helpers.Calculator.CalculateMovieQualities()
	   at Statistics.ScheduledTasks.CalculateStatsTask.MediaBrowser.Model.Tasks.IScheduledTask.Execute(CancellationToken cancellationToken, IProgress`1 progress)
	   at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)
	Source: statistics
	TargetSite: statistics.Models.Configuration.ValueGroup CalculateMovieQualities()

 

Happy2Play
Posted

Debug logging may show more information, but I know I can only get that error with SeriesName issue.  But yours is different as you are not getting any episodes with the query.

  • Solution
Junglejim
Posted (edited)

I seem to be having the same problem, it's been working fine for months but over the last week it has started failing. Not sure what has changed.

	*** Error Report ***
	Version: 4.7.11.0
	Command line: /app/emby/EmbyServer.dll -programdata /config -ffdetect /app/emby/ffdetect -ffmpeg /app/emby/ffmpeg -ffprobe /app/emby/ffprobe -restartexitcode 3
	Operating system: Linux version 6.0.0-0.deb11.6-amd64 (debian-kernel@lists.debian.org) (gcc-10 (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.
	Framework: .NET 6.0.8
	OS/Process: x64/x64
	Runtime: app/emby/System.Private.CoreLib.dll
	Processor count: 4
	Data path: /config
	Application path: /app/emby
	System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
	   at Statistics.Helpers.Calculator.CalculateMovieQualities()
	   at Statistics.ScheduledTasks.CalculateStatsTask.MediaBrowser.Model.Tasks.IScheduledTask.Execute(CancellationToken cancellationToken, IProgress`1 progress)
	   at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)
	Source: statistics
	TargetSite: statistics.Models.Configuration.ValueGroup CalculateMovieQualities()

EDIT: Got it working! I uninstalled the watched history plugin and now it's working. These two plugins (Watch History & Statistics) don't seem to like each other. :)

@Cheesegeezer @hackthis02 Not sure which plugin (Watch History) or (Statistics) is causing the problem?

Edited by Junglejim
  • Like 2
  • Thanks 1
Happy2Play
Posted

Yep seems to a common denominator here as OP has the plugin also.

Eigeplackter
Posted

@JunglejimYou are absolutely right. Just deinstalled Watched History, and statistics ran through fine.

Cheesegeezer
Posted

So i have installed Statistics plugin myself and can confirm that watch history is causing the issue. Why??? I have no idea. Because the exceptions make no sense to me.

but its failing at the calcmoviequality method, which i assume is to get the resolution of the movie. I’m sure that nothing has changed in a long time in the core code that would break this. However the stats plugin should not be including channels as stats, because its only focused on Library items. 
 

i think this is where the issue lies. 

and with the limited capabilities you have when creating a channel I don’t know how to fix this in Watch History. 

if you read the requests from users of watch history, all the requests want it to basically be yet another movie or tv show library with all the relevant info like browsing a movie library. I think i should strip back a lot of that in Watch History as its only a list of what users have been watching. 
 

so I’m open to suggestions.

Posted

Hey Cheeze.  This is going to come down to some value on your items that the stats plug-in is never expecting to not be there but isn't.  Exactly what that value is, I can't be sure but perhaps things like runtime or a media type or something like that...

  • Thanks 1
Cheesegeezer
Posted
52 minutes ago, ebr said:

Hey Cheeze.  This is going to come down to some value on your items that the stats plug-in is never expecting to not be there but isn't.  Exactly what that value is, I can't be sure but perhaps things like runtime or a media type or something like that...

I have filled almost every field available in the channeliteminfo… i shall demonstrate… 2 secs…

Cheesegeezer
Posted (edited)
ChannelMediaContentType contentType = item switch
                {
                    Episode _ => ChannelMediaContentType.Episode,
                    Movie _ => ChannelMediaContentType.Movie,
                    _ => ChannelMediaContentType.Episode
                };

                ChannelFolderType folderType = item switch
                {
                    Episode _ => ChannelFolderType.Series,
                    Movie _ => ChannelFolderType.Container,
                    _ => ChannelFolderType.Container,
                };

string seriesName = "";

                if(item is Episode)
                {
                    var series = item.FindParent<Series>();
                    seriesName = series.Name;
                }

                ChannelItemInfo historyItem = new ChannelItemInfo
                {
                    Name = item.Name,
                    SeriesName = seriesName,
                    Id = item.Id.ToString(),
                    Type = ChannelItemType.Media,
                    OfficialRating = item.OfficialRating,
                    Overview = item.Overview,
                    Genres = new List<string>(item.Genres),
                    Studios = new List<string>(item.Studios),
                    CommunityRating = item.CommunityRating,
                    RunTimeTicks = item.RunTimeTicks,
                    DateCreated = item.LastPlayedDate,
                    IndexNumber = item.IndexNumber,
                    ParentIndexNumber = item.ParentIndexNumber,
                    DateModified = item.DateModified,
                    ContentType = contentType,
                    ExtraType = (ExtraType)0,
                    ImageUrl = item.PrimaryImagePath,
                    OriginalTitle = item.OriginalTitle,
                    MediaType = ChannelMediaType.Video,
                    FolderType = folderType,
                    ProviderIds = item.ProviderIds,
                    PremiereDate = item.PremiereDate,
                    ProductionYear = item.ProductionYear,

                    MediaSources = new List<MediaSourceInfo>
                    {
                        new ChannelMediaInfo()
                        {
                            Path = item.Path,

                        }.ToMediaSource(),
                    },
                };
                items.Add(historyItem);

 

Edited by Cheesegeezer
Cheesegeezer
Posted

so i guess based on an assumption that statistics plugin knows how to handle MediaSource Width and Height internally, then i can add those variables into the Mediasource List.

i will give that a go.  Thanks Eric.

Posted

Yeah, I'll bet it is the almost completely blank media source that is tripping it up.

  • Agree 1
Cheesegeezer
Posted
12 minutes ago, ebr said:

Yeah, I'll bet it is the almost completely blank media source that is tripping it up.

Thanks Eric for your advice, I’ll get on it later or tomorrow.  We are watching 2nd series of Clarkson Farm, can’t stop watching lol 😂 

hackthis02
Posted
3 hours ago, Cheesegeezer said:
ChannelMediaContentType contentType = item switch
                {
                    Episode _ => ChannelMediaContentType.Episode,
                    Movie _ => ChannelMediaContentType.Movie,
                    _ => ChannelMediaContentType.Episode
                };

                ChannelFolderType folderType = item switch
                {
                    Episode _ => ChannelFolderType.Series,
                    Movie _ => ChannelFolderType.Container,
                    _ => ChannelFolderType.Container,
                };

string seriesName = "";

                if(item is Episode)
                {
                    var series = item.FindParent<Series>();
                    seriesName = series.Name;
                }

                ChannelItemInfo historyItem = new ChannelItemInfo
                {
                    Name = item.Name,
                    SeriesName = seriesName,
                    Id = item.Id.ToString(),
                    Type = ChannelItemType.Media,
                    OfficialRating = item.OfficialRating,
                    Overview = item.Overview,
                    Genres = new List<string>(item.Genres),
                    Studios = new List<string>(item.Studios),
                    CommunityRating = item.CommunityRating,
                    RunTimeTicks = item.RunTimeTicks,
                    DateCreated = item.LastPlayedDate,
                    IndexNumber = item.IndexNumber,
                    ParentIndexNumber = item.ParentIndexNumber,
                    DateModified = item.DateModified,
                    ContentType = contentType,
                    ExtraType = (ExtraType)0,
                    ImageUrl = item.PrimaryImagePath,
                    OriginalTitle = item.OriginalTitle,
                    MediaType = ChannelMediaType.Video,
                    FolderType = folderType,
                    ProviderIds = item.ProviderIds,
                    PremiereDate = item.PremiereDate,
                    ProductionYear = item.ProductionYear,

                    MediaSources = new List<MediaSourceInfo>
                    {
                        new ChannelMediaInfo()
                        {
                            Path = item.Path,

                        }.ToMediaSource(),
                    },
                };
                items.Add(historyItem);

 

Just from a quick look, what I use that I don't see in your code:
movie.SortName -Movie title
episode.Series.SortName --Episode title
movie(or episode).GetMediaStreams().FirstOrDefault(s => s != null && s.Type == MediaStreamType.Video)?.Codec -give me the media codec
movie(or episode).GetMediaStreams().FirstOrDefault(s => s != null && s.Type == MediaStreamType.Video)?.DisplayTitle.Split(' ')[0] -give me what emby thinks the resolution is.

Cheesegeezer
Posted
57 minutes ago, hackthis02 said:

Just from a quick look, what I use that I don't see in your code:
movie.SortName -Movie title
episode.Series.SortName --Episode title
movie(or episode).GetMediaStreams().FirstOrDefault(s => s != null && s.Type == MediaStreamType.Video)?.Codec -give me the media codec
movie(or episode).GetMediaStreams().FirstOrDefault(s => s != null && s.Type == MediaStreamType.Video)?.DisplayTitle.Split(' ')[0] -give me what emby thinks the resolution is.

What isn’t available in a channel is 

1. sortName

2. episodeTitle.. should be item.Name and is typed based on internalItemQuery result

3. mediacodec i can do.

4. Your display title relies on a string value not a calculation of width and height.

in my mediaInfo plugin there is this to determine the resolution 

string resolution = "";
                    if (Convert.ToInt32(typeInfo.Width) >= 1281 && Convert.ToInt32(typeInfo.Width) <= 1920)
                    {
                        resolution = config.ShowHD ? "HD 1080p" : "1080p";
                    }

                    if (Convert.ToInt32(typeInfo.Width) >= 3841 && Convert.ToInt32(typeInfo.Width) <= 7680)
                    {
                        resolution = config.ShowAsUHD ? "8K UHD" : "8K";
                    }

                    if (Convert.ToInt32(typeInfo.Width) >= 1921 && Convert.ToInt32(typeInfo.Width) <= 3840 )
                    {
                        resolution = config.ShowAsUHD ? "UHD".Trim() : "4K".Trim();
                    }

                    if (Convert.ToInt32(typeInfo.Width) >= 1200 && Convert.ToInt32(typeInfo.Width) <= 1280)
                    {
                        resolution = config.ShowHD ? "HD 720p" : "720p";
                    }

                    if (Convert.ToInt32(typeInfo.Width) < 1200)
                    {
                        resolution = "SD";
                    }

 

  • Like 1
hackthis02
Posted

Thanks @Cheesegeezer I was looking for a way to sort resolutions without relying on emby. I'll see if I can factor this into my plugin. 

  • Like 1
Cheesegeezer
Posted
21 minutes ago, hackthis02 said:

Thanks @Cheesegeezer I was looking for a way to sort resolutions without relying on emby. I'll see if I can factor this into my plugin. 

Appreciate it fella, and hope we can work together to make everything compatible with each other. 
 

happy coding chief 👍👍

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...