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

Commit 3320b01

Browse files
Merge pull request #1 from Nickbert7/master
Port to Jellyfin
2 parents bc034dd + e5ca8f9 commit 3320b01

File tree

10 files changed

+107
-71
lines changed

10 files changed

+107
-71
lines changed

MediaBrowser.Plugins.PushBulletNotifications.sln renamed to Pushbullet.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
1+
22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
44
VisualStudioVersion = 15.0.26730.3
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Plugins.PushBulletNotifications", "MediaBrowser.Plugins.PushBulletNotifications\MediaBrowser.Plugins.PushBulletNotifications.csproj", "{DFC6982E-A548-4599-B612-41D307623364}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pushbullet", "Pushbullet\Pushbullet.csproj", "{DFC6982E-A548-4599-B612-41D307623364}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
55
using System.Net;
66
using System.Text;
77
using MediaBrowser.Common.Net;
88
using MediaBrowser.Controller.Net;
9-
using MediaBrowser.Model.Logging;
9+
using Microsoft.Extensions.Logging;
1010
using MediaBrowser.Model.Services;
11-
using MediaBrowser.Plugins.PushBulletNotifications.Configuration;
11+
using Pushbullet.Configuration;
1212
using System.Threading;
1313
using System.Threading.Tasks;
1414

15-
namespace MediaBrowser.Plugins.PushBulletNotifications.Api
15+
namespace Pushbullet.Api
1616
{
17-
[Route("/Notification/PushBullet/Test/{UserID}", "POST", Summary = "Tests PushBullet")]
17+
[Route("/Notification/Pushbullet/Test/{UserID}", "POST", Summary = "Tests Pushbullet")]
1818
public class TestNotification : IReturnVoid
1919
{
2020
[ApiMember(Name = "UserID", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
@@ -26,12 +26,12 @@ class ServerApiEndpoints : IService
2626
private readonly IHttpClient _httpClient;
2727
private readonly ILogger _logger;
2828

29-
public ServerApiEndpoints(ILogManager logManager, IHttpClient httpClient)
29+
public ServerApiEndpoints(ILogger logger, IHttpClient httpClient)
3030
{
31-
_logger = logManager.GetLogger(GetType().Name);
32-
_httpClient = httpClient;
31+
_logger = logger;
32+
_httpClient = httpClient;
3333
}
34-
private PushBulletOptions GetOptions(String userID)
34+
private PushbulletOptions GetOptions(String userID)
3535
{
3636
return Plugin.Instance.Configuration.Options
3737
.FirstOrDefault(i => string.Equals(i.MediaBrowserUserId, userID, StringComparison.OrdinalIgnoreCase));
@@ -51,7 +51,7 @@ public async Task PostAsync(TestNotification request)
5151
{
5252
{"type", "note"},
5353
{"title", "Test Notification" },
54-
{"body", "This is a test notification from MediaBrowser"}
54+
{"body", "This is a test notification from Jellyfin"}
5555
};
5656

5757
var _httpRequest = new HttpRequestOptions();
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using MediaBrowser.Model.Plugins;
44

5-
namespace MediaBrowser.Plugins.PushBulletNotifications.Configuration
5+
namespace Pushbullet.Configuration
66
{
77
public class PluginConfiguration : BasePluginConfiguration
88
{
9-
public PushBulletOptions[] Options { get; set; }
9+
public PushbulletOptions[] Options { get; set; }
1010

1111
public PluginConfiguration()
1212
{
13-
Options = new PushBulletOptions[] { };
13+
Options = new PushbulletOptions[] { };
1414
}
1515
}
1616

17-
public class PushBulletOptions
17+
public class PushbulletOptions
1818
{
1919
public Boolean Enabled { get; set; }
2020
public String Token { get; set; }
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>PushBullet Notifications</title>
4+
<title>Pushbullet Notifications</title>
55
</head>
66
<body>
7-
<div data-role="page" class="page type-interior pluginConfigurationPage pushBulletConfigurationPage" data-require="emby-input,emby-button,emby-checkbox,emby-select">
7+
<div data-role="page" class="page type-interior pluginConfigurationPage PushbulletConfigurationPage" data-require="emby-input,emby-button,emby-checkbox,emby-select">
88

99
<div data-role="content">
1010
<div class="content-primary">
11-
<form class="pushBulletConfigurationForm">
11+
<form class="PushbulletConfigurationForm">
1212
<div style="height:0; overflow: hidden;"><input type="text" name="fakeusernameremembered" tabindex="-1" /><input type="password" name="fakepasswordremembered" tabindex="-1" /></div>
1313
<div class="selectContainer">
14-
<select is="emby-select" id="selectUser" label="Configure PushBullet notifications for:"></select>
14+
<select is="emby-select" id="selectUser" label="Configure Pushbullet notifications for:"></select>
1515
</div>
1616
<label class="checkboxContainer">
17-
<input is="emby-checkbox" type="checkbox" id="chkEnablePushBullet" />
17+
<input is="emby-checkbox" type="checkbox" id="chkEnablePushbullet" />
1818
<span>Enabled</span>
1919
</label>
2020
<div class="inputContainer">
21-
<input is="emby-input" type="text" id="txtPushBulletAuthKey" required="required" label="PushBullet auth token:" />
21+
<input is="emby-input" type="text" id="txtPushbulletAuthKey" required="required" label="Pushbullet auth token:" />
2222
<div class="fieldDescription">
2323
Auth key for your application
2424
</div>
@@ -49,21 +49,21 @@
4949

5050
ApiClient.getPluginConfiguration(pluginId).then(function (config) {
5151

52-
var pushBulletConfig = config.Options.filter(function (c) {
52+
var PushbulletConfig = config.Options.filter(function (c) {
5353

5454
return userId == c.MediaBrowserUserId;
5555

5656
})[0] || {};
5757

58-
$('#chkEnablePushBullet', page).checked(pushBulletConfig.Enabled || false).checkboxradio("refresh");
59-
$('#txtPushBulletAuthKey', page).val(pushBulletConfig.Token || '');
60-
$('#txtPushBulletDeviceId', page).val(pushBulletConfig.DeviceId || '');
58+
$('#chkEnablePushbullet', page).checked(PushbulletConfig.Enabled || false).checkboxradio("refresh");
59+
$('#txtPushbulletAuthKey', page).val(PushbulletConfig.Token || '');
60+
$('#txtPushbulletDeviceId', page).val(PushbulletConfig.DeviceId || '');
6161

6262
Dashboard.hideLoadingMsg();
6363
});
6464
}
6565

66-
$('.pushBulletConfigurationPage').on('pageinit', function (event) {
66+
$('.PushbulletConfigurationPage').on('pageinit', function (event) {
6767

6868
var page = this;
6969

@@ -96,7 +96,7 @@
9696

9797
ApiClient.ajax({
9898
type: "POST",
99-
url: ApiClient.getUrl("Notification/PushBullet/Test/" + c.MediaBrowserUserId)
99+
url: ApiClient.getUrl("Notification/Pushbullet/Test/" + c.MediaBrowserUserId)
100100

101101
}).then(function () {
102102
Dashboard.hideLoadingMsg();
@@ -124,7 +124,7 @@
124124
Dashboard.hideLoadingMsg();
125125
});
126126

127-
$('.pushBulletConfigurationForm').on('submit', function (e) {
127+
$('.PushbulletConfigurationForm').on('submit', function (e) {
128128

129129
Dashboard.showLoadingMsg();
130130

@@ -134,22 +134,22 @@
134134

135135
var userId = $('#selectUser', form).val();
136136

137-
var pushBulletConfig = config.Options.filter(function (c) {
137+
var PushbulletConfig = config.Options.filter(function (c) {
138138

139139
return userId == c.MediaBrowserUserId;
140140

141141
})[0];
142142

143-
if (!pushBulletConfig) {
144-
pushBulletConfig = {};
145-
config.Options.push(pushBulletConfig);
143+
if (!PushbulletConfig) {
144+
PushbulletConfig = {};
145+
config.Options.push(PushbulletConfig);
146146
}
147147

148-
pushBulletConfig.MediaBrowserUserId = userId;
148+
PushbulletConfig.MediaBrowserUserId = userId;
149149

150-
pushBulletConfig.Enabled = $('#chkEnablePushBullet', form).checked();
151-
pushBulletConfig.Token = $('#txtPushBulletAuthKey', form).val();
152-
pushBulletConfig.DeviceId = $('#txtPushBulletDeviceId', form).val();
150+
PushbulletConfig.Enabled = $('#chkEnablePushbullet', form).checked();
151+
PushbulletConfig.Token = $('#txtPushbulletAuthKey', form).val();
152+
PushbulletConfig.DeviceId = $('#txtPushbulletDeviceId', form).val();
153153

154154
ApiClient.updatePluginConfiguration(pluginId, config).then(Dashboard.processPluginConfigurationUpdateResult);
155155
});
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
using MediaBrowser.Common.Net;
44
using MediaBrowser.Controller.Entities;
55
using MediaBrowser.Controller.Notifications;
6-
using MediaBrowser.Model.Logging;
7-
using MediaBrowser.Plugins.PushBulletNotifications.Configuration;
6+
using Microsoft.Extensions.Logging;
7+
using Pushbullet.Configuration;
88
using System;
99
using System.Linq;
1010
using System.Threading;
1111
using System.Threading.Tasks;
1212

13-
namespace MediaBrowser.Plugins.PushBulletNotifications
13+
namespace Pushbullet
1414
{
1515
public class Notifier : INotificationService
1616
{
1717
private readonly ILogger _logger;
1818
private readonly IHttpClient _httpClient;
1919

20-
public Notifier(ILogManager logManager, IHttpClient httpClient)
20+
public Notifier(ILogger logger, IHttpClient httpClient)
2121
{
22-
_logger = logManager.GetLogger(GetType().Name);
23-
_httpClient = httpClient;
22+
_logger = logger;
23+
_httpClient = httpClient;
2424
}
2525

2626
public bool IsEnabledForUser(User user)
@@ -30,7 +30,7 @@ public bool IsEnabledForUser(User user)
3030
return options != null && IsValid(options) && options.Enabled;
3131
}
3232

33-
private PushBulletOptions GetOptions(User user)
33+
private PushbulletOptions GetOptions(User user)
3434
{
3535
return Plugin.Instance.Configuration.Options
3636
.FirstOrDefault(i => string.Equals(i.MediaBrowserUserId, user.Id.ToString("N"), StringComparison.OrdinalIgnoreCase));
@@ -53,7 +53,7 @@ public async Task SendNotification(UserNotification request, CancellationToken c
5353
{"body", request.Description}
5454
};
5555

56-
_logger.Debug("PushBullet to Token : {0} - {1} - {2}", options.Token, options.DeviceId, request.Description);
56+
_logger.LogDebug("Pushbullet to Token : {0} - {1} - {2}", options.Token, options.DeviceId, request.Description);
5757
var _httpRequest = new HttpRequestOptions();
5858
string authInfo = options.Token;
5959
authInfo = Convert.ToBase64String(Encoding.UTF8.GetBytes(authInfo));
@@ -70,7 +70,7 @@ public async Task SendNotification(UserNotification request, CancellationToken c
7070
}
7171
}
7272

73-
private bool IsValid(PushBulletOptions options)
73+
private bool IsValid(PushbulletOptions options)
7474
{
7575
return !string.IsNullOrEmpty(options.Token);
7676
}
Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using MediaBrowser.Common.Configuration;
44
using MediaBrowser.Common.Plugins;
55
using MediaBrowser.Model.Plugins;
66
using MediaBrowser.Model.Serialization;
7-
using MediaBrowser.Plugins.PushBulletNotifications.Configuration;
7+
using Pushbullet.Configuration;
88
using MediaBrowser.Model.Drawing;
99
using System.IO;
1010

11-
namespace MediaBrowser.Plugins.PushBulletNotifications
11+
namespace Pushbullet
1212
{
13-
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages, IHasThumbImage
13+
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
1414
{
1515
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
1616
: base(applicationPaths, xmlSerializer)
@@ -20,7 +20,7 @@ public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
2020

2121
public override string Name
2222
{
23-
get { return "PushBullet Notifications"; }
23+
get { return "Pushbullet Notifications"; }
2424
}
2525

2626
public IEnumerable<PluginPageInfo> GetPages()
@@ -39,7 +39,7 @@ public override string Description
3939
{
4040
get
4141
{
42-
return "Sends notifications via PushBullet Service.";
42+
return "Sends notifications via Pushbullet Service.";
4343
}
4444
}
4545

@@ -49,20 +49,6 @@ public override Guid Id
4949
get { return _id; }
5050
}
5151

52-
public Stream GetThumbImage()
53-
{
54-
var type = GetType();
55-
return type.Assembly.GetManifestResourceStream(type.Namespace + ".thumb.jpg");
56-
}
57-
58-
public ImageFormat ThumbImageFormat
59-
{
60-
get
61-
{
62-
return ImageFormat.Jpg;
63-
}
64-
}
65-
6652
public static Plugin Instance { get; private set; }
6753
}
6854
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
5-
<AssemblyVersion>3.1.2.0</AssemblyVersion>
6-
<FileVersion>3.1.2.0</FileVersion>
5+
<AssemblyVersion>1.0.0</AssemblyVersion>
6+
<FileVersion>1.0.0</FileVersion>
77
</PropertyGroup>
88

99
<ItemGroup>
@@ -17,7 +17,7 @@
1717
</ItemGroup>
1818

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

23-
</Project>
23+
</Project>
File renamed without changes.

azure-pipelines.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# ASP.NET Core (.NET Framework)
2+
# Build and test ASP.NET Core projects targeting the full .NET Framework.
3+
# Add steps that publish symbols, save build artifacts, and more:
4+
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
5+
6+
trigger:
7+
- master
8+
9+
pool:
10+
vmImage: 'windows-latest'
11+
12+
variables:
13+
solution: '**/*.sln'
14+
buildPlatform: 'Any CPU'
15+
buildConfiguration: 'Release'
16+
17+
steps:
18+
- task: NuGetToolInstaller@0
19+
20+
- task: NuGetCommand@2
21+
inputs:
22+
restoreSolution: '$(solution)'
23+
24+
- task: VSBuild@1
25+
inputs:
26+
solution: '$(solution)'
27+
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
28+
platform: '$(buildPlatform)'
29+
configuration: '$(buildConfiguration)'
30+
31+
- task: VSTest@2
32+
inputs:
33+
platform: '$(buildPlatform)'
34+
configuration: '$(buildConfiguration)'

build.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: "jellyfin-plugin-pushbullet"
3+
guid: "de228f12-e43e-4bd9-9fc0-2830819c3b92"
4+
version: "1" # Please increment with each pull request
5+
jellyfin_version: "10.3.0" # The earliest binary-compatible version
6+
nicename: "Pushbullet"
7+
description: "Jellyfin Pushbullet notification plugin"
8+
overview: >
9+
Get notifications via Pushbullet.
10+
category: "Notifications"
11+
owner: "jellyfin"
12+
artifacts:
13+
- "Pushbullet.dll"
14+
build_type: "dotnet"
15+
dotnet_configuration: "Release"
16+
dotnet_framework: "netstandard2.0"

0 commit comments

Comments
 (0)