diff --git a/Shoko.Desktop/AppSettings.cs b/Shoko.Desktop/AppSettings.cs index db6a8ff9..53e212ca 100644 --- a/Shoko.Desktop/AppSettings.cs +++ b/Shoko.Desktop/AppSettings.cs @@ -298,6 +298,20 @@ private static bool BaseImagesPathIsDefault } } + public static string JMMServer_Protocol + { + get + { + string val = Get("ShokoServer_Protocol"); + if (!string.IsNullOrEmpty(val)) return val; + // default value + val = "http"; + Set("ShokoServer_Protocol", val); + return val; + } + set => Set("ShokoServer_Protocol", value); + } + public static string JMMServer_Address { get @@ -1764,6 +1778,7 @@ public static void DebugSettingsToLog() logger.Info($"Episodes_WatchedStatus: {Episodes_WatchedStatus}"); logger.Info($"BaseImagesPath: {BaseImagesPath}"); logger.Info($"BaseImagesPathIsDefault: {BaseImagesPathIsDefault}"); + logger.Info($"ShokoServer_Protocol: {JMMServer_Protocol}"); logger.Info($"ShokoServer_Address: {JMMServer_Address}"); logger.Info($"ShokoServer_Port: {JMMServer_Port}"); logger.Info($"ShokoServer_FilePort: {JMMServer_FilePort}"); diff --git a/Shoko.Desktop/UserControls/Settings/JMMServerSettings.xaml b/Shoko.Desktop/UserControls/Settings/JMMServerSettings.xaml index 8aaee243..4b61ea0a 100644 --- a/Shoko.Desktop/UserControls/Settings/JMMServerSettings.xaml +++ b/Shoko.Desktop/UserControls/Settings/JMMServerSettings.xaml @@ -11,6 +11,7 @@ + @@ -23,13 +24,17 @@ + + + + - + - + @@ -45,7 +50,7 @@ - + diff --git a/Shoko.Desktop/UserControls/Settings/JMMServerSettings.xaml.cs b/Shoko.Desktop/UserControls/Settings/JMMServerSettings.xaml.cs index 11fa2b07..7fde16d6 100644 --- a/Shoko.Desktop/UserControls/Settings/JMMServerSettings.xaml.cs +++ b/Shoko.Desktop/UserControls/Settings/JMMServerSettings.xaml.cs @@ -19,6 +19,7 @@ public JMMServerSettings() Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(AppSettings.Culture); + checkHttps.IsChecked = AppSettings.JMMServer_Protocol == "https"; txtServer.Text = AppSettings.JMMServer_Address; txtPort.Text = AppSettings.JMMServer_Port; //txtFilePort.Text = AppSettings.JMMServer_FilePort; @@ -33,6 +34,9 @@ void btnTest_Click(object sender, RoutedEventArgs e) { try { + AppSettings.JMMServer_Protocol = (checkHttps.IsChecked.HasValue && checkHttps.IsChecked.Value) + ? "https" + : "http"; AppSettings.JMMServer_Address = txtServer.Text.Trim(); AppSettings.JMMServer_Port = txtPort.Text.Trim(); diff --git a/Shoko.Desktop/VideoPlayers/Extensions.cs b/Shoko.Desktop/VideoPlayers/Extensions.cs index eab3c207..589b05a4 100644 --- a/Shoko.Desktop/VideoPlayers/Extensions.cs +++ b/Shoko.Desktop/VideoPlayers/Extensions.cs @@ -97,7 +97,7 @@ static Tuple> GetInfo(int vlID, string path, Media m) name = WebUtility.UrlEncode(name); string uri = - $"http://{AppSettings.JMMServer_Address}:{AppSettings.JMMServer_Port}/Stream/{vlID}/{VM_ShokoServer.Instance.CurrentUser.JMMUserID}/false/{name}"; + $"{AppSettings.JMMServer_Protocol}://{AppSettings.JMMServer_Address}:{AppSettings.JMMServer_Port}/Stream/{vlID}/{VM_ShokoServer.Instance.CurrentUser.JMMUserID}/false/{name}"; string fname = Path.GetFileNameWithoutExtension(path); var p = m?.Parts?.FirstOrDefault(); if (p?.Streams == null) return new Tuple>(uri, subs); @@ -109,7 +109,7 @@ static Tuple> GetInfo(int vlID, string path, Media m) try { - var url = $"http://{AppSettings.JMMServer_Address}:{AppSettings.JMMServer_Port}/Stream/Filename/{Base64EncodeUrl(s.File)}/{VM_ShokoServer.Instance.CurrentUser.JMMUserID}/false"; + var url = $"{AppSettings.JMMServer_Protocol}://{AppSettings.JMMServer_Address}:{AppSettings.JMMServer_Port}/Stream/Filename/{Base64EncodeUrl(s.File)}/{VM_ShokoServer.Instance.CurrentUser.JMMUserID}/false"; string subtitle = wc.DownloadString(url); try { diff --git a/Shoko.Desktop/VideoPlayers/VideoHandler.cs b/Shoko.Desktop/VideoPlayers/VideoHandler.cs index f6ca7c52..add56886 100644 --- a/Shoko.Desktop/VideoPlayers/VideoHandler.cs +++ b/Shoko.Desktop/VideoPlayers/VideoHandler.cs @@ -445,7 +445,7 @@ public string GenerateTemporaryPlayList(List vids) plsContent += @"[playlist]" + Environment.NewLine; List lines=new List(); - string url = $"http://{AppSettings.JMMServer_Address}:{AppSettings.JMMServer_Port}/Stream/%s/%s/false/%s"; + string url = $"{AppSettings.JMMServer_Protocol}://{AppSettings.JMMServer_Address}:{AppSettings.JMMServer_Port}/Stream/%s/%s/false/%s"; for (int i = 1; i <= vids.Count; i++) { diff --git a/Shoko.Desktop/ViewModel/VM_ShokoServer.cs b/Shoko.Desktop/ViewModel/VM_ShokoServer.cs index 23c70d81..4700b273 100644 --- a/Shoko.Desktop/ViewModel/VM_ShokoServer.cs +++ b/Shoko.Desktop/ViewModel/VM_ShokoServer.cs @@ -109,6 +109,8 @@ public static bool SettingsAreValid() if (string.IsNullOrEmpty(AppSettings.JMMServer_Address) || string.IsNullOrEmpty(AppSettings.JMMServer_Port)) return false; + if (!(AppSettings.JMMServer_Protocol.Equals("http") || AppSettings.JMMServer_Protocol.Equals("https"))) + return false; return true; } @@ -122,7 +124,7 @@ public void SetupImageClient() try { - _imageClient = ClientFactory.Create($"http://{AppSettings.JMMServer_Address}:{AppSettings.JMMServer_Port}/"); + _imageClient = ClientFactory.Create($"{AppSettings.JMMServer_Protocol}://{AppSettings.JMMServer_Address}:{AppSettings.JMMServer_Port}/"); } catch (Exception ex) { @@ -139,7 +141,7 @@ public void SetupPlexClient() try { - _plexClient = ClientFactory.Create($"http://{AppSettings.JMMServer_Address}:{AppSettings.JMMServer_Port}/"); + _plexClient = ClientFactory.Create($"{AppSettings.JMMServer_Protocol}://{AppSettings.JMMServer_Address}:{AppSettings.JMMServer_Port}/"); } catch (Exception ex) { @@ -223,7 +225,7 @@ public bool SetupClient() _shokoservices = ClientFactory.Create( - $"http://{AppSettings.JMMServer_Address}:{AppSettings.JMMServer_Port}/", mappings, proxy:proxy); + $"{AppSettings.JMMServer_Protocol}://{AppSettings.JMMServer_Address}:{AppSettings.JMMServer_Port}/", mappings, proxy:proxy); // try connecting to see if the server is responding Instance.ShokoServices.GetServerStatus(); ServerOnline = true; diff --git a/Shoko.Desktop/testing.config b/Shoko.Desktop/testing.config index 958f8d95..429e81f0 100644 --- a/Shoko.Desktop/testing.config +++ b/Shoko.Desktop/testing.config @@ -14,6 +14,7 @@ +