watchparty/src/WatchParty/Plugin.cs
Nicolas db815df7d5 Fix plugin to build clean against real Emby 4.9.1.90 SDK
Installed .NET 8 SDK (per-user, winget needed admin elevation this
machine doesn't have) and restored the real MediaBrowser.Server.Core /
MediaBrowser.Common packages, then fixed everything the compiler and
a bit of reflection surfaced:

- PlaybackProgressEventArgs/PlaybackStopEventArgs are in
  MediaBrowser.Controller.Library, not ...Session
- IAuthorizationContext/AuthorizationInfo are in MediaBrowser.Controller.Net
- Item/user/session ids (SessionInfo.Id/UserId, BaseItemDto.Id) are plain
  string on this SDK version, not Guid - Party/PartyMember updated
  accordingly (Party.Id stays a Guid; it's minted by this plugin, not Emby)
- Reading the calling user needed an extra step:
  IAuthorizationContext.GetAuthorizationInfo(Request).UserId is a `long`
  (internal row id); .User.Id is the one matching SessionInfo.UserId,
  but it's a Guid so it's reformatted with .ToString("N")

docs/architecture.md's "Assumptions to verify" now reflects what was
actually confirmed vs. what's still only compile-checked (HTTP status
codes, content-type headers, the JS auth header format, the dashboard
config page) pending a run against a real server.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-13 14:40:17 +02:00

51 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization;
using WatchParty.Configuration;
namespace WatchParty
{
// -----------------------------------------------------------------------
// Emby plugin entry point. Builds clean against the real
// MediaBrowser.Server.Core/MediaBrowser.Common 4.9.1.90 assemblies
// (restored from NuGet) - BasePlugin<T>, IHasWebPages and PluginPageInfo's
// Name/EmbeddedResourcePath are all confirmed as used below. See
// docs/architecture.md#assumptions-to-verify for what's still only
// compile-checked rather than run against a real server (e.g. whether the
// dashboard actually renders this settings page correctly).
// -----------------------------------------------------------------------
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
{
public static Plugin Instance { get; private set; }
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
: base(applicationPaths, xmlSerializer)
{
Instance = this;
}
// Generated once for this project - keep it stable across every release,
// Emby uses it to identify the plugin (and its config file) across upgrades.
public override Guid Id => new Guid("5b6a1e2c-6e3a-4b8b-9c1a-1f7a2c9d4e10");
public override string Name => "Watch Party";
public override string Description =>
"Watch the same title together with other users on this server: " +
"start or join a party, and the server nudges everyone's existing " +
"playback back in sync using Emby's normal remote-control commands.";
/// <summary>Admin-only settings page (thresholds etc.) - see Configuration/configPage.html.</summary>
public IEnumerable<PluginPageInfo> GetPages()
{
yield return new PluginPageInfo
{
Name = "WatchParty",
EmbeddedResourcePath = GetType().Namespace + ".Configuration.configPage.html"
};
}
}
}