Skip to content

Commit

Permalink
1.308
Browse files Browse the repository at this point in the history
Jriver remote changes for local playback files
Fix for FilePath errors hopefully
  • Loading branch information
Ghawken committed Oct 19, 2019
1 parent 5de685b commit 932a374
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 85 deletions.
2 changes: 1 addition & 1 deletion FrontView/Libs/Weather.cs
Expand Up @@ -329,7 +329,7 @@ public WeatherData GetWeatherDataNew(string locId, bool force)
}
catch (Exception ex)
{
Logger.Instance().Trace("Weather:", "DarkSky Error" + ex);
Logger.Instance().Trace("Weather:", "DarkSky Caught Error:" + ex);
return null;
}

Expand Down
191 changes: 111 additions & 80 deletions FrontView/Plugins/Remote.Jriver/Api/Xbmc.Player.cs
Expand Up @@ -17,20 +17,20 @@
// ------------------------------------------------------------------------

using System;
using System.Collections;
//using System.Collections;
using System.Globalization;
using Jayrock.Json;
using Plugin;
using System.Web.Script.Serialization;
using System.Xml;
//using System.Web.Script.Serialization;
//using System.Xml;
using System.Xml.Serialization;
using System.Net;
using System.Text.RegularExpressions;
using Setup;
//using System.Text.RegularExpressions;
//using Setup;
using System.IO;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
//using System.Diagnostics;
//using System.Text;

namespace Remote.Jriver.Api
{
Expand Down Expand Up @@ -186,100 +186,131 @@ public void RefreshNowPlaying()
var serverArt = getItemName(deserialized, "ImageURL");
_parent.Log("JRiver: server.Art EQUALS ===========" + serverArt);

var sw = Stopwatch.StartNew();
var filePath = Path.GetDirectoryName(_nowPlaying.FileName);
string[] files = System.IO.Directory.GetFiles(filePath);
// var sw = Stopwatch.StartNew();

var extrafanart = false;
string extrafanartbackdropfile = "";

var extrafanartpath = Path.Combine(filePath, "extrafanart");

_parent.Log("JRiver: nowPlaying extrafanartPath to check equals:" + extrafanartpath);

if (Directory.Exists(extrafanartpath))
var filePath = "BAD";
try
{
var extrafanartFiles = System.IO.Directory.GetFiles(extrafanartpath, "*.jpg");
_parent.Log("JRiver: nowPlaying extrafanartPath Exists:");
_parent.Log("JRiver: extrafanart Files: "+ string.Join(", ", extrafanartFiles));
// check files
if (extrafanartFiles != null && extrafanartFiles.Length > 0)
{
extrafanart = true;
// get random item
var idx = new Random().Next(extrafanartFiles.Length);
_parent.Log("JRiver: ExtrafanartFiles Index ==============" + idx);
extrafanartbackdropfile = extrafanartFiles[idx];
_parent.Log("JRiver: extrabackdropfile ==============" + extrafanartbackdropfile);
}
filePath = Path.GetDirectoryName(_nowPlaying.FileName);
extrafanart = true; //Path Seems to be okay
}

var fanartPath = Path.Combine(filePath, "fanart.jpg");
var LogoPath = Path.Combine(filePath, "logo.png");
var ThumbPath = Path.Combine(filePath, "poster.jpg");
var ThumbPath2 = Path.Combine(filePath, "folder.jpg");

string CustomArt = "Default.";
if (!String.IsNullOrEmpty(_nowPlaying.FileName))
catch
{
CustomArt = _nowPlaying.FileName.Remove(_nowPlaying.FileName.Length - 3);
_parent.Log("JRIVER: nowPlaying Bad filePath: Caught: ");
extrafanart = false;
}

CustomArt = CustomArt + "jpg";
_parent.Log("Jriver: CustomArt: Check: " + CustomArt);

_parent.Log("JRiver: ** filePath ** :" + filePath);
//_parent.Log("JRiver: Files in path:" + string.Join(", ", files) );
_parent.Log("JRiver: Checking.... ** fanArt.Jpg ** ** Logo.Png ** ** poster.Jpg ** ** folder.jpg ** :");
int pos = Array.IndexOf(files, fanartPath);

if (extrafanart == true && extrafanartbackdropfile != "" )
string[] files = new string[] { };
if (extrafanart)
{
_nowPlaying.FanartURL = extrafanartbackdropfile;
}
else if (pos > -1)
{
_nowPlaying.FanartURL = files[pos]; //if fanart.jpg exisits in directory with movie use this otherwise default to JRiver Thumb
files = System.IO.Directory.GetFiles(filePath);
}
else
{
_nowPlaying.FanartURL = @"http://" + _parent.IP + ":" + _parent.Port + @"/" + serverArt + "&Type=Full&Token=" + _parent.JRiverAuthToken;
files = new string[] { "Empty" };
}

string extrafanartbackdropfile = "";


pos = Array.IndexOf(files, LogoPath);
if (pos > -1)
{
_nowPlaying.LogoURL = files[pos];
}
else
if (extrafanart)
{
_nowPlaying.LogoURL = "";
var extrafanartpath = Path.Combine(filePath, "extrafanart");
_parent.Log("JRiver: nowPlaying extrafanartPath to check equals:" + extrafanartpath);
if (Directory.Exists(extrafanartpath))
{
var extrafanartFiles = System.IO.Directory.GetFiles(extrafanartpath, "*.jpg");
_parent.Log("JRiver: nowPlaying extrafanartPath Exists:");
_parent.Log("JRiver: extrafanart Files: " + string.Join(", ", extrafanartFiles));
// check files
if (extrafanartFiles != null && extrafanartFiles.Length > 0)
{
extrafanart = true;
// get random item
var idx = new Random().Next(extrafanartFiles.Length);
_parent.Log("JRiver: ExtrafanartFiles Index ==============" + idx);
extrafanartbackdropfile = extrafanartFiles[idx];
_parent.Log("JRiver: extrabackdropfile ==============" + extrafanartbackdropfile);
}
}
}
pos = Array.IndexOf(files, ThumbPath);
int pos2 = Array.IndexOf(files, ThumbPath2);
int pos3 = Array.IndexOf(files, CustomArt);

if (pos > -1)
if (filePath != "BAD")
{
_nowPlaying.ThumbURL = files[pos];
}
else if (pos2 > -1)
{
_nowPlaying.ThumbURL = files[pos2];
}
else if (pos3 > -1)
{
_nowPlaying.ThumbURL = files[pos3];
var fanartPath = Path.Combine(filePath, "fanart.jpg");
var LogoPath = Path.Combine(filePath, "logo.png");
var ThumbPath = Path.Combine(filePath, "poster.jpg");
var ThumbPath2 = Path.Combine(filePath, "folder.jpg");

string CustomArt = "Default.";
if (!String.IsNullOrEmpty(_nowPlaying.FileName))
{
CustomArt = _nowPlaying.FileName.Remove(_nowPlaying.FileName.Length - 3);
}

CustomArt = CustomArt + "jpg";
_parent.Log("Jriver: CustomArt: Check: " + CustomArt);

_parent.Log("JRiver: ** filePath ** :" + filePath);
//_parent.Log("JRiver: Files in path:" + string.Join(", ", files) );
_parent.Log("JRiver: Checking.... ** fanArt.Jpg ** ** Logo.Png ** ** poster.Jpg ** ** folder.jpg ** :");
int pos = Array.IndexOf(files, fanartPath);

if (extrafanart == true && extrafanartbackdropfile != "")
{
_nowPlaying.FanartURL = extrafanartbackdropfile;
}
else if (pos > -1)
{
_nowPlaying.FanartURL = files[pos]; //if fanart.jpg exisits in directory with movie use this otherwise default to JRiver Thumb
}
else
{
_nowPlaying.FanartURL = @"http://" + _parent.IP + ":" + _parent.Port + @"/" + serverArt + "&Type=Full&Token=" + _parent.JRiverAuthToken;
}


pos = Array.IndexOf(files, LogoPath);
if (pos > -1)
{
_nowPlaying.LogoURL = files[pos];
}
else
{
_nowPlaying.LogoURL = "";
}
pos = Array.IndexOf(files, ThumbPath);
int pos2 = Array.IndexOf(files, ThumbPath2);
int pos3 = Array.IndexOf(files, CustomArt);

if (pos > -1)
{
_nowPlaying.ThumbURL = files[pos];
}
else if (pos2 > -1)
{
_nowPlaying.ThumbURL = files[pos2];
}
else if (pos3 > -1)
{
_nowPlaying.ThumbURL = files[pos3];
}
else
{
// _nowPlaying.FanartURL = @"http://" + _parent.IP + ":" + _parent.Port + @"/"+ serverArt + "&Type=Full&Token="+_parent.JRiverAuthToken;
_nowPlaying.ThumbURL = @"http://" + _parent.IP + ":" + _parent.Port + @"/" + serverArt + "&Type=Full&Token=" + _parent.JRiverAuthToken;
}

//sw.Stop();
}
else
else // No filePath information. Nothing to get except http file from Jrvier

{
// _nowPlaying.FanartURL = @"http://" + _parent.IP + ":" + _parent.Port + @"/"+ serverArt + "&Type=Full&Token="+_parent.JRiverAuthToken;
_nowPlaying.FanartURL = @"http://" + _parent.IP + ":" + _parent.Port + @"/" + serverArt + "&Type=Full&Token=" + _parent.JRiverAuthToken;
_nowPlaying.ThumbURL = @"http://" + _parent.IP + ":" + _parent.Port + @"/" + serverArt + "&Type=Full&Token=" + _parent.JRiverAuthToken;
_nowPlaying.LogoURL = "";
}

sw.Stop();
_parent.Log("JRIVER: STOPWATCH: Elapsed MS " + sw.ElapsedMilliseconds);
// _parent.Log("JRIVER: STOPWATCH: Elapsed MS " + sw.ElapsedMilliseconds);


_parent.Log("JRiver: nowPlaying Fanart equals:" + _nowPlaying.FanartURL);
Expand Down
7 changes: 7 additions & 0 deletions FrontView/Plugins/Remote.Jriver/Api/Xbmc.cs
Expand Up @@ -166,11 +166,18 @@ public string GetDownloadPath(string fileName)
try
{
if (!_configured) return null;
if (fileName == "") return null;
if (fileName.StartsWith(@"\\"))
{
Log("JRiver: GetDownloadPath: \\ Found Returing FileName:" + fileName);
return fileName;
}
else if ( fileName[1] == ':')
{
Log("JRiver: GetDownloadPath: : - Yes Semi-Colon - presume local file - Found Returing FileName:" + fileName);
return fileName;
}

// return @"http://" + HttpUtility.UrlEncode(fileName);
Log("Line 171: Plex API - Trying to sortout fanart URL: and Returning FileName: " + HttpUtility.UrlEncode(fileName));
return HttpUtility.UrlEncode(fileName);
Expand Down
4 changes: 2 additions & 2 deletions FrontView/Plugins/Remote.Jriver/Properties/AssemblyInfo.cs
Expand Up @@ -35,6 +35,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.70.0")]
[assembly: AssemblyFileVersion("1.0.70.0")]
[assembly: AssemblyVersion("1.0.75.0")]
[assembly: AssemblyFileVersion("1.0.75.0")]
[assembly: NeutralResourcesLanguageAttribute("en")]
4 changes: 2 additions & 2 deletions FrontView/Properties/AssemblyInfo.cs
Expand Up @@ -52,8 +52,8 @@
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
[assembly: AssemblyVersion("1.0.307.1")]
[assembly: AssemblyVersion("1.0.308.1")]
//[assembly: AssemblyVersion("2.0.0.101")]
//[assembly: AssemblyFileVersion("2.0.0.101")]
[assembly: NeutralResourcesLanguageAttribute("en")]
[assembly: AssemblyFileVersion("1.0.307.1")]
[assembly: AssemblyFileVersion("1.0.308.1")]

0 comments on commit 932a374

Please sign in to comment.