Skip to content
This repository has been archived by the owner on Aug 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from Nickbert7/master
Browse files Browse the repository at this point in the history
Port to Jellyfin
  • Loading branch information
joshuaboniface authored May 9, 2019
2 parents bc034dd + e5ca8f9 commit 3320b01
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 71 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
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")]
Expand All @@ -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));
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<title>PushBullet Notifications</title>
<title>Pushbullet Notifications</title>
</head>
<body>
<div data-role="page" class="page type-interior pluginConfigurationPage pushBulletConfigurationPage" data-require="emby-input,emby-button,emby-checkbox,emby-select">
<div data-role="page" class="page type-interior pluginConfigurationPage PushbulletConfigurationPage" data-require="emby-input,emby-button,emby-checkbox,emby-select">

<div data-role="content">
<div class="content-primary">
<form class="pushBulletConfigurationForm">
<form class="PushbulletConfigurationForm">
<div style="height:0; overflow: hidden;"><input type="text" name="fakeusernameremembered" tabindex="-1" /><input type="password" name="fakepasswordremembered" tabindex="-1" /></div>
<div class="selectContainer">
<select is="emby-select" id="selectUser" label="Configure PushBullet notifications for:"></select>
<select is="emby-select" id="selectUser" label="Configure Pushbullet notifications for:"></select>
</div>
<label class="checkboxContainer">
<input is="emby-checkbox" type="checkbox" id="chkEnablePushBullet" />
<input is="emby-checkbox" type="checkbox" id="chkEnablePushbullet" />
<span>Enabled</span>
</label>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtPushBulletAuthKey" required="required" label="PushBullet auth token:" />
<input is="emby-input" type="text" id="txtPushbulletAuthKey" required="required" label="Pushbullet auth token:" />
<div class="fieldDescription">
Auth key for your application
</div>
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -124,7 +124,7 @@
Dashboard.hideLoadingMsg();
});

$('.pushBulletConfigurationForm').on('submit', function (e) {
$('.PushbulletConfigurationForm').on('submit', function (e) {

Dashboard.showLoadingMsg();

Expand All @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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));
Expand All @@ -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));
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<PluginConfiguration>, IHasWebPages, IHasThumbImage
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
{
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
: base(applicationPaths, xmlSerializer)
Expand All @@ -20,7 +20,7 @@ public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)

public override string Name
{
get { return "PushBullet Notifications"; }
get { return "Pushbullet Notifications"; }
}

public IEnumerable<PluginPageInfo> GetPages()
Expand All @@ -39,7 +39,7 @@ public override string Description
{
get
{
return "Sends notifications via PushBullet Service.";
return "Sends notifications via Pushbullet Service.";
}
}

Expand All @@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
<AssemblyVersion>3.1.2.0</AssemblyVersion>
<FileVersion>3.1.2.0</FileVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -17,7 +17,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="mediabrowser.server.core" Version="3.6.0.36-beta" />
<PackageReference Include="Jellyfin.Controller" Version="10.*" />
</ItemGroup>

</Project>
</Project>
File renamed without changes
34 changes: 34 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -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)'
16 changes: 16 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 3320b01

Please sign in to comment.