aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-11-17 02:06:35 -0500
committerGitHub <noreply@github.com>2016-11-17 02:06:35 -0500
commitd8f40438d499c7a5caa48fe7b1f05ede83a02f1a (patch)
tree29e8c660f108f9efe1d099e20d0a2b04be7bb33e
parent43ee35a19c4e5b3a1a4977fbf38bea70c700c6ca (diff)
parent5bcc419857f9445bc5964d0518c656090b2ae4ee (diff)
Merge pull request #2293 from MediaBrowser/dev
Dev
-rw-r--r--Emby.Common.Implementations/Networking/NetworkManager.cs4
-rw-r--r--Emby.Server.Core/Data/DataExtensions.cs5
-rw-r--r--Emby.Server.Core/Data/SqliteItemRepository.cs45
-rw-r--r--Emby.Server.Core/Notifications/SqliteNotificationsRepository.cs20
-rw-r--r--Emby.Server.Core/Security/AuthenticationRepository.cs22
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs5
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs10
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs5
-rw-r--r--MediaBrowser.Api/Playback/Hls/BaseHlsService.cs5
-rw-r--r--MediaBrowser.Api/Playback/Hls/VideoHlsService.cs4
-rw-r--r--MediaBrowser.Providers/TV/MissingEpisodeProvider.cs26
-rw-r--r--MediaBrowser.ServerApplication/Networking/NetworkManager.cs4
-rw-r--r--src/Emby.Server/CoreSystemEvents.cs2
13 files changed, 104 insertions, 53 deletions
diff --git a/Emby.Common.Implementations/Networking/NetworkManager.cs b/Emby.Common.Implementations/Networking/NetworkManager.cs
index e33697337..a4f8f7ced 100644
--- a/Emby.Common.Implementations/Networking/NetworkManager.cs
+++ b/Emby.Common.Implementations/Networking/NetworkManager.cs
@@ -489,7 +489,7 @@ namespace Emby.Common.Implementations.Networking
/// </summary>
/// <param name="path">The path.</param>
/// <returns>IEnumerable{NetworkShare}.</returns>
- public IEnumerable<NetworkShare> GetNetworkShares(string path)
+ public virtual IEnumerable<NetworkShare> GetNetworkShares(string path)
{
return new List<NetworkShare>();
}
@@ -498,7 +498,7 @@ namespace Emby.Common.Implementations.Networking
/// Gets available devices within the domain
/// </summary>
/// <returns>PC's in the Domain</returns>
- public IEnumerable<FileSystemEntryInfo> GetNetworkDevices()
+ public virtual IEnumerable<FileSystemEntryInfo> GetNetworkDevices()
{
return new List<FileSystemEntryInfo>();
}
diff --git a/Emby.Server.Core/Data/DataExtensions.cs b/Emby.Server.Core/Data/DataExtensions.cs
index 631c1c500..20766619e 100644
--- a/Emby.Server.Core/Data/DataExtensions.cs
+++ b/Emby.Server.Core/Data/DataExtensions.cs
@@ -25,6 +25,11 @@ namespace Emby.Server.Core.Data
return (IDataParameter)cmd.Parameters[index];
}
+ public static IDataParameter GetParameter(this IDbCommand cmd, string name)
+ {
+ return (IDataParameter)cmd.Parameters[name];
+ }
+
public static IDataParameter Add(this IDataParameterCollection paramCollection, IDbCommand cmd, string name, DbType type)
{
var param = cmd.CreateParameter();
diff --git a/Emby.Server.Core/Data/SqliteItemRepository.cs b/Emby.Server.Core/Data/SqliteItemRepository.cs
index c2328641c..91c46222b 100644
--- a/Emby.Server.Core/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Core/Data/SqliteItemRepository.cs
@@ -810,7 +810,15 @@ namespace Emby.Server.Core.Data
_saveItemCommand.GetParameter(index++).Value = item.ParentId;
}
- _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Genres.ToArray());
+ if (item.Genres.Count > 0)
+ {
+ _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Genres.ToArray());
+ }
+ else
+ {
+ _saveItemCommand.GetParameter(index++).Value = null;
+ }
+
_saveItemCommand.GetParameter(index++).Value = item.GetInheritedParentalRatingValue() ?? 0;
_saveItemCommand.GetParameter(index++).Value = LatestSchemaVersion;
@@ -852,8 +860,23 @@ namespace Emby.Server.Core.Data
}
_saveItemCommand.GetParameter(index++).Value = item.IsInMixedFolder;
- _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.LockedFields.Select(i => i.ToString()).ToArray());
- _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Studios.ToArray());
+ if (item.LockedFields.Count > 0)
+ {
+ _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.LockedFields.Select(i => i.ToString()).ToArray());
+ }
+ else
+ {
+ _saveItemCommand.GetParameter(index++).Value = null;
+ }
+
+ if (item.Studios.Count > 0)
+ {
+ _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Studios.ToArray());
+ }
+ else
+ {
+ _saveItemCommand.GetParameter(index++).Value = null;
+ }
if (item.Audio.HasValue)
{
@@ -1043,31 +1066,27 @@ namespace Emby.Server.Core.Data
_saveItemCommand.GetParameter(index++).Value = item.TotalBitrate;
_saveItemCommand.GetParameter(index++).Value = item.ExtraType;
+ string artists = null;
var hasArtists = item as IHasArtist;
if (hasArtists != null)
{
if (hasArtists.Artists.Count > 0)
{
- _saveItemCommand.GetParameter(index++).Value = string.Join("|", hasArtists.Artists.ToArray());
- }
- else
- {
- _saveItemCommand.GetParameter(index++).Value = null;
+ artists = string.Join("|", hasArtists.Artists.ToArray());
}
}
+ _saveItemCommand.GetParameter(index++).Value = artists;
+ string albumArtists = null;
var hasAlbumArtists = item as IHasAlbumArtist;
if (hasAlbumArtists != null)
{
if (hasAlbumArtists.AlbumArtists.Count > 0)
{
- _saveItemCommand.GetParameter(index++).Value = string.Join("|", hasAlbumArtists.AlbumArtists.ToArray());
- }
- else
- {
- _saveItemCommand.GetParameter(index++).Value = null;
+ albumArtists = string.Join("|", hasAlbumArtists.AlbumArtists.ToArray());
}
}
+ _saveItemCommand.GetParameter(index++).Value = albumArtists;
_saveItemCommand.GetParameter(index++).Value = item.ExternalId;
diff --git a/Emby.Server.Core/Notifications/SqliteNotificationsRepository.cs b/Emby.Server.Core/Notifications/SqliteNotificationsRepository.cs
index dee0d4cfd..cd4ac28dc 100644
--- a/Emby.Server.Core/Notifications/SqliteNotificationsRepository.cs
+++ b/Emby.Server.Core/Notifications/SqliteNotificationsRepository.cs
@@ -260,16 +260,16 @@ namespace Emby.Server.Core.Notifications
{
transaction = connection.BeginTransaction();
- replaceNotificationCommand.GetParameter(0).Value = new Guid(notification.Id);
- replaceNotificationCommand.GetParameter(1).Value = new Guid(notification.UserId);
- replaceNotificationCommand.GetParameter(2).Value = notification.Date.ToUniversalTime();
- replaceNotificationCommand.GetParameter(3).Value = notification.Name;
- replaceNotificationCommand.GetParameter(4).Value = notification.Description;
- replaceNotificationCommand.GetParameter(5).Value = notification.Url;
- replaceNotificationCommand.GetParameter(6).Value = notification.Level.ToString();
- replaceNotificationCommand.GetParameter(7).Value = notification.IsRead;
- replaceNotificationCommand.GetParameter(8).Value = string.Empty;
- replaceNotificationCommand.GetParameter(9).Value = string.Empty;
+ replaceNotificationCommand.GetParameter("@Id").Value = new Guid(notification.Id);
+ replaceNotificationCommand.GetParameter("@UserId").Value = new Guid(notification.UserId);
+ replaceNotificationCommand.GetParameter("@Date").Value = notification.Date.ToUniversalTime();
+ replaceNotificationCommand.GetParameter("@Name").Value = notification.Name;
+ replaceNotificationCommand.GetParameter("@Description").Value = notification.Description;
+ replaceNotificationCommand.GetParameter("@Url").Value = notification.Url;
+ replaceNotificationCommand.GetParameter("@Level").Value = notification.Level.ToString();
+ replaceNotificationCommand.GetParameter("@IsRead").Value = notification.IsRead;
+ replaceNotificationCommand.GetParameter("@Category").Value = string.Empty;
+ replaceNotificationCommand.GetParameter("@RelatedId").Value = string.Empty;
replaceNotificationCommand.Transaction = transaction;
diff --git a/Emby.Server.Core/Security/AuthenticationRepository.cs b/Emby.Server.Core/Security/AuthenticationRepository.cs
index eaf91c710..548585375 100644
--- a/Emby.Server.Core/Security/AuthenticationRepository.cs
+++ b/Emby.Server.Core/Security/AuthenticationRepository.cs
@@ -80,18 +80,16 @@ namespace Emby.Server.Core.Security
{
transaction = connection.BeginTransaction();
- var index = 0;
-
- saveInfoCommand.GetParameter(index++).Value = new Guid(info.Id);
- saveInfoCommand.GetParameter(index++).Value = info.AccessToken;
- saveInfoCommand.GetParameter(index++).Value = info.DeviceId;
- saveInfoCommand.GetParameter(index++).Value = info.AppName;
- saveInfoCommand.GetParameter(index++).Value = info.AppVersion;
- saveInfoCommand.GetParameter(index++).Value = info.DeviceName;
- saveInfoCommand.GetParameter(index++).Value = info.UserId;
- saveInfoCommand.GetParameter(index++).Value = info.IsActive;
- saveInfoCommand.GetParameter(index++).Value = info.DateCreated;
- saveInfoCommand.GetParameter(index++).Value = info.DateRevoked;
+ saveInfoCommand.GetParameter("@Id").Value = new Guid(info.Id);
+ saveInfoCommand.GetParameter("@AccessToken").Value = info.AccessToken;
+ saveInfoCommand.GetParameter("@DeviceId").Value = info.DeviceId;
+ saveInfoCommand.GetParameter("@AppName").Value = info.AppName;
+ saveInfoCommand.GetParameter("@AppVersion").Value = info.AppVersion;
+ saveInfoCommand.GetParameter("@DeviceName").Value = info.DeviceName;
+ saveInfoCommand.GetParameter("@UserId").Value = info.UserId;
+ saveInfoCommand.GetParameter("@IsActive").Value = info.IsActive;
+ saveInfoCommand.GetParameter("@DateCreated").Value = info.DateCreated;
+ saveInfoCommand.GetParameter("@DateRevoked").Value = info.DateRevoked;
saveInfoCommand.Transaction = transaction;
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index aaf74b5c6..81a6b8508 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -992,6 +992,11 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(string channelId, CancellationToken cancellationToken)
{
+ if (string.IsNullOrWhiteSpace(channelId))
+ {
+ throw new ArgumentNullException("channelId");
+ }
+
foreach (var hostInstance in _liveTvManager.TunerHosts)
{
try
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
index ad43a611b..5fae3f666 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
@@ -101,6 +101,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
public async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(string channelId, CancellationToken cancellationToken)
{
+ if (string.IsNullOrWhiteSpace(channelId))
+ {
+ throw new ArgumentNullException("channelId");
+ }
+
if (IsValidChannelId(channelId))
{
var hosts = GetTunerHosts();
@@ -161,6 +166,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
public async Task<LiveStream> GetChannelStream(string channelId, string streamId, CancellationToken cancellationToken)
{
+ if (string.IsNullOrWhiteSpace(channelId))
+ {
+ throw new ArgumentNullException("channelId");
+ }
+
if (!IsValidChannelId(channelId))
{
throw new FileNotFoundException();
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs
index 756c3377c..19454abbc 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs
@@ -87,6 +87,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
protected override bool IsValidChannelId(string channelId)
{
+ if (string.IsNullOrWhiteSpace(channelId))
+ {
+ throw new ArgumentNullException("channelId");
+ }
+
return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase);
}
diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
index 0c1cdf53e..3b51cbc3a 100644
--- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
@@ -254,7 +254,10 @@ namespace MediaBrowser.Api.Playback.Hls
"hls/" + Path.GetFileNameWithoutExtension(outputPath));
}
- var args = string.Format("{0} {1} {2} -map_metadata -1 -threads {3} {4} {5} -avoid_negative_ts make_zero -fflags +genpts -sc_threshold 0 {6} -hls_time {7} -start_number {8} -hls_list_size {9}{10} -y \"{11}\"",
+ // add when stream copying?
+ // -avoid_negative_ts make_zero -fflags +genpts
+
+ var args = string.Format("{0} {1} {2} -map_metadata -1 -threads {3} {4} {5} -sc_threshold 0 {6} -hls_time {7} -start_number {8} -hls_list_size {9}{10} -y \"{11}\"",
itsOffset,
inputModifier,
GetInputArgument(state),
diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
index 8a2047de4..67edd3f00 100644
--- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
@@ -89,7 +89,7 @@ namespace MediaBrowser.Api.Playback.Hls
{
args += " -bsf:v h264_mp4toannexb";
}
- args += " -flags +global_header";
+ args += " -flags -global_header";
return args;
}
@@ -112,7 +112,7 @@ namespace MediaBrowser.Api.Playback.Hls
args += GetGraphicalSubtitleParam(state, codec);
}
- args += " -flags +global_header";
+ args += " -flags -global_header";
return args;
}
diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs
index c93b6c2fd..fe56bc752 100644
--- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs
+++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs
@@ -30,7 +30,7 @@ namespace MediaBrowser.Providers.TV
private readonly IFileSystem _fileSystem;
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
- private static readonly SemaphoreSlim _resourceLock = new SemaphoreSlim(1, 1);
+ private static readonly SemaphoreSlim ResourceLock = new SemaphoreSlim(1, 1);
public static bool IsRunning = false;
private readonly IXmlReaderSettingsFactory _xmlSettings;
@@ -46,7 +46,7 @@ namespace MediaBrowser.Providers.TV
public async Task Run(List<IGrouping<string, Series>> series, bool addNewItems, CancellationToken cancellationToken)
{
- await _resourceLock.WaitAsync(cancellationToken).ConfigureAwait(false);
+ await ResourceLock.WaitAsync(cancellationToken).ConfigureAwait(false);
IsRunning = true;
foreach (var seriesGroup in series)
@@ -59,9 +59,10 @@ namespace MediaBrowser.Providers.TV
{
break;
}
- catch (IOException)
+ catch (IOException ex)
{
//_logger.Warn("Series files missing for series id {0}", seriesGroup.Key);
+ _logger.ErrorException("Error in missing episode provider for series id {0}", ex, seriesGroup.Key);
}
catch (Exception ex)
{
@@ -70,12 +71,15 @@ namespace MediaBrowser.Providers.TV
}
IsRunning = false;
- _resourceLock.Release();
+ ResourceLock.Release();
}
private async Task Run(IGrouping<string, Series> group, bool addNewItems, CancellationToken cancellationToken)
{
- var tvdbId = group.Key;
+ var seriesList = group.ToList();
+ var tvdbId = seriesList
+ .Select(i => i.GetProviderId(MetadataProviders.Tvdb))
+ .FirstOrDefault(i => !string.IsNullOrWhiteSpace(i));
// Todo: Support series by imdb id
var seriesProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
@@ -114,30 +118,30 @@ namespace MediaBrowser.Providers.TV
.Where(i => i.Item1 != -1 && i.Item2 != -1)
.ToList();
- var hasBadData = HasInvalidContent(group);
+ var hasBadData = HasInvalidContent(seriesList);
- var anySeasonsRemoved = await RemoveObsoleteOrMissingSeasons(group, episodeLookup)
+ var anySeasonsRemoved = await RemoveObsoleteOrMissingSeasons(seriesList, episodeLookup)
.ConfigureAwait(false);
- var anyEpisodesRemoved = await RemoveObsoleteOrMissingEpisodes(group, episodeLookup)
+ var anyEpisodesRemoved = await RemoveObsoleteOrMissingEpisodes(seriesList, episodeLookup)
.ConfigureAwait(false);
var hasNewEpisodes = false;
- if (addNewItems && !group.Any(i => !i.IsInternetMetadataEnabled()))
+ if (addNewItems && seriesList.All(i => i.IsInternetMetadataEnabled()))
{
var seriesConfig = _config.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, typeof(Series).Name, StringComparison.OrdinalIgnoreCase));
if (seriesConfig == null || !seriesConfig.DisabledMetadataFetchers.Contains(TvdbSeriesProvider.Current.Name, StringComparer.OrdinalIgnoreCase))
{
- hasNewEpisodes = await AddMissingEpisodes(group.ToList(), hasBadData, seriesDataPath, episodeLookup, cancellationToken)
+ hasNewEpisodes = await AddMissingEpisodes(seriesList, hasBadData, seriesDataPath, episodeLookup, cancellationToken)
.ConfigureAwait(false);
}
}
if (hasNewEpisodes || anySeasonsRemoved || anyEpisodesRemoved)
{
- foreach (var series in group)
+ foreach (var series in seriesList)
{
var directoryService = new DirectoryService(_logger, _fileSystem);
diff --git a/MediaBrowser.ServerApplication/Networking/NetworkManager.cs b/MediaBrowser.ServerApplication/Networking/NetworkManager.cs
index ed99dcc06..6d3d96e19 100644
--- a/MediaBrowser.ServerApplication/Networking/NetworkManager.cs
+++ b/MediaBrowser.ServerApplication/Networking/NetworkManager.cs
@@ -25,7 +25,7 @@ namespace MediaBrowser.ServerApplication.Networking
/// </summary>
/// <param name="path">The path.</param>
/// <returns>IEnumerable{NetworkShare}.</returns>
- public IEnumerable<NetworkShare> GetNetworkShares(string path)
+ public override IEnumerable<NetworkShare> GetNetworkShares(string path)
{
Logger.Info("Getting network shares from {0}", path);
return new ShareCollection(path).OfType<Share>().Select(ToNetworkShare);
@@ -148,7 +148,7 @@ namespace MediaBrowser.ServerApplication.Networking
/// Gets available devices within the domain
/// </summary>
/// <returns>PC's in the Domain</returns>
- public IEnumerable<FileSystemEntryInfo> GetNetworkDevices()
+ public override IEnumerable<FileSystemEntryInfo> GetNetworkDevices()
{
return GetNetworkDevicesInternal().Select(c => new FileSystemEntryInfo
{
diff --git a/src/Emby.Server/CoreSystemEvents.cs b/src/Emby.Server/CoreSystemEvents.cs
index d83071fa8..7afb94160 100644
--- a/src/Emby.Server/CoreSystemEvents.cs
+++ b/src/Emby.Server/CoreSystemEvents.cs
@@ -7,5 +7,7 @@ namespace Emby.Server
{
public event EventHandler Resume;
public event EventHandler Suspend;
+ public event EventHandler SessionLogoff;
+ public event EventHandler SystemShutdown;
}
}