From b92c31ce827cd2d807d10f46fca4477570965647 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 1 Dec 2016 00:46:32 -0500 Subject: [PATCH 1/4] update translations --- .../Session/SessionManager.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index 300b67ae2..a20fb67b2 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -820,6 +820,17 @@ namespace Emby.Server.Implementations.Session } } + if (info.Item != null) + { + var msString = info.PositionTicks.HasValue ? (info.PositionTicks.Value / 10000).ToString(CultureInfo.InvariantCulture) : "unknown"; + + _logger.Info("Playback stopped reported by app {0} {1} playing {2}. Stopped at {3} ms", + session.Client, + session.ApplicationVersion, + info.Item.Name, + msString); + } + RemoveNowPlayingItem(session); var users = GetUsers(session); @@ -874,7 +885,7 @@ namespace Emby.Server.Implementations.Session { playedToCompletion = _userDataManager.UpdatePlayState(item, data, positionTicks.Value); } - else + else { // If the client isn't able to report this, then we'll just have to make an assumption data.PlayCount++; @@ -973,7 +984,7 @@ namespace Emby.Server.Implementations.Session var subItems = await TranslateItemForPlayback(itemId, user).ConfigureAwait(false); list.AddRange(subItems); } - + items = list .Where(i => i.LocationType != LocationType.Virtual) .ToList(); From 3e9f65589907e1bf38f1c30848aa6a234bf33035 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 1 Dec 2016 12:38:13 -0500 Subject: [PATCH 2/4] update card layouts --- Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 46eb569c2..4e5b8d34f 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -1650,7 +1650,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { var image = program.GetImageInfo(ImageType.Primary, 0); - if (image != null) + if (image != null && program.IsMovie) { try { From 77a6eafe154f2b5d1005c0dccffea6e3967635f1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 1 Dec 2016 13:23:47 -0500 Subject: [PATCH 3/4] update translations --- .../Security/MBLicenseFile.cs | 64 +++++++++++++++---- .../Security/PluginSecurityManager.cs | 17 ++++- 2 files changed, 66 insertions(+), 15 deletions(-) diff --git a/Emby.Server.Implementations/Security/MBLicenseFile.cs b/Emby.Server.Implementations/Security/MBLicenseFile.cs index 76741bdf8..c791d6a52 100644 --- a/Emby.Server.Implementations/Security/MBLicenseFile.cs +++ b/Emby.Server.Implementations/Security/MBLicenseFile.cs @@ -39,7 +39,7 @@ namespace Emby.Server.Implementations.Security } } - private readonly ConcurrentDictionary _updateRecords = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _updateRecords = new ConcurrentDictionary(); private readonly object _fileLock = new object(); private string _regKey; @@ -52,7 +52,7 @@ namespace Emby.Server.Implementations.Security Load(); } - private void SetUpdateRecord(Guid key, DateTime value) + private void SetUpdateRecord(Guid key, FeatureRegInfo value) { _updateRecords.AddOrUpdate(key, value, (k, v) => value); } @@ -62,10 +62,14 @@ namespace Emby.Server.Implementations.Security return new Guid(_cryptographyProvider.ComputeMD5(Encoding.Unicode.GetBytes(featureId))); } - public void AddRegCheck(string featureId) + public void AddRegCheck(string featureId, DateTime expirationDate) { var key = GetKey(featureId); - var value = DateTime.UtcNow; + var value = new FeatureRegInfo + { + ExpirationDate = expirationDate, + LastChecked = DateTime.UtcNow + }; SetUpdateRecord(key, value); Save(); @@ -74,21 +78,26 @@ namespace Emby.Server.Implementations.Security public void RemoveRegCheck(string featureId) { var key = GetKey(featureId); - DateTime val; + FeatureRegInfo val; _updateRecords.TryRemove(key, out val); Save(); } - public DateTime LastChecked(string featureId) + public FeatureRegInfo GetRegInfo(string featureId) { var key = GetKey(featureId); - DateTime last; - _updateRecords.TryGetValue(key, out last); + FeatureRegInfo info = null; + _updateRecords.TryGetValue(key, out info); + + if (info == null) + { + return null; + } // guard agains people just putting a large number in the file - return last < DateTime.UtcNow ? last : DateTime.MinValue; + return info.LastChecked < DateTime.UtcNow ? info : null; } private void Load() @@ -105,7 +114,7 @@ namespace Emby.Server.Implementations.Security { lock (_fileLock) { - _fileSystem.WriteAllBytes(licenseFile, new byte[] {}); + _fileSystem.WriteAllBytes(licenseFile, new byte[] { }); } } catch (IOException) @@ -139,7 +148,23 @@ namespace Emby.Server.Implementations.Security Guid feat; if (Guid.TryParse(line, out feat)) { - SetUpdateRecord(feat, new DateTime(Convert.ToInt64(contents[i + 1]))); + var lineParts = contents[i + 1].Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); + + long ticks; + if (long.TryParse(lineParts[0], out ticks)) + { + var info = new FeatureRegInfo + { + LastChecked = new DateTime(ticks) + }; + + if (lineParts.Length > 1 && long.TryParse(lineParts[1], out ticks)) + { + info.ExpirationDate = new DateTime(ticks); + } + + SetUpdateRecord(feat, info); + } } } } @@ -160,7 +185,11 @@ namespace Emby.Server.Implementations.Security .ToList()) { lines.Add(pair.Key.ToString()); - lines.Add(pair.Value.Ticks.ToString(CultureInfo.InvariantCulture)); + + var dateLine = pair.Value.LastChecked.Ticks.ToString(CultureInfo.InvariantCulture) + "|" + + pair.Value.ExpirationDate.Ticks.ToString(CultureInfo.InvariantCulture); + + lines.Add(dateLine); } var licenseFile = Filename; @@ -171,4 +200,15 @@ namespace Emby.Server.Implementations.Security } } } + + internal class FeatureRegInfo + { + public DateTime ExpirationDate { get; set; } + public DateTime LastChecked { get; set; } + + public FeatureRegInfo() + { + ExpirationDate = DateTime.MinValue; + } + } } diff --git a/Emby.Server.Implementations/Security/PluginSecurityManager.cs b/Emby.Server.Implementations/Security/PluginSecurityManager.cs index 61d4f5252..2a22d048c 100644 --- a/Emby.Server.Implementations/Security/PluginSecurityManager.cs +++ b/Emby.Server.Implementations/Security/PluginSecurityManager.cs @@ -245,13 +245,24 @@ namespace Emby.Server.Implementations.Security string mb2Equivalent = null, string version = null) { - var lastChecked = LicenseFile.LastChecked(feature); + var regInfo = LicenseFile.GetRegInfo(feature); + var lastChecked = regInfo == null ? DateTime.MinValue : regInfo.LastChecked; + var expDate = regInfo == null ? DateTime.MinValue : regInfo.ExpirationDate; + + var maxCacheDays = 14; + var nextCheckDate = new [] { expDate, lastChecked.AddDays(maxCacheDays) }.Min(); + + if (nextCheckDate > DateTime.UtcNow.AddDays(maxCacheDays)) + { + nextCheckDate = DateTime.MinValue; + } //check the reg file first to alleviate strain on the MB admin server - must actually check in every 30 days tho var reg = new RegRecord { // Cache the result for up to a week - registered = lastChecked > DateTime.UtcNow.AddDays(-7) + registered = regInfo != null && nextCheckDate >= DateTime.UtcNow, + expDate = expDate }; var success = reg.registered; @@ -291,7 +302,7 @@ namespace Emby.Server.Implementations.Security if (reg.registered) { - LicenseFile.AddRegCheck(feature); + LicenseFile.AddRegCheck(feature, reg.expDate); } else { From 12ff39eeafd7bfe81b7d3dd4d3046b5640e33495 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 2 Dec 2016 03:03:38 -0500 Subject: [PATCH 4/4] update details --- Emby.Server.Implementations/Connect/ConnectManager.cs | 3 +-- Emby.Server.Implementations/Security/PluginSecurityManager.cs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Emby.Server.Implementations/Connect/ConnectManager.cs b/Emby.Server.Implementations/Connect/ConnectManager.cs index 079bfe868..b7faaa901 100644 --- a/Emby.Server.Implementations/Connect/ConnectManager.cs +++ b/Emby.Server.Implementations/Connect/ConnectManager.cs @@ -817,7 +817,6 @@ namespace Emby.Server.Implementations.Connect } } - private readonly SemaphoreSlim _connectImageSemaphore = new SemaphoreSlim(5, 5); private async Task RefreshAuthorizations(List list, bool refreshImages) { var users = _userManager.Users.ToList(); @@ -992,7 +991,7 @@ namespace Emby.Server.Implementations.Connect if (changed) { - await _providerManager.SaveImage(user, imageUrl, _connectImageSemaphore, ImageType.Primary, null, CancellationToken.None).ConfigureAwait(false); + await _providerManager.SaveImage(user, imageUrl, null, ImageType.Primary, null, CancellationToken.None).ConfigureAwait(false); await user.RefreshMetadata(new MetadataRefreshOptions(_fileSystem) { diff --git a/Emby.Server.Implementations/Security/PluginSecurityManager.cs b/Emby.Server.Implementations/Security/PluginSecurityManager.cs index 2a22d048c..f21259137 100644 --- a/Emby.Server.Implementations/Security/PluginSecurityManager.cs +++ b/Emby.Server.Implementations/Security/PluginSecurityManager.cs @@ -261,13 +261,13 @@ namespace Emby.Server.Implementations.Security var reg = new RegRecord { // Cache the result for up to a week - registered = regInfo != null && nextCheckDate >= DateTime.UtcNow, + registered = regInfo != null && nextCheckDate >= DateTime.UtcNow && expDate >= DateTime.UtcNow, expDate = expDate }; var success = reg.registered; - if (!(lastChecked > DateTime.UtcNow.AddDays(-1))) + if (!(lastChecked > DateTime.UtcNow.AddDays(-1)) || !reg.registered) { var data = new Dictionary {