aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations')
-rw-r--r--Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs103
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs74
-rw-r--r--Emby.Server.Implementations/ServerApplicationPaths.cs15
3 files changed, 65 insertions, 127 deletions
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
index 701c04f9e..f26cc4f62 100644
--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
@@ -1,3 +1,4 @@
+using System;
using System.IO;
using MediaBrowser.Common.Configuration;
@@ -14,50 +15,44 @@ namespace Emby.Server.Implementations.AppBase
/// </summary>
protected BaseApplicationPaths(
string programDataPath,
- string appFolderPath,
- string logDirectoryPath = null,
- string configurationDirectoryPath = null,
- string cacheDirectoryPath = null)
+ string logDirectoryPath,
+ string configurationDirectoryPath,
+ string cacheDirectoryPath)
{
ProgramDataPath = programDataPath;
- ProgramSystemPath = appFolderPath;
LogDirectoryPath = logDirectoryPath;
ConfigurationDirectoryPath = configurationDirectoryPath;
CachePath = cacheDirectoryPath;
+
+ DataPath = Path.Combine(ProgramDataPath, "data");
}
+ /// <summary>
+ /// Gets the path to the program data folder
+ /// </summary>
+ /// <value>The program data path.</value>
public string ProgramDataPath { get; private set; }
/// <summary>
/// Gets the path to the system folder
/// </summary>
- public string ProgramSystemPath { get; private set; }
+ public string ProgramSystemPath { get; } = AppContext.BaseDirectory;
/// <summary>
- /// The _data directory
- /// </summary>
- private string _dataDirectory;
- /// <summary>
/// Gets the folder path to the data directory
/// </summary>
/// <value>The data directory.</value>
+ private string _dataPath;
public string DataPath
{
- get
- {
- if (_dataDirectory == null)
- {
- _dataDirectory = Path.Combine(ProgramDataPath, "data");
-
- Directory.CreateDirectory(_dataDirectory);
- }
-
- return _dataDirectory;
- }
+ get => _dataPath;
+ private set => _dataPath = Directory.CreateDirectory(value).FullName;
}
- private const string _virtualDataPath = "%AppDataPath%";
- public string VirtualDataPath => _virtualDataPath;
+ /// <summary>
+ /// Gets the magic strings used for virtual path manipulation.
+ /// </summary>
+ public string VirtualDataPath { get; } = "%AppDataPath%";
/// <summary>
/// Gets the image cache path.
@@ -84,54 +79,16 @@ namespace Emby.Server.Implementations.AppBase
public string TempUpdatePath => Path.Combine(ProgramDataPath, "updates");
/// <summary>
- /// The _log directory
- /// </summary>
- private string _logDirectoryPath;
-
- /// <summary>
/// Gets the path to the log directory
/// </summary>
/// <value>The log directory path.</value>
- public string LogDirectoryPath
- {
- get
- {
- if (string.IsNullOrEmpty(_logDirectoryPath))
- {
- _logDirectoryPath = Path.Combine(ProgramDataPath, "logs");
-
- Directory.CreateDirectory(_logDirectoryPath);
- }
-
- return _logDirectoryPath;
- }
- set => _logDirectoryPath = value;
- }
-
- /// <summary>
- /// The _config directory
- /// </summary>
- private string _configurationDirectoryPath;
+ public string LogDirectoryPath { get; private set; }
/// <summary>
/// Gets the path to the application configuration root directory
/// </summary>
/// <value>The configuration directory path.</value>
- public string ConfigurationDirectoryPath
- {
- get
- {
- if (string.IsNullOrEmpty(_configurationDirectoryPath))
- {
- _configurationDirectoryPath = Path.Combine(ProgramDataPath, "config");
-
- Directory.CreateDirectory(_configurationDirectoryPath);
- }
-
- return _configurationDirectoryPath;
- }
- set => _configurationDirectoryPath = value;
- }
+ public string ConfigurationDirectoryPath { get; private set; }
/// <summary>
/// Gets the path to the system configuration file
@@ -140,28 +97,10 @@ namespace Emby.Server.Implementations.AppBase
public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml");
/// <summary>
- /// The _cache directory
- /// </summary>
- private string _cachePath;
- /// <summary>
/// Gets the folder path to the cache directory
/// </summary>
/// <value>The cache directory.</value>
- public string CachePath
- {
- get
- {
- if (string.IsNullOrEmpty(_cachePath))
- {
- _cachePath = Path.Combine(ProgramDataPath, "cache");
-
- Directory.CreateDirectory(_cachePath);
- }
-
- return _cachePath;
- }
- set => _cachePath = value;
- }
+ public string CachePath { get; set; }
/// <summary>
/// Gets the folder path to the temp directory within the cache folder
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
index 9a01c42d3..d2a835b85 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
@@ -157,56 +157,56 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null;
string numberString = null;
+ string attributeValue;
+ double doubleValue;
- // Check for channel number with the format from SatIp
- // #EXTINF:0,84. VOX Schweiz
- // #EXTINF:0,84.0 - VOX Schweiz
- if (!string.IsNullOrWhiteSpace(nameInExtInf))
+ if (attributes.TryGetValue("tvg-chno", out attributeValue))
{
- var numberIndex = nameInExtInf.IndexOf(' ');
- if (numberIndex > 0)
+ if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue))
{
- var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
-
- if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out var number))
- {
- numberString = numberPart;
- }
+ numberString = attributeValue;
}
}
- if (!string.IsNullOrWhiteSpace(numberString))
- {
- numberString = numberString.Trim();
- }
-
if (!IsValidChannelNumber(numberString))
{
- if (attributes.TryGetValue("tvg-id", out string value))
+ if (attributes.TryGetValue("tvg-id", out attributeValue))
{
- if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var doubleValue))
+ if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue))
{
- numberString = value;
+ numberString = attributeValue;
+ }
+ else if (attributes.TryGetValue("channel-id", out attributeValue))
+ {
+ if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue))
+ {
+ numberString = attributeValue;
+ }
}
}
- }
- if (!string.IsNullOrWhiteSpace(numberString))
- {
- numberString = numberString.Trim();
- }
-
- if (!IsValidChannelNumber(numberString))
- {
- if (attributes.TryGetValue("channel-id", out string value))
+ if (String.IsNullOrWhiteSpace(numberString))
{
- numberString = value;
+ // Using this as a fallback now as this leads to Problems with channels like "5 USA"
+ // where 5 isnt ment to be the channel number
+ // Check for channel number with the format from SatIp
+ // #EXTINF:0,84. VOX Schweiz
+ // #EXTINF:0,84.0 - VOX Schweiz
+ if (!string.IsNullOrWhiteSpace(nameInExtInf))
+ {
+ var numberIndex = nameInExtInf.IndexOf(' ');
+ if (numberIndex > 0)
+ {
+ var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
+
+ if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out var number))
+ {
+ numberString = numberPart;
+ }
+ }
+ }
}
- }
- if (!string.IsNullOrWhiteSpace(numberString))
- {
- numberString = numberString.Trim();
}
if (!IsValidChannelNumber(numberString))
@@ -214,7 +214,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
numberString = null;
}
- if (string.IsNullOrWhiteSpace(numberString))
+ if (!string.IsNullOrWhiteSpace(numberString))
+ {
+ numberString = numberString.Trim();
+ }
+ else
{
if (string.IsNullOrWhiteSpace(mediaUrl))
{
diff --git a/Emby.Server.Implementations/ServerApplicationPaths.cs b/Emby.Server.Implementations/ServerApplicationPaths.cs
index 36975df50..05f6469ec 100644
--- a/Emby.Server.Implementations/ServerApplicationPaths.cs
+++ b/Emby.Server.Implementations/ServerApplicationPaths.cs
@@ -15,21 +15,17 @@ namespace Emby.Server.Implementations
/// </summary>
public ServerApplicationPaths(
string programDataPath,
- string appFolderPath,
- string applicationResourcesPath,
- string logDirectoryPath = null,
- string configurationDirectoryPath = null,
- string cacheDirectoryPath = null)
+ string logDirectoryPath,
+ string configurationDirectoryPath,
+ string cacheDirectoryPath)
: base(programDataPath,
- appFolderPath,
logDirectoryPath,
configurationDirectoryPath,
cacheDirectoryPath)
{
- ApplicationResourcesPath = applicationResourcesPath;
}
- public string ApplicationResourcesPath { get; private set; }
+ public string ApplicationResourcesPath { get; } = AppContext.BaseDirectory;
/// <summary>
/// Gets the path to the base root media directory
@@ -148,7 +144,6 @@ namespace Emby.Server.Implementations
set => _internalMetadataPath = value;
}
- private const string _virtualInternalMetadataPath = "%MetadataPath%";
- public string VirtualInternalMetadataPath => _virtualInternalMetadataPath;
+ public string VirtualInternalMetadataPath { get; } = "%MetadataPath%";
}
}