Skip to content

Commit

Permalink
10.9 (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
crobibero authored May 11, 2024
1 parent 16db34a commit 3d0153d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ You should have received a copy of the GNU General Public License
namespace Jellyfin.Plugin.PlaybackReporting.Api
{
[ApiController]
[Authorize(Policy = "DefaultAuthorization")]
[Authorize]
[Route("user_usage_stats")]
[Produces(MediaTypeNames.Application.Json)]
public class PlaybackReportingActivityController : ControllerBase
Expand Down
46 changes: 26 additions & 20 deletions Jellyfin.Plugin.PlaybackReporting/EventMonitorEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Plugin.PlaybackReporting.Data;
using MediaBrowser.Controller;
Expand All @@ -28,11 +29,12 @@ You should have received a copy of the GNU General Public License
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace Jellyfin.Plugin.PlaybackReporting
{
public class EventMonitorEntryPoint : IServerEntryPoint
public class EventMonitorEntryPoint : IHostedService
{
private readonly ISessionManager _sessionManager;
private readonly IServerConfigurationManager _config;
Expand All @@ -56,25 +58,6 @@ public EventMonitorEntryPoint(
playback_trackers = new Dictionary<string, PlaybackTracker>();
}

public void Dispose()
{
GC.SuppressFinalize(this);
}

public Task RunAsync()
{
_logger.LogInformation("EventMonitorEntryPoint Running");
var repo = new ActivityRepository(_loggerFactory.CreateLogger<ActivityRepository>(), _config.ApplicationPaths, _fileSystem);
repo.Initialize();
_repository = repo;

_sessionManager.PlaybackStart += SessionManager_PlaybackStart;
_sessionManager.PlaybackStopped += SessionManager_PlaybackStop;
_sessionManager.PlaybackProgress += SessionManager_PlaybackProgress;

return Task.CompletedTask;
}

private void SessionManager_PlaybackProgress(object? sender, PlaybackProgressEventArgs e)
{
string key = e.DeviceId + "-" + e.Users[0].Id.ToString("N") + "-" + e.Item?.Id.ToString("N");
Expand Down Expand Up @@ -362,5 +345,28 @@ private static string GetItemName(BaseItem item)

return item_name;
}

public Task StartAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("EventMonitorEntryPoint Running");
var repo = new ActivityRepository(_loggerFactory.CreateLogger<ActivityRepository>(), _config.ApplicationPaths, _fileSystem);
repo.Initialize();
_repository = repo;

_sessionManager.PlaybackStart += SessionManager_PlaybackStart;
_sessionManager.PlaybackStopped += SessionManager_PlaybackStop;
_sessionManager.PlaybackProgress += SessionManager_PlaybackProgress;

return Task.CompletedTask;
}

public Task StopAsync(CancellationToken cancellationToken)
{
_sessionManager.PlaybackStart -= SessionManager_PlaybackStart;
_sessionManager.PlaybackStopped -= SessionManager_PlaybackStop;
_sessionManager.PlaybackProgress -= SessionManager_PlaybackProgress;

return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
13 changes: 13 additions & 0 deletions Jellyfin.Plugin.PlaybackReporting/PluginServiceRegistrator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using MediaBrowser.Controller;
using MediaBrowser.Controller.Plugins;
using Microsoft.Extensions.DependencyInjection;

namespace Jellyfin.Plugin.PlaybackReporting;

public class PluginServiceRegistrator : IPluginServiceRegistrator
{
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
{
serviceCollection.AddHostedService<EventMonitorEntryPoint>();
}
}
11 changes: 3 additions & 8 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ name: "Playback Reporting"
guid: "5c534381-91a3-43cb-907a-35aa02eb9d2c"
imageUrl: "https://repo.jellyfin.org/releases/plugin/images/jellyfin-plugin-playbackreporting.png"
version: 13
targetAbi: "10.8.1.0"
framework: net6.0
targetAbi: "10.9.0.0"
framework: net8.0
owner: "jellyfin"
overview: "Collect and show user play statistics"
description: "Collect and show user play statistics"
category: "General"
artifacts:
- "Jellyfin.Plugin.PlaybackReporting.dll"
- "SQLitePCL.pretty.dll"
changelog: |2-
### Bug Fixes ###
- Added support for decimal timezones (#64) @theKAKAN
- Keep all avatars the same dimension (#62) @sambartik
### CI & build changes ###
- fix: meta ci workflows (#60) @h1dden-da3m0n

0 comments on commit 3d0153d

Please sign in to comment.