AddDefaultCastReceivers.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using MediaBrowser.Controller.Configuration;
  3. using MediaBrowser.Model.System;
  4. namespace Jellyfin.Server.Migrations.Routines;
  5. /// <summary>
  6. /// Migration to add the default cast receivers to the system config.
  7. /// </summary>
  8. public class AddDefaultCastReceivers : IMigrationRoutine
  9. {
  10. private readonly IServerConfigurationManager _serverConfigurationManager;
  11. /// <summary>
  12. /// Initializes a new instance of the <see cref="AddDefaultCastReceivers"/> class.
  13. /// </summary>
  14. /// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
  15. public AddDefaultCastReceivers(IServerConfigurationManager serverConfigurationManager)
  16. {
  17. _serverConfigurationManager = serverConfigurationManager;
  18. }
  19. /// <inheritdoc />
  20. public Guid Id => new("34A1A1C4-5572-418E-A2F8-32CDFE2668E8");
  21. /// <inheritdoc />
  22. public string Name => "AddDefaultCastReceivers";
  23. /// <inheritdoc />
  24. public bool PerformOnNewInstall => true;
  25. /// <inheritdoc />
  26. public void Perform()
  27. {
  28. // Only add if receiver list is empty.
  29. if (_serverConfigurationManager.Configuration.CastReceiverApplications.Length == 0)
  30. {
  31. _serverConfigurationManager.Configuration.CastReceiverApplications = new CastReceiverApplication[]
  32. {
  33. new()
  34. {
  35. Id = "F007D354",
  36. Name = "Stable"
  37. },
  38. new()
  39. {
  40. Id = "6F511C87",
  41. Name = "Unstable"
  42. }
  43. };
  44. _serverConfigurationManager.SaveConfiguration();
  45. }
  46. }
  47. }