aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2019-01-03 19:51:18 +0100
committerBond_009 <bond.009@outlook.com>2019-01-03 19:51:18 +0100
commitdb62648510dbe1aa6adda3c88a7560615daa5188 (patch)
tree647d7b4259eea740dcd105ca7c7c5fbd4c8f7370
parent86275bcc55cfe6cf6798d152a53f79c6f7811b52 (diff)
Remove firebase and empty resource config file
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs47
-rw-r--r--Emby.Server.Implementations/Session/FirebaseSessionController.cs131
-rw-r--r--Emby.Server.Implementations/Session/SessionManager.cs13
-rw-r--r--MediaBrowser.Common/IApplicationHost.cs2
-rw-r--r--MediaBrowser.Model/Session/ClientCapabilities.cs5
-rw-r--r--MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs84
-rw-r--r--MediaBrowser.Providers/Omdb/OmdbProvider.cs16
7 files changed, 12 insertions, 286 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index 3cc6151f1..05398984b 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -2437,53 +2437,6 @@ namespace Emby.Server.Implementations
}
}
}
-
- private Dictionary<string, string> _values;
- public string GetValue(string name)
- {
- if (_values == null)
- {
- _values = LoadValues();
- }
-
- string value;
-
- if (_values.TryGetValue(name, out value))
- {
- return value;
- }
-
- return null;
- }
-
- // TODO: @bond Remove?
- private Dictionary<string, string> LoadValues()
- {
- Dictionary<string, string> values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
-
- using (var stream = typeof(ApplicationHost).Assembly.GetManifestResourceStream(typeof(ApplicationHost).Namespace + ".values.txt"))
- {
- using (var reader = new StreamReader(stream))
- {
- while (!reader.EndOfStream)
- {
- var line = reader.ReadLine();
- if (string.IsNullOrEmpty(line))
- {
- continue;
- }
-
- var index = line.IndexOf('=');
- if (index != -1)
- {
- values[line.Substring(0, index)] = line.Substring(index + 1);
- }
- }
- }
- }
-
- return values;
- }
}
internal class CertificateInfo
diff --git a/Emby.Server.Implementations/Session/FirebaseSessionController.cs b/Emby.Server.Implementations/Session/FirebaseSessionController.cs
deleted file mode 100644
index cfe513305..000000000
--- a/Emby.Server.Implementations/Session/FirebaseSessionController.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-using MediaBrowser.Controller.Session;
-using MediaBrowser.Model.Net;
-using MediaBrowser.Common.Net;
-using MediaBrowser.Model.Serialization;
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Text;
-using MediaBrowser.Common;
-
-namespace Emby.Server.Implementations.Session
-{
- public class FirebaseSessionController : ISessionController
- {
- private readonly IHttpClient _httpClient;
- private readonly IJsonSerializer _json;
- private readonly ISessionManager _sessionManager;
-
- public SessionInfo Session { get; private set; }
-
- private readonly string _token;
-
- private IApplicationHost _appHost;
- private string _senderId;
- private string _applicationId;
-
- public FirebaseSessionController(IHttpClient httpClient,
- IApplicationHost appHost,
- IJsonSerializer json,
- SessionInfo session,
- string token, ISessionManager sessionManager)
- {
- _httpClient = httpClient;
- _json = json;
- _appHost = appHost;
- Session = session;
- _token = token;
- _sessionManager = sessionManager;
-
- _applicationId = _appHost.GetValue("firebase_applicationid");
- _senderId = _appHost.GetValue("firebase_senderid");
- }
-
- public static bool IsSupported(IApplicationHost appHost)
- {
- return !string.IsNullOrEmpty(appHost.GetValue("firebase_applicationid")) && !string.IsNullOrEmpty(appHost.GetValue("firebase_senderid"));
- }
-
- public bool IsSessionActive
- {
- get
- {
- return (DateTime.UtcNow - Session.LastActivityDate).TotalDays <= 3;
- }
- }
-
- public bool SupportsMediaControl
- {
- get { return true; }
- }
-
- public async Task SendMessage<T>(string name, string messageId, T data, ISessionController[] allControllers, CancellationToken cancellationToken)
- {
- if (!IsSessionActive)
- {
- return;
- }
-
- if (string.IsNullOrEmpty(_senderId) || string.IsNullOrEmpty(_applicationId))
- {
- return;
- }
-
- foreach (var controller in allControllers)
- {
- // Don't send if there's an active web socket connection
- if ((controller is WebSocketController) && controller.IsSessionActive)
- {
- return;
- }
- }
-
- var msg = new WebSocketMessage<T>
- {
- Data = data,
- MessageType = name,
- MessageId = messageId,
- ServerId = _appHost.SystemId
- };
-
- var req = new FirebaseBody<T>
- {
- to = _token,
- data = msg
- };
-
- var byteArray = Encoding.UTF8.GetBytes(_json.SerializeToString(req));
-
- var enableLogging = false;
-
-#if DEBUG
- enableLogging = true;
-#endif
-
- var options = new HttpRequestOptions
- {
- Url = "https://fcm.googleapis.com/fcm/send",
- RequestContentType = "application/json",
- RequestContentBytes = byteArray,
- CancellationToken = cancellationToken,
- LogRequest = enableLogging,
- LogResponse = enableLogging,
- LogErrors = enableLogging
- };
-
- options.RequestHeaders["Authorization"] = string.Format("key={0}", _applicationId);
- options.RequestHeaders["Sender"] = string.Format("id={0}", _senderId);
-
- using (var response = await _httpClient.Post(options).ConfigureAwait(false))
- {
-
- }
- }
- }
-
- internal class FirebaseBody<T>
- {
- public string to { get; set; }
- public WebSocketMessage<T> data { get; set; }
- }
-}
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs
index 2b2b3c677..9911cd0c6 100644
--- a/Emby.Server.Implementations/Session/SessionManager.cs
+++ b/Emby.Server.Implementations/Session/SessionManager.cs
@@ -1577,14 +1577,6 @@ namespace Emby.Server.Implementations.Session
{
session.Capabilities = capabilities;
- if (!string.IsNullOrEmpty(capabilities.PushToken))
- {
- if (string.Equals(capabilities.PushTokenType, "firebase", StringComparison.OrdinalIgnoreCase) && FirebaseSessionController.IsSupported(_appHost))
- {
- EnsureFirebaseController(session, capabilities.PushToken);
- }
- }
-
if (saveCapabilities)
{
EventHelper.FireEventIfNotNull(CapabilitiesChanged, this, new SessionEventArgs
@@ -1604,11 +1596,6 @@ namespace Emby.Server.Implementations.Session
}
}
- private void EnsureFirebaseController(SessionInfo session, string token)
- {
- session.EnsureController<FirebaseSessionController>(s => new FirebaseSessionController(_httpClient, _appHost, _jsonSerializer, s, token, this));
- }
-
private ClientCapabilities GetSavedCapabilities(string deviceId)
{
return _deviceManager.GetCapabilities(deviceId);
diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs
index 39d69ea15..c4f760b15 100644
--- a/MediaBrowser.Common/IApplicationHost.cs
+++ b/MediaBrowser.Common/IApplicationHost.cs
@@ -135,7 +135,5 @@ namespace MediaBrowser.Common
object CreateInstance(Type type);
PackageVersionClass SystemUpdateLevel { get; }
-
- string GetValue(string name);
}
}
diff --git a/MediaBrowser.Model/Session/ClientCapabilities.cs b/MediaBrowser.Model/Session/ClientCapabilities.cs
index 0a780b910..6860b29f9 100644
--- a/MediaBrowser.Model/Session/ClientCapabilities.cs
+++ b/MediaBrowser.Model/Session/ClientCapabilities.cs
@@ -1,5 +1,4 @@
using MediaBrowser.Model.Dlna;
-using System;
namespace MediaBrowser.Model.Session
{
@@ -12,8 +11,6 @@ namespace MediaBrowser.Model.Session
public bool SupportsMediaControl { get; set; }
public bool SupportsContentUploading { get; set; }
public string MessageCallbackUrl { get; set; }
- public string PushToken { get; set; }
- public string PushTokenType { get; set; }
public bool SupportsPersistentIdentifier { get; set; }
public bool SupportsSync { get; set; }
@@ -30,4 +27,4 @@ namespace MediaBrowser.Model.Session
SupportsPersistentIdentifier = true;
}
}
-} \ No newline at end of file
+}
diff --git a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs
index 0dbc43313..2c94d6a07 100644
--- a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs
+++ b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs
@@ -720,82 +720,6 @@ namespace MediaBrowser.Providers.Music
return null;
}
- private long _lastMbzUrlQueryTicks = 0;
- private List<MbzUrl> _mbzUrls = null;
- private MbzUrl _chosenUrl;
-
- private async Task<MbzUrl> GetMbzUrl(bool forceMusicBrainzProper = false)
- {
- if (_chosenUrl == null || _mbzUrls == null || (DateTime.UtcNow.Ticks - _lastMbzUrlQueryTicks) > TimeSpan.FromHours(12).Ticks)
- {
- var urls = await RefreshMzbUrls(forceMusicBrainzProper).ConfigureAwait(false);
-
- if (urls.Count > 1)
- {
- _chosenUrl = urls[new Random().Next(0, urls.Count)];
- }
- else
- {
- _chosenUrl = urls[0];
- }
- }
-
- return _chosenUrl;
- }
-
- private async Task<List<MbzUrl>> RefreshMzbUrls(bool forceMusicBrainzProper = false)
- {
- List<MbzUrl> list = null;
-
- if (!forceMusicBrainzProper)
- {
- var musicbrainzadminurl = _appHost.GetValue("musicbrainzadminurl");
-
- if (!string.IsNullOrEmpty(musicbrainzadminurl))
- {
- try
- {
- var options = new HttpRequestOptions
- {
- Url = musicbrainzadminurl,
- UserAgent = _appHost.Name + "/" + _appHost.ApplicationVersion
- };
-
- using (var response = await _httpClient.SendAsync(options, "GET").ConfigureAwait(false))
- {
- using (var stream = response.Content)
- {
- var results = await _json.DeserializeFromStreamAsync<List<MbzUrl>>(stream).ConfigureAwait(false);
-
- list = results;
- }
- }
- _lastMbzUrlQueryTicks = DateTime.UtcNow.Ticks;
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error getting music brainz info");
- }
- }
- }
-
- if (list == null)
- {
- list = new List<MbzUrl>
- {
- new MbzUrl
- {
- url = MusicBrainzBaseUrl,
- throttleMs = 1000
- }
- };
- }
-
- _mbzUrls = list.ToList();
-
- return list;
- }
-
internal Task<HttpResponseInfo> GetMusicBrainzResponse(string url, bool isSearch, CancellationToken cancellationToken)
{
return GetMusicBrainzResponse(url, isSearch, false, cancellationToken);
@@ -806,7 +730,7 @@ namespace MediaBrowser.Providers.Music
/// </summary>
internal async Task<HttpResponseInfo> GetMusicBrainzResponse(string url, bool isSearch, bool forceMusicBrainzProper, CancellationToken cancellationToken)
{
- var urlInfo = await GetMbzUrl(forceMusicBrainzProper).ConfigureAwait(false);
+ var urlInfo = new MbzUrl(MusicBrainzBaseUrl, 1000);
var throttleMs = urlInfo.throttleMs;
if (throttleMs > 0)
@@ -841,6 +765,12 @@ namespace MediaBrowser.Providers.Music
internal class MbzUrl
{
+ internal MbzUrl(string url, int throttleMs)
+ {
+ this.url = url;
+ this.throttleMs = throttleMs;
+ }
+
public string url { get; set; }
public int throttleMs { get; set; }
}
diff --git a/MediaBrowser.Providers/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Omdb/OmdbProvider.cs
index 5c4eb62a8..bb4624b5c 100644
--- a/MediaBrowser.Providers/Omdb/OmdbProvider.cs
+++ b/MediaBrowser.Providers/Omdb/OmdbProvider.cs
@@ -270,21 +270,13 @@ namespace MediaBrowser.Providers.Omdb
public static string GetOmdbUrl(string query, IApplicationHost appHost, CancellationToken cancellationToken)
{
- var baseUrl = appHost.GetValue("omdb_baseurl");
+ const string url = "https://www.omdbapi.com?apikey=fe53f97e";
- if (string.IsNullOrEmpty(baseUrl))
+ if (string.IsNullOrWhiteSpace(query))
{
- baseUrl = "https://www.omdbapi.com";
+ return url;
}
-
- var url = baseUrl + "?apikey=fe53f97e";
-
- if (!string.IsNullOrWhiteSpace(query))
- {
- url += "&" + query;
- }
-
- return url;
+ return url + "&" + query;
}
private async Task<string> EnsureItemInfo(string imdbId, CancellationToken cancellationToken)