Skip to content

Commit

Permalink
Merge pull request #6 from PrplHaz4/fixlinuxpath
Browse files Browse the repository at this point in the history
Fix Recorded TV for non-Windows servers, improve config pages
  • Loading branch information
PrplHaz4 authored Oct 17, 2019
2 parents dd1d7e1 + c871db3 commit 572fa09
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class PluginConfiguration : BasePluginConfiguration
/// <summary>
/// Initializes a new instance of the <see cref="PluginConfiguration" /> class.
/// </summary>
public PluginConfiguration() : base()
public PluginConfiguration()
{
ServerIP = "localhost";
ServerPort = 9080;
Expand Down
143 changes: 51 additions & 92 deletions Jellyfin.Plugin.ServerWMC/Configuration/configPage.html
Original file line number Diff line number Diff line change
@@ -1,111 +1,70 @@
<!DOCTYPE html>
<html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>ServerWMC</title>
</head>
<body>
<div data-role="page" class="page type-interior pluginConfigurationPage serverwmcConfigurationPage">

<div id="ServerWMCConfigurationPage" data-role="page" class="page type-interior pluginConfigurationPage" data-require="emby-input,emby-button">
<div data-role="content">
<div class="content-primary">
<form class="serverwmcConfigurationForm">

<ul class="ulForm" data-role="listview">
<li>
<a href="http://bit.ly/serverwmc" target="_blank">
ServerWMC app is required for this plugin, download installer here
</a>
<p class="fieldDescription">
The ServerWMC app needs to be running on the machine that has WMC installed and configured, but the WMC app does not need to be running to use the program.
</p>
<p class="fieldDescription">
If Jellyfin Server is running on a different machine than ServerWMC, make sure that the 'Recorded TV' folder that is used for new recordings is shared on the network (see 'Folders' tab in ServerWMC), and make sure the Jellyfin Server can access this folder.
</p>
</li>
<li>
<label for="txtServerWMCIP">
ServerWMC IP/Name:
</label>
<input type="text" id="txtServerWMCIP" name="txtServerWMCIP" />
<div class="fieldDescription">
The ip address or name of your ServerWMC machine
</div>
</li>
<li>
<label for="txtServerWMCPort">
ServerWMC Port:
</label>
<input id="txtServerWMCPort" name="txtServerWMCPort" type="number" pattern="[0-9]*" min="1" />
<div class="fieldDescription">
The Port of your ServerWMC machine
</div>
</li>
<li>
<label for="txtLinux">
Linux 'Recorded TV' path:
</label>
<input type="text" id="txtLinuxPath" name="txtLinuxPath" />
<div class="fieldDescription">
For Emby running on Linux, WMC's 'recorded tv' share needs to be mounted and the linux path to this directory needs to be entered here.
</div>
</li>
<li>
<button type="submit" data-theme="b">Save</button>
<button type="button" onclick="history.back();">Cancel</button>
</li>
</ul>

<h1>ServerWMC</h1>
<p>ServerWMC app is required for this plugin, download installer here (<a href="https://serverwmc.github.io/" target="_blank">https://serverwmc.github.io/</a>)</p>
<p>The ServerWMC app needs to be running on the machine that has WMC installed and configured, but the WMC app does not need to be running to use the program.</p>
<p>If Jellyfin Server is running on a different machine than ServerWMC, make sure that the 'Recorded TV' folder that is used for new recordings is shared on the network (see 'Folders' tab in ServerWMC), and that the Jellyfin Server can access this folder.</p>

<h2>Configuration</h2>
<form id="ServerWMCConfigurationForm">
<div class="inputContainer">
<label class="inputeLabel inputLabelUnfocused" for="txtServerWMCIP">ServerWMC IP/Name</label>
<input id="txtServerWMCIP" name="txtServerWMCIP" type="text" is="emby-input" />
<div class="fieldDescription">The ip address or name of your ServerWMC machine</div>
</div>
<div class="inputContainer">
<label class="inputeLabel inputLabelUnfocused" for="txtServerWMCPort">ServerWMC Port</label>
<input id="txtServerWMCPort" name="txtServerWMCPort" type="number" pattern="[0-9]*" min="1" is="emby-input" />
<div class="fieldDescription">The port used to access ServerWMC (default is 9080)</div>
</div>
<div class="inputContainer">
<label class="inputeLabel inputLabelUnfocused" for="txtLinuxPath">Linux 'Recorded TV' path</label>
<input id="txtLinuxPath" name="txtLinuxPath" type="text" is="emby-input" />
<div class="fieldDescription">For Jellyfin running on Linux, WMC's 'recorded tv' share needs to be mounted and the Linux path to this directory needs to be entered here.</div>
</div>
<div>
<button is="emby-button" type="submit" class="raised button-submit block emby-button">
<span>Save</span>
</button>
</div>
</form>
</div>
</div>

<script type="text/javascript">

var ServerWMCConfigurationPage = {
pluginUniqueId: "1fc322a1-af2e-49a5-b2eb-a89b4240f700"
var ServerWMCConfig = {
pluginUniqueId: '1fc322a1-af2e-49a5-b2eb-a89b4240f700'
};

$('.serverwmcConfigurationPage').on('pageshow', function (event) {

Dashboard.showLoadingMsg();

var page = this;

ApiClient.getPluginConfiguration(ServerWMCConfigurationPage.pluginUniqueId).then(function (config) {

$('#txtServerWMCIP', page).val(config.ServerIP || "");
$('#txtServerWMCPort', page).val(config.ServerPort || "");
$('#txtLinuxPath', page).val(config.LinuxPath || "");
$('#txtMaxEpgDownload', page).val(config.EpgMaxDownload || "");

Dashboard.hideLoadingMsg();
$('#ServerWMCConfigurationPage').on('pageshow', function () {
ApiClient.getPluginConfiguration(ServerWMCConfig.pluginUniqueId).then(function (config) {
var page = $.mobile.activePage;
$('#txtServerWMCIP', page).val(config.ServerIP).change();
$('#txtServerWMCPort', page).val(config.ServerPort).change();
$('#txtLinuxPath', page).val(config.LinuxPath).change();
});
});

$('.serverwmcConfigurationPage').on('submit', function (e) {

Dashboard.showLoadingMsg();

var form = this;

ApiClient.getPluginConfiguration(ServerWMCConfigurationPage.pluginUniqueId).then(function (config) {

var serverIP = $('#txtServerWMCIP', form).val();
var serverPort = $('#txtServerWMCPort', form).val();
var linuxPath = $('#txtLinuxPath', form).val();
var maxEpgDownload = $('#txtMaxEpgDownload', form).val();

config.ServerIP = serverIP ? serverIP : null;
config.ServerPort = serverPort ? serverPort : null;
config.LinuxPath = linuxPath ? linuxPath : null;
config.EpgMaxDownload = maxEpgDownload ? maxEpgDownload : null;

ApiClient.updatePluginConfiguration(ServerWMCConfigurationPage.pluginUniqueId, config).then(Dashboard.processPluginConfigurationUpdateResult,
function () {
alert('There was an error communicating with ServerWmc. Please make sure the ServerWmc application is installed and running, and reachable from the above configured address.');
});
$('#ServerWMCConfigurationForm').on('submit', function () {
ApiClient.getPluginConfiguration(ServerWMCConfig.pluginUniqueId).then(function (config) {
var page = $.mobile.activePage;
config.ServerIP = $('#txtServerWMCIP', page).val();
config.ServerPort = $('#txtServerWMCPort', page).val();
config.LinuxPath = $('#txtLinuxPath', page).val();
ApiClient.updatePluginConfiguration(ServerWMCConfig.pluginUniqueId, config).then(function (result) {
Dashboard.processPluginConfigurationUpdateResult(result);
},
function (result) {
Dashboard.alert("Saving configuration failed.");
});
});

return false;
});
</script>
Expand Down
4 changes: 2 additions & 2 deletions Jellyfin.Plugin.ServerWMC/Jellyfin.Plugin.ServerWMC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>Jellyfin.Plugin.ServerWMC</RootNamespace>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<AssemblyVersion>2.0.0</AssemblyVersion>
<FileVersion>2.0.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
40 changes: 20 additions & 20 deletions Jellyfin.Plugin.ServerWMC/WMCService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,23 @@ public WMCService(IHttpClient httpClient, IFileSystem fileSystem, ILoggerFactory
_clientVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

SocketClientAsync.InitAddress(Plugin.Instance.Configuration.ServerIP, Plugin.Instance.Configuration.ServerPort); // set ip and port
_logger.LogInformation("Config IP: {0} ({1}), Config Port: {2}",
_logger.LogInformation("[ServerWMC] Config IP: {0} ({1}), Config Port: {2}",
Plugin.Instance.Configuration.ServerIP,
SocketClientAsync.IpAddr,
Plugin.Instance.Configuration.ServerPort);

//Thread.Sleep(20000);

_linuxPath = null; // linux path obsoleted in .net core
_linuxPath = Plugin.Instance.Configuration.LinuxPath;

// read newest serverwmc build from autoupdate site
var newBuild = GetNewestSWMCBuild();
if (newBuild == 0)
_logger.LogInformation("Using last hardcoded build value: " + _newestBuild);
_logger.LogInformation("[ServerWMC] Using last hardcoded build value: " + _newestBuild);
else
{
_newestBuild = newBuild;
_logger.LogInformation("Newest ServerWMC build value found: " + _newestBuild);
_logger.LogInformation("[ServerWMC] Newest ServerWMC build value found: " + _newestBuild);
}

_fileSystem = fileSystem; // for file access, not used currently
Expand Down Expand Up @@ -205,7 +205,7 @@ public int GetNewestSWMCBuild()
}
catch (Exception ex)
{
_logger.LogError("Failed check for checking for newest ServerWMC version number: " + ex);
_logger.LogError("[ServerWMC] Failed check for checking for newest ServerWMC version number: " + ex);
return 0;
}
}
Expand Down Expand Up @@ -517,12 +517,12 @@ MediaStream GetMediaStream(string str)
}
}
else
_logger.LogError("GetMediaStream> Prop name: " + propName + " not found");
_logger.LogError("[ServerWMC] GetMediaStream> Prop name: " + propName + " not found");
}
}
catch (Exception ex)
{
_logger.LogError("GetMediaStream> Media stream parse error: {0}", ex);
_logger.LogError("[ServerWMC] GetMediaStream> Media stream parse error: {0}", ex);
}
}
return ms;
Expand Down Expand Up @@ -582,7 +582,7 @@ public async Task<MediaSourceInfo> GetChannelStream(string channelId, string tra
}
else // tell server file was not accesible and throw an error
{
_logger.LogError("GetChannelStream> stream file not found: {0}", strm);
_logger.LogError("[ServerWMC] GetChannelStream> stream file not found: {0}", strm);
// tell server stream did not start
await SocketClientAsync.GetVectorAsync(XferString("StreamStartError", strm), cancellationToken, streamId);
throw new Exception("ServerWMC: Stream file not not found: " + strm);
Expand Down Expand Up @@ -724,7 +724,7 @@ public async Task<IEnumerable<ChannelInfo>> GetChannelsAsync(System.Threading.Ca
}
catch (Exception ex)
{
_logger.LogError("GetChannelsAsync> " + ex);
_logger.LogError("[ServerWMC] GetChannelsAsync> " + ex);
throw ex;
}

Expand Down Expand Up @@ -797,7 +797,7 @@ public async Task CreateTimerAsync(TimerInfo info, System.Threading.Cancellation

if (DateTimeOffset.UtcNow >= info.EndDate)
{
_logger.LogError("CreateTimerAsync> requested program '{0}' has already aired; EndTime(UTC): {1}, CurrentTime(UTC): {2}", info.Name, info.EndDate, DateTimeOffset.UtcNow);
_logger.LogError("[ServerWMC] CreateTimerAsync> requested program '{0}' has already aired; EndTime(UTC): {1}, CurrentTime(UTC): {2}", info.Name, info.EndDate, DateTimeOffset.UtcNow);
throw new Exception("ServerWMC: Can't record: program occurs in the past");
}

Expand All @@ -822,7 +822,7 @@ public async Task CreateTimerAsync(TimerInfo info, System.Threading.Cancellation
{
LastRecordingChange = DateTimeOffset.UtcNow;

_logger.LogInformation("CreateTimerAsync> recording added for timer '{0}', status {1}", info.Name, info.Status);
_logger.LogInformation("[ServerWMC] CreateTimerAsync> recording added for timer '{0}', status {1}", info.Name, info.Status);

if (responses.Length > 1) // if there is extra results sent from server...
{
Expand All @@ -836,15 +836,15 @@ public async Task CreateTimerAsync(TimerInfo info, System.Threading.Cancellation
}
else if (splitResult[0] == "recordingChannel") // service picked a different channel for timer
{
_logger.LogInformation("CreateTimerAsync> timer channel changed by wmc to '{0}'", splitResult[1]);
_logger.LogInformation("[ServerWMC] CreateTimerAsync> timer channel changed by wmc to '{0}'", splitResult[1]);
}
else if (splitResult[0] == "recordingTime") // service picked a different start time for timer
{
_logger.LogInformation("CreateTimerAsync> timer start time changed by wmc to '{0}'", splitResult[1]);
_logger.LogInformation("[ServerWMC] CreateTimerAsync> timer start time changed by wmc to '{0}'", splitResult[1]);
}
else if (splitResult[0] == "increasedEndTime") // end time has been increased on an instant record
{
_logger.LogInformation("CreateTimerAsync> instant record end time increased by '{0}' minutes", splitResult[1]);
_logger.LogInformation("[ServerWMC] CreateTimerAsync> instant record end time increased by '{0}' minutes", splitResult[1]);
}
}
}
Expand Down Expand Up @@ -961,7 +961,7 @@ public async Task<IEnumerable<TimerInfo>> GetTimersAsync(System.Threading.Cancel
}
catch (Exception ex)
{
_logger.LogError("GetTimersAsync> " + ex);
_logger.LogError("[ServerWMC] GetTimersAsync> " + ex);
throw ex;
}

Expand Down Expand Up @@ -1015,7 +1015,7 @@ public async Task<IEnumerable<SeriesTimerInfo>> GetSeriesTimersAsync(System.Thre
}
catch (Exception ex)
{
_logger.LogError("GetSeriesTimersAsync> " + ex);
_logger.LogError("[ServerWMC] GetSeriesTimersAsync> " + ex);
throw ex;
}

Expand Down Expand Up @@ -1144,7 +1144,7 @@ public async Task<MediaSourceInfo> GetRecordingStream(string recordingId, string
}
else // tell server file was not accesible and throw an error
{
_logger.LogError("GetRecordingStream> stream file not found: {0}", strmFile);
_logger.LogError("[ServerWMC] GetRecordingStream> stream file not found: {0}", strmFile);
// tell server stream did not start
await SocketClientAsync.GetVectorAsync(XferString("StreamStartError", strmFile), cancellationToken, streamId);
throw new Exception("ServerWMC: Stream file not not found: " + strmFile);
Expand Down Expand Up @@ -1315,7 +1315,7 @@ public async Task<IEnumerable<MyRecordingInfo>> GetAllRecordingsAsync(System.Thr
}
catch (Exception ex)
{
_logger.LogError("GetRecordingsAsync> " + ex.Message);
_logger.LogError("[ServerWMC] GetRecordingsAsync> " + ex.Message);
throw ex;
}

Expand Down Expand Up @@ -1410,7 +1410,7 @@ public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(string channelId, D
}
catch (Exception ex)
{
_logger.LogError("GetProgramsAsync> " + ex.Message);
_logger.LogError("[ServerWMC] GetProgramsAsync> " + ex.Message);
throw ex;
}

Expand Down Expand Up @@ -1503,7 +1503,7 @@ public async Task<LiveTvServiceStatusInfo> GetStatusInfoAsync(CancellationToken
}
catch (Exception ex)
{
_logger.LogError("GetStatusInfoAsync::TunerStatus> " + ex.Message);
_logger.LogError("[ServerWMC] GetStatusInfoAsync::TunerStatus> " + ex.Message);
throw ex;
}
#endregion
Expand Down
2 changes: 1 addition & 1 deletion build.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: "jellyfin-plugin-serverwmc"
guid: "1fc322a1-af2e-49a5-b2eb-a89b4240f700"
version: "1" # Please increment with each pull request
version: "2" # Please increment with each pull request
jellyfin_version: "10.3.0" # The earliest binary-compatible version
nicename: "ServerWMC"
description: "Jellyfin LiveTV plugin for Windows MediaCenter with ServerWMC"
Expand Down

0 comments on commit 572fa09

Please sign in to comment.