diff --git a/MediaBrowser.Plugins.PushBulletNotifications.sln b/Pushbullet.sln similarity index 79% rename from MediaBrowser.Plugins.PushBulletNotifications.sln rename to Pushbullet.sln index fe2de40..6653137 100644 --- a/MediaBrowser.Plugins.PushBulletNotifications.sln +++ b/Pushbullet.sln @@ -1,9 +1,9 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.3 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Plugins.PushBulletNotifications", "MediaBrowser.Plugins.PushBulletNotifications\MediaBrowser.Plugins.PushBulletNotifications.csproj", "{DFC6982E-A548-4599-B612-41D307623364}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pushbullet", "Pushbullet\Pushbullet.csproj", "{DFC6982E-A548-4599-B612-41D307623364}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/MediaBrowser.Plugins.PushBulletNotifications/Api/ServerApiEntryPoints.cs b/Pushbullet/Api/ServerApiEntryPoints.cs similarity index 76% rename from MediaBrowser.Plugins.PushBulletNotifications/Api/ServerApiEntryPoints.cs rename to Pushbullet/Api/ServerApiEntryPoints.cs index 8dde2a3..69f65ce 100644 --- a/MediaBrowser.Plugins.PushBulletNotifications/Api/ServerApiEntryPoints.cs +++ b/Pushbullet/Api/ServerApiEntryPoints.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -6,15 +6,15 @@ using System.Text; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Net; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using MediaBrowser.Model.Services; -using MediaBrowser.Plugins.PushBulletNotifications.Configuration; +using Pushbullet.Configuration; using System.Threading; using System.Threading.Tasks; -namespace MediaBrowser.Plugins.PushBulletNotifications.Api +namespace Pushbullet.Api { - [Route("/Notification/PushBullet/Test/{UserID}", "POST", Summary = "Tests PushBullet")] + [Route("/Notification/Pushbullet/Test/{UserID}", "POST", Summary = "Tests Pushbullet")] public class TestNotification : IReturnVoid { [ApiMember(Name = "UserID", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] @@ -26,12 +26,12 @@ class ServerApiEndpoints : IService private readonly IHttpClient _httpClient; private readonly ILogger _logger; - public ServerApiEndpoints(ILogManager logManager, IHttpClient httpClient) + public ServerApiEndpoints(ILogger logger, IHttpClient httpClient) { - _logger = logManager.GetLogger(GetType().Name); - _httpClient = httpClient; + _logger = logger; + _httpClient = httpClient; } - private PushBulletOptions GetOptions(String userID) + private PushbulletOptions GetOptions(String userID) { return Plugin.Instance.Configuration.Options .FirstOrDefault(i => string.Equals(i.MediaBrowserUserId, userID, StringComparison.OrdinalIgnoreCase)); @@ -51,7 +51,7 @@ public async Task PostAsync(TestNotification request) { {"type", "note"}, {"title", "Test Notification" }, - {"body", "This is a test notification from MediaBrowser"} + {"body", "This is a test notification from Jellyfin"} }; var _httpRequest = new HttpRequestOptions(); diff --git a/MediaBrowser.Plugins.PushBulletNotifications/Configuration/PluginConfiguration.cs b/Pushbullet/Configuration/PluginConfiguration.cs similarity index 63% rename from MediaBrowser.Plugins.PushBulletNotifications/Configuration/PluginConfiguration.cs rename to Pushbullet/Configuration/PluginConfiguration.cs index f5ba8e2..e78a0a7 100644 --- a/MediaBrowser.Plugins.PushBulletNotifications/Configuration/PluginConfiguration.cs +++ b/Pushbullet/Configuration/PluginConfiguration.cs @@ -1,20 +1,20 @@ -using System; +using System; using System.Collections.Generic; using MediaBrowser.Model.Plugins; -namespace MediaBrowser.Plugins.PushBulletNotifications.Configuration +namespace Pushbullet.Configuration { public class PluginConfiguration : BasePluginConfiguration { - public PushBulletOptions[] Options { get; set; } + public PushbulletOptions[] Options { get; set; } public PluginConfiguration() { - Options = new PushBulletOptions[] { }; + Options = new PushbulletOptions[] { }; } } - public class PushBulletOptions + public class PushbulletOptions { public Boolean Enabled { get; set; } public String Token { get; set; } diff --git a/MediaBrowser.Plugins.PushBulletNotifications/Configuration/config.html b/Pushbullet/Configuration/config.html similarity index 78% rename from MediaBrowser.Plugins.PushBulletNotifications/Configuration/config.html rename to Pushbullet/Configuration/config.html index a02d05e..448eb0d 100644 --- a/MediaBrowser.Plugins.PushBulletNotifications/Configuration/config.html +++ b/Pushbullet/Configuration/config.html @@ -1,24 +1,24 @@  - PushBullet Notifications + Pushbullet Notifications -
+
-
+
- +
- +
Auth key for your application
@@ -49,21 +49,21 @@ ApiClient.getPluginConfiguration(pluginId).then(function (config) { - var pushBulletConfig = config.Options.filter(function (c) { + var PushbulletConfig = config.Options.filter(function (c) { return userId == c.MediaBrowserUserId; })[0] || {}; - $('#chkEnablePushBullet', page).checked(pushBulletConfig.Enabled || false).checkboxradio("refresh"); - $('#txtPushBulletAuthKey', page).val(pushBulletConfig.Token || ''); - $('#txtPushBulletDeviceId', page).val(pushBulletConfig.DeviceId || ''); + $('#chkEnablePushbullet', page).checked(PushbulletConfig.Enabled || false).checkboxradio("refresh"); + $('#txtPushbulletAuthKey', page).val(PushbulletConfig.Token || ''); + $('#txtPushbulletDeviceId', page).val(PushbulletConfig.DeviceId || ''); Dashboard.hideLoadingMsg(); }); } - $('.pushBulletConfigurationPage').on('pageinit', function (event) { + $('.PushbulletConfigurationPage').on('pageinit', function (event) { var page = this; @@ -96,7 +96,7 @@ ApiClient.ajax({ type: "POST", - url: ApiClient.getUrl("Notification/PushBullet/Test/" + c.MediaBrowserUserId) + url: ApiClient.getUrl("Notification/Pushbullet/Test/" + c.MediaBrowserUserId) }).then(function () { Dashboard.hideLoadingMsg(); @@ -124,7 +124,7 @@ Dashboard.hideLoadingMsg(); }); - $('.pushBulletConfigurationForm').on('submit', function (e) { + $('.PushbulletConfigurationForm').on('submit', function (e) { Dashboard.showLoadingMsg(); @@ -134,22 +134,22 @@ var userId = $('#selectUser', form).val(); - var pushBulletConfig = config.Options.filter(function (c) { + var PushbulletConfig = config.Options.filter(function (c) { return userId == c.MediaBrowserUserId; })[0]; - if (!pushBulletConfig) { - pushBulletConfig = {}; - config.Options.push(pushBulletConfig); + if (!PushbulletConfig) { + PushbulletConfig = {}; + config.Options.push(PushbulletConfig); } - pushBulletConfig.MediaBrowserUserId = userId; + PushbulletConfig.MediaBrowserUserId = userId; - pushBulletConfig.Enabled = $('#chkEnablePushBullet', form).checked(); - pushBulletConfig.Token = $('#txtPushBulletAuthKey', form).val(); - pushBulletConfig.DeviceId = $('#txtPushBulletDeviceId', form).val(); + PushbulletConfig.Enabled = $('#chkEnablePushbullet', form).checked(); + PushbulletConfig.Token = $('#txtPushbulletAuthKey', form).val(); + PushbulletConfig.DeviceId = $('#txtPushbulletDeviceId', form).val(); ApiClient.updatePluginConfiguration(pluginId, config).then(Dashboard.processPluginConfigurationUpdateResult); }); diff --git a/MediaBrowser.Plugins.PushBulletNotifications/Notifier.cs b/Pushbullet/Notifier.cs similarity index 77% rename from MediaBrowser.Plugins.PushBulletNotifications/Notifier.cs rename to Pushbullet/Notifier.cs index 71b3591..886362d 100644 --- a/MediaBrowser.Plugins.PushBulletNotifications/Notifier.cs +++ b/Pushbullet/Notifier.cs @@ -3,24 +3,24 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Notifications; -using MediaBrowser.Model.Logging; -using MediaBrowser.Plugins.PushBulletNotifications.Configuration; +using Microsoft.Extensions.Logging; +using Pushbullet.Configuration; using System; using System.Linq; using System.Threading; using System.Threading.Tasks; -namespace MediaBrowser.Plugins.PushBulletNotifications +namespace Pushbullet { public class Notifier : INotificationService { private readonly ILogger _logger; private readonly IHttpClient _httpClient; - public Notifier(ILogManager logManager, IHttpClient httpClient) + public Notifier(ILogger logger, IHttpClient httpClient) { - _logger = logManager.GetLogger(GetType().Name); - _httpClient = httpClient; + _logger = logger; + _httpClient = httpClient; } public bool IsEnabledForUser(User user) @@ -30,7 +30,7 @@ public bool IsEnabledForUser(User user) return options != null && IsValid(options) && options.Enabled; } - private PushBulletOptions GetOptions(User user) + private PushbulletOptions GetOptions(User user) { return Plugin.Instance.Configuration.Options .FirstOrDefault(i => string.Equals(i.MediaBrowserUserId, user.Id.ToString("N"), StringComparison.OrdinalIgnoreCase)); @@ -53,7 +53,7 @@ public async Task SendNotification(UserNotification request, CancellationToken c {"body", request.Description} }; - _logger.Debug("PushBullet to Token : {0} - {1} - {2}", options.Token, options.DeviceId, request.Description); + _logger.LogDebug("Pushbullet to Token : {0} - {1} - {2}", options.Token, options.DeviceId, request.Description); var _httpRequest = new HttpRequestOptions(); string authInfo = options.Token; authInfo = Convert.ToBase64String(Encoding.UTF8.GetBytes(authInfo)); @@ -70,7 +70,7 @@ public async Task SendNotification(UserNotification request, CancellationToken c } } - private bool IsValid(PushBulletOptions options) + private bool IsValid(PushbulletOptions options) { return !string.IsNullOrEmpty(options.Token); } diff --git a/MediaBrowser.Plugins.PushBulletNotifications/Plugin.cs b/Pushbullet/Plugin.cs similarity index 66% rename from MediaBrowser.Plugins.PushBulletNotifications/Plugin.cs rename to Pushbullet/Plugin.cs index c157b45..6cbafc8 100644 --- a/MediaBrowser.Plugins.PushBulletNotifications/Plugin.cs +++ b/Pushbullet/Plugin.cs @@ -1,16 +1,16 @@ -using System; +using System; using System.Collections.Generic; using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Plugins; using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Serialization; -using MediaBrowser.Plugins.PushBulletNotifications.Configuration; +using Pushbullet.Configuration; using MediaBrowser.Model.Drawing; using System.IO; -namespace MediaBrowser.Plugins.PushBulletNotifications +namespace Pushbullet { - public class Plugin : BasePlugin, IHasWebPages, IHasThumbImage + public class Plugin : BasePlugin, IHasWebPages { public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths, xmlSerializer) @@ -20,7 +20,7 @@ public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) public override string Name { - get { return "PushBullet Notifications"; } + get { return "Pushbullet Notifications"; } } public IEnumerable GetPages() @@ -39,7 +39,7 @@ public override string Description { get { - return "Sends notifications via PushBullet Service."; + return "Sends notifications via Pushbullet Service."; } } @@ -49,20 +49,6 @@ public override Guid Id get { return _id; } } - public Stream GetThumbImage() - { - var type = GetType(); - return type.Assembly.GetManifestResourceStream(type.Namespace + ".thumb.jpg"); - } - - public ImageFormat ThumbImageFormat - { - get - { - return ImageFormat.Jpg; - } - } - public static Plugin Instance { get; private set; } } } diff --git a/MediaBrowser.Plugins.PushBulletNotifications/MediaBrowser.Plugins.PushBulletNotifications.csproj b/Pushbullet/Pushbullet.csproj similarity index 69% rename from MediaBrowser.Plugins.PushBulletNotifications/MediaBrowser.Plugins.PushBulletNotifications.csproj rename to Pushbullet/Pushbullet.csproj index 4d34749..b8a5b6d 100644 --- a/MediaBrowser.Plugins.PushBulletNotifications/MediaBrowser.Plugins.PushBulletNotifications.csproj +++ b/Pushbullet/Pushbullet.csproj @@ -2,8 +2,8 @@ netstandard2.0; - 3.1.2.0 - 3.1.2.0 + 1.0.0 + 1.0.0 @@ -17,7 +17,7 @@ - + - + \ No newline at end of file diff --git a/MediaBrowser.Plugins.PushBulletNotifications/thumb.jpg b/Pushbullet/thumb.jpg similarity index 100% rename from MediaBrowser.Plugins.PushBulletNotifications/thumb.jpg rename to Pushbullet/thumb.jpg diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..cc829ca --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,34 @@ +# ASP.NET Core (.NET Framework) +# Build and test ASP.NET Core projects targeting the full .NET Framework. +# Add steps that publish symbols, save build artifacts, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core + +trigger: +- master + +pool: + vmImage: 'windows-latest' + +variables: + solution: '**/*.sln' + buildPlatform: 'Any CPU' + buildConfiguration: 'Release' + +steps: +- task: NuGetToolInstaller@0 + +- task: NuGetCommand@2 + inputs: + restoreSolution: '$(solution)' + +- task: VSBuild@1 + inputs: + solution: '$(solution)' + msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"' + platform: '$(buildPlatform)' + configuration: '$(buildConfiguration)' + +- task: VSTest@2 + inputs: + platform: '$(buildPlatform)' + configuration: '$(buildConfiguration)' diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..3a6f5f7 --- /dev/null +++ b/build.yaml @@ -0,0 +1,16 @@ +--- +name: "jellyfin-plugin-pushbullet" +guid: "de228f12-e43e-4bd9-9fc0-2830819c3b92" +version: "1" # Please increment with each pull request +jellyfin_version: "10.3.0" # The earliest binary-compatible version +nicename: "Pushbullet" +description: "Jellyfin Pushbullet notification plugin" +overview: > + Get notifications via Pushbullet. +category: "Notifications" +owner: "jellyfin" +artifacts: + - "Pushbullet.dll" +build_type: "dotnet" +dotnet_configuration: "Release" +dotnet_framework: "netstandard2.0"