Merge pull request #2112 from MediaBrowser/beta

Beta
This commit is contained in:
Luke 2016-08-27 15:53:08 -04:00 committed by GitHub
commit 6c156ce841
55 changed files with 1360 additions and 303 deletions

View File

@ -304,7 +304,7 @@ namespace MediaBrowser.Api
item.EndDate = request.EndDate.HasValue ? NormalizeDateTime(request.EndDate.Value) : (DateTime?)null;
item.PremiereDate = request.PremiereDate.HasValue ? NormalizeDateTime(request.PremiereDate.Value) : (DateTime?)null;
item.ProductionYear = request.ProductionYear;
item.OfficialRating = request.OfficialRating;
item.OfficialRating = string.IsNullOrWhiteSpace(request.OfficialRating) ? null : request.OfficialRating;
item.CustomRating = request.CustomRating;
SetProductionLocations(item, request);

View File

@ -989,8 +989,6 @@ namespace MediaBrowser.Api.Playback
}
}
arg += string.Format(" -ss {0}", MediaEncoder.GetTimeParameter(TimeSpan.FromSeconds(1).Ticks));
return arg.Trim();
}

View File

@ -781,6 +781,9 @@ namespace MediaBrowser.Controller.Entities
[IgnoreDataMember]
public string OfficialRating { get; set; }
[IgnoreDataMember]
public int InheritedParentalRatingValue { get; set; }
/// <summary>
/// Gets or sets the critic rating.
/// </summary>

View File

@ -59,5 +59,8 @@ namespace MediaBrowser.Controller.Entities
string GetPresentationUniqueKey();
string CreatePresentationUniqueKey();
bool StopRefreshIfLocalMetadataFound { get; }
int? GetInheritedParentalRatingValue();
int InheritedParentalRatingValue { get; set; }
}
}

View File

@ -331,12 +331,11 @@ namespace MediaBrowser.Controller.LiveTv
/// <param name="user">The user.</param>
/// <returns>Task.</returns>
Task AddInfoToProgramDto(List<Tuple<BaseItem,BaseItemDto>> programs, List<ItemFields> fields, User user = null);
/// <summary>
/// Saves the tuner host.
/// </summary>
/// <param name="info">The information.</param>
/// <returns>Task.</returns>
Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info);
Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true);
/// <summary>
/// Saves the listing provider.
/// </summary>

View File

@ -206,7 +206,6 @@ namespace MediaBrowser.Dlna
throw new ArgumentNullException("headers");
}
//_logger.Debug("GetProfile. Headers: " + _jsonSerializer.SerializeToString(headers));
// Convert to case insensitive
headers = new Dictionary<string, string>(headers, StringComparer.OrdinalIgnoreCase);
@ -218,16 +217,12 @@ namespace MediaBrowser.Dlna
}
else
{
string userAgent = null;
headers.TryGetValue("User-Agent", out userAgent);
var msg = "No matching device profile via headers found. The default will be used. ";
if (!string.IsNullOrEmpty(userAgent))
var msg = new StringBuilder();
foreach (var header in headers)
{
msg += "User-agent: " + userAgent + ". ";
msg.AppendLine(header.Key + ": " + header.Value);
}
_logger.Debug(msg);
_logger.LogMultiline("No matching device profile found. The default will need to be used.", LogSeverity.Info, msg);
}
return profile;
@ -566,7 +561,10 @@ namespace MediaBrowser.Dlna
new SonyBravia2012Profile(),
new SonyBravia2013Profile(),
new SonyBravia2014Profile(),
new SonyBlurayPlayer2013Profile(),
new SonyBlurayPlayer2013(),
new SonyBlurayPlayer2014(),
new SonyBlurayPlayer2015(),
new SonyBlurayPlayer2016(),
new SonyBlurayPlayerProfile(),
new PanasonicVieraProfile(),
new WdtvLiveProfile(),

View File

@ -94,6 +94,9 @@
<Compile Include="Profiles\DishHopperJoeyProfile.cs" />
<Compile Include="Profiles\KodiProfile.cs" />
<Compile Include="Profiles\PopcornHourProfile.cs" />
<Compile Include="Profiles\SonyBlurayPlayer2016.cs" />
<Compile Include="Profiles\SonyBlurayPlayer2015.cs" />
<Compile Include="Profiles\SonyBlurayPlayer2014.cs" />
<Compile Include="Profiles\SonyBravia2014Profile.cs" />
<Compile Include="Profiles\SonyPs4Profile.cs" />
<Compile Include="Profiles\VlcProfile.cs" />
@ -137,7 +140,7 @@
<Compile Include="Profiles\LinksysDMA2100Profile.cs" />
<Compile Include="Profiles\PanasonicVieraProfile.cs" />
<Compile Include="Profiles\SamsungSmartTvProfile.cs" />
<Compile Include="Profiles\SonyBlurayPlayer2013Profile.cs" />
<Compile Include="Profiles\SonyBlurayPlayer2013.cs" />
<Compile Include="Profiles\SonyBlurayPlayerProfile.cs" />
<Compile Include="Profiles\SonyBravia2010Profile.cs" />
<Compile Include="Profiles\SonyBravia2011Profile.cs" />
@ -244,6 +247,11 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Profiles\Xml\Sony Blu-ray Player 2014.xml" />
<EmbeddedResource Include="Profiles\Xml\Sony Blu-ray Player 2015.xml" />
<EmbeddedResource Include="Profiles\Xml\Sony Blu-ray Player 2016.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -221,7 +221,7 @@ namespace MediaBrowser.Dlna.PlayTo
{
await _sessionManager.OnPlaybackStopped(new PlaybackStopInfo
{
ItemId = mediaInfo.Id,
ItemId = streamInfo.ItemId,
SessionId = _session.Id,
PositionTicks = positionTicks,
MediaSourceId = streamInfo.MediaSourceId

View File

@ -77,6 +77,15 @@ namespace MediaBrowser.Dlna.Profiles
}
};
SubtitleProfiles = new[]
{
new SubtitleProfile
{
Format = "srt",
Method = SubtitleDeliveryMethod.Embed
}
};
ResponseProfiles = new[]
{
new ResponseProfile

View File

@ -192,6 +192,11 @@ namespace MediaBrowser.Dlna.Profiles
SubtitleProfiles = new[]
{
new SubtitleProfile
{
Format = "srt",
Method = SubtitleDeliveryMethod.Embed
},
new SubtitleProfile
{
Format = "srt",

View File

@ -188,6 +188,11 @@ namespace MediaBrowser.Dlna.Profiles
SubtitleProfiles = new[]
{
new SubtitleProfile
{
Format = "srt",
Method = SubtitleDeliveryMethod.Embed
},
new SubtitleProfile
{
Format = "srt",

View File

@ -340,6 +340,11 @@ namespace MediaBrowser.Dlna.Profiles
SubtitleProfiles = new[]
{
new SubtitleProfile
{
Format = "srt",
Method = SubtitleDeliveryMethod.Embed
},
new SubtitleProfile
{
Format = "srt",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,17 +4,37 @@ using System.Xml.Serialization;
namespace MediaBrowser.Dlna.Profiles
{
[XmlRoot("Profile")]
public class SonyBlurayPlayer2013Profile : DefaultProfile
public class SonyBlurayPlayer2015 : DefaultProfile
{
public SonyBlurayPlayer2013Profile()
public SonyBlurayPlayer2015()
{
Name = "Sony Blu-ray Player 2013";
Name = "Sony Blu-ray Player 2015";
Identification = new DeviceIdentification
{
FriendlyName = @"Blu-ray Disc Player",
Manufacturer = "Sony",
ModelNumber = "BDP-2013"
ModelNumber = "BDP-2015",
Headers = new[]
{
new HttpHeaderInfo
{
Name = "X-AV-Physical-Unit-Info",
Value = "BDP-S1500",
Match = HeaderMatchType.Substring
},
new HttpHeaderInfo
{
Name = "X-AV-Physical-Unit-Info",
Value = "BDP-S3500",
Match = HeaderMatchType.Substring
},
new HttpHeaderInfo
{
Name = "X-AV-Physical-Unit-Info",
Value = "BDP-S6500",
Match = HeaderMatchType.Substring
}
}
};
AddXmlRootAttribute("xmlns:av", "urn:schemas-sony-com:av");
@ -36,9 +56,9 @@ namespace MediaBrowser.Dlna.Profiles
new TranscodingProfile
{
Container = "ts",
Container = "mkv",
VideoCodec = "h264",
AudioCodec = "ac3",
AudioCodec = "ac3,aac,mp3",
Type = DlnaProfileType.Video
},
@ -53,21 +73,21 @@ namespace MediaBrowser.Dlna.Profiles
{
new DirectPlayProfile
{
Container = "ts",
Container = "ts,mpegts",
VideoCodec = "mpeg1video,mpeg2video,h264",
AudioCodec = "ac3,aac,mp3,pcm",
Type = DlnaProfileType.Video
},
new DirectPlayProfile
{
Container = "mpeg",
Container = "mpeg,mpg",
VideoCodec = "mpeg1video,mpeg2video",
AudioCodec = "ac3,mp3,mp2,pcm",
Type = DlnaProfileType.Video
},
new DirectPlayProfile
{
Container = "mp4",
Container = "mp4,m4v",
VideoCodec = "mpeg4,h264",
AudioCodec = "ac3,aac,pcm,mp3",
Type = DlnaProfileType.Video
@ -88,25 +108,24 @@ namespace MediaBrowser.Dlna.Profiles
},
new DirectPlayProfile
{
Container = "mp3",
AudioCodec = "mp3",
Container = "m2ts,mts",
VideoCodec = "h264,mpeg4,vc1",
AudioCodec = "aac,mp3,ac3,dca,dts",
Type = DlnaProfileType.Video
},
new DirectPlayProfile
{
Container = "wmv,asf",
Type = DlnaProfileType.Video
},
new DirectPlayProfile
{
Container = "mp3,m4a,wma,wav",
Type = DlnaProfileType.Audio
},
new DirectPlayProfile
{
Container = "mp4",
AudioCodec = "aac",
Type = DlnaProfileType.Audio
},
new DirectPlayProfile
{
Container = "asf",
AudioCodec = "wmav2,wmapro,wmavoice",
Type = DlnaProfileType.Audio
},
new DirectPlayProfile
{
Container = "jpeg",
Container = "jpeg,png,gif",
Type = DlnaProfileType.Photo
}
};
@ -182,6 +201,15 @@ namespace MediaBrowser.Dlna.Profiles
}
};
SubtitleProfiles = new[]
{
new SubtitleProfile
{
Format = "srt",
Method = SubtitleDeliveryMethod.Embed
}
};
ResponseProfiles = new ResponseProfile[] { };
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,7 @@
<MaxStreamingBitrate>20000000</MaxStreamingBitrate>
<MaxStaticBitrate>20000000</MaxStaticBitrate>
<MusicStreamingTranscodingBitrate>192000</MusicStreamingTranscodingBitrate>
<MusicSyncBitrate>192000</MusicSyncBitrate>
<MaxStaticMusicBitrate xsi:nil="true" />
<XDlnaDoc>DMS-1.50</XDlnaDoc>
<ProtocolInfo>http-get:*:video/mp2t:*,http-get:*:video/MP1S:*,http-get:*:video/mpeg2:*,http-get:*:video/mp4:*,http-get:*:video/x-matroska:*,http-get:*:audio/mpeg:*,http-get:*:audio/mpeg3:*,http-get:*:audio/mp3:*,http-get:*:audio/mp4:*,http-get:*:audio/mp4a-latm:*,http-get:*:image/jpeg:*</ProtocolInfo>
<TimelineOffsetSeconds>0</TimelineOffsetSeconds>
@ -43,9 +43,9 @@
<DirectPlayProfile container="jpeg" type="Photo" />
</DirectPlayProfiles>
<TranscodingProfiles>
<TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" forceLiveStream="false" enableSubtitlesInManifest="false" />
<TranscodingProfile container="mp4" type="Video" videoCodec="h264" audioCodec="aac" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" forceLiveStream="false" enableSubtitlesInManifest="false" />
<TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" forceLiveStream="false" enableSubtitlesInManifest="false" />
<TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
<TranscodingProfile container="mp4" type="Video" videoCodec="h264" audioCodec="aac" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
<TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
</TranscodingProfiles>
<ContainerProfiles />
<CodecProfiles>
@ -86,5 +86,7 @@
<Conditions />
</ResponseProfile>
</ResponseProfiles>
<SubtitleProfiles />
<SubtitleProfiles>
<SubtitleProfile format="srt" method="Embed" />
</SubtitleProfiles>
</Profile>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,7 @@
<MaxStreamingBitrate>20000000</MaxStreamingBitrate>
<MaxStaticBitrate>20000000</MaxStaticBitrate>
<MusicStreamingTranscodingBitrate>192000</MusicStreamingTranscodingBitrate>
<MusicSyncBitrate>192000</MusicSyncBitrate>
<MaxStaticMusicBitrate xsi:nil="true" />
<XDlnaDoc>DMS-1.50</XDlnaDoc>
<SonyAggregationFlags>10</SonyAggregationFlags>
<ProtocolInfo>http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=81500000000000000000000000000000,http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_SM;DLNA.ORG_OP=00;DLNA.ORG_FLAGS=00D00000000000000000000000000000,http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_PAL;DLNA.ORG_OP=11;DLNA.ORG_FLAGS=81500000000000000000000000000000</ProtocolInfo>
@ -45,9 +45,9 @@
<DirectPlayProfile container="mp3" audioCodec="mp3" type="Audio" />
</DirectPlayProfiles>
<TranscodingProfiles>
<TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" forceLiveStream="false" enableSubtitlesInManifest="false" />
<TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="ac3" estimateContentLength="false" enableMpegtsM2TsMode="true" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" forceLiveStream="false" enableSubtitlesInManifest="false" />
<TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" forceLiveStream="false" enableSubtitlesInManifest="false" />
<TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
<TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="ac3" estimateContentLength="false" enableMpegtsM2TsMode="true" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
<TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
</TranscodingProfiles>
<ContainerProfiles>
<ContainerProfile type="Photo">
@ -127,5 +127,7 @@
<Conditions />
</ResponseProfile>
</ResponseProfiles>
<SubtitleProfiles />
<SubtitleProfiles>
<SubtitleProfile format="srt" method="Embed" />
</SubtitleProfiles>
</Profile>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -602,7 +602,7 @@ namespace MediaBrowser.Model.Dlna
private int GetAudioBitrate(string subProtocol, int? maxTotalBitrate, int? targetAudioChannels, string targetAudioCodec, MediaStream audioStream)
{
var defaultBitrate = audioStream.BitRate ?? 192000;
var defaultBitrate = audioStream == null ? 192000 : audioStream.BitRate ?? 192000;
// Reduce the bitrate if we're downmixing
if (targetAudioChannels.HasValue && audioStream != null && audioStream.Channels.HasValue && targetAudioChannels.Value < audioStream.Channels.Value)
{

View File

@ -294,6 +294,13 @@ namespace MediaBrowser.Providers.Manager
updateType |= ItemUpdateType.MetadataImport;
}
var inheritedParentalRatingValue = item.GetInheritedParentalRatingValue() ?? 0;
if (inheritedParentalRatingValue != item.InheritedParentalRatingValue)
{
item.InheritedParentalRatingValue = inheritedParentalRatingValue;
updateType |= ItemUpdateType.MetadataImport;
}
return updateType;
}

View File

@ -283,7 +283,7 @@ namespace MediaBrowser.Server.Implementations.Library
ExcludeItemTypes = excludeItemTypes,
ExcludeLocationTypes = new[] { LocationType.Virtual },
Limit = limit * 5,
ExcludeSourceTypes = parentIds.Length == 0 ? new[] { SourceType.Channel, SourceType.LiveTV } : new SourceType[] { },
SourceTypes = parentIds.Length == 0 ? new[] { SourceType.Library } : new SourceType[] { },
IsPlayed = request.IsPlayed
}, parentIds);

View File

@ -2475,7 +2475,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return await _libraryManager.GetNamedView(name, CollectionType.LiveTv, name, cancellationToken).ConfigureAwait(false);
}
public async Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info)
public async Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true)
{
info = (TunerHostInfo)_jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info), typeof(TunerHostInfo));
@ -2508,7 +2508,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
_config.SaveConfiguration("livetv", config);
_taskManager.CancelIfRunningAndQueue<RefreshChannelsScheduledTask>();
if (dataSourceChanged)
{
_taskManager.CancelIfRunningAndQueue<RefreshChannelsScheduledTask>();
}
return info;
}

View File

@ -111,7 +111,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
M3UUrl = info.M3UUrl,
IsEnabled = true
}).ConfigureAwait(false);
}, true).ConfigureAwait(false);
}
else
{
@ -120,7 +120,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
existing.M3UUrl = info.M3UUrl;
existing.FriendlyName = info.FriendlyName;
existing.Tuners = info.Tuners;
await _liveTvManager.SaveTunerHost(existing).ConfigureAwait(false);
await _liveTvManager.SaveTunerHost(existing, false).ConfigureAwait(false);
}
}
catch (OperationCanceledException)

View File

@ -92,7 +92,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
private IDbCommand _deleteImagesCommand;
private IDbCommand _saveImagesCommand;
private IDbCommand _updateInheritedRatingCommand;
private IDbCommand _updateInheritedTagsCommand;
public const int LatestSchemaVersion = 109;
@ -412,7 +411,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"SeasonId",
"SeriesId",
"SeriesSortName",
"PresentationUniqueKey"
"PresentationUniqueKey",
"InheritedParentalRatingValue"
};
private readonly string[] _mediaStreamSaveColumns =
@ -611,11 +611,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveStreamCommand.Parameters.Add(_saveStreamCommand, "@" + col);
}
_updateInheritedRatingCommand = _connection.CreateCommand();
_updateInheritedRatingCommand.CommandText = "Update TypedBaseItems set InheritedParentalRatingValue=@InheritedParentalRatingValue where Guid=@Guid";
_updateInheritedRatingCommand.Parameters.Add(_updateInheritedRatingCommand, "@Guid");
_updateInheritedRatingCommand.Parameters.Add(_updateInheritedRatingCommand, "@InheritedParentalRatingValue");
_updateInheritedTagsCommand = _connection.CreateCommand();
_updateInheritedTagsCommand.CommandText = "Update TypedBaseItems set InheritedTags=@InheritedTags where Guid=@Guid";
_updateInheritedTagsCommand.Parameters.Add(_updateInheritedTagsCommand, "@Guid");
@ -942,7 +937,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = item.Album;
_saveItemCommand.GetParameter(index++).Value = item.IsVirtualItem || (!item.IsFolder && item.LocationType == LocationType.Virtual);
_saveItemCommand.GetParameter(index++).Value = item.IsVirtualItem;
var hasSeries = item as IHasSeries;
if (hasSeries != null)
@ -1458,6 +1453,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
index++;
if (!reader.IsDBNull(index))
{
item.InheritedParentalRatingValue = reader.GetInt32(index);
}
index++;
return item;
}
@ -3402,7 +3403,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
public async Task UpdateInheritedValues(CancellationToken cancellationToken)
{
await UpdateInheritedParentalRating(cancellationToken).ConfigureAwait(false);
await UpdateInheritedTags(cancellationToken).ConfigureAwait(false);
}
@ -3482,82 +3482,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
}
private async Task UpdateInheritedParentalRating(CancellationToken cancellationToken)
{
var newValues = new List<Tuple<Guid, int>>();
using (var cmd = _connection.CreateCommand())
{
cmd.CommandText = "select Guid,InheritedParentalRatingValue,(select Max(InheritedParentalRatingValue, (select COALESCE(MAX(InheritedParentalRatingValue),0) from TypedBaseItems where guid in (Select AncestorId from AncestorIds where ItemId=Outer.guid)))) as NewInheritedParentalRatingValue from typedbaseitems as Outer where InheritedParentalRatingValue <> NewInheritedParentalRatingValue";
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
{
while (reader.Read())
{
var id = reader.GetGuid(0);
var newValue = reader.GetInt32(2);
newValues.Add(new Tuple<Guid, int>(id, newValue));
}
}
}
Logger.Debug("UpdateInheritedParentalRatings - {0} rows", newValues.Count);
if (newValues.Count == 0)
{
return;
}
await WriteLock.WaitAsync(cancellationToken).ConfigureAwait(false);
IDbTransaction transaction = null;
try
{
transaction = _connection.BeginTransaction();
foreach (var item in newValues)
{
_updateInheritedRatingCommand.GetParameter(0).Value = item.Item1;
_updateInheritedRatingCommand.GetParameter(1).Value = item.Item2;
_updateInheritedRatingCommand.Transaction = transaction;
_updateInheritedRatingCommand.ExecuteNonQuery();
}
transaction.Commit();
}
catch (OperationCanceledException)
{
if (transaction != null)
{
transaction.Rollback();
}
throw;
}
catch (Exception e)
{
Logger.ErrorException("Error running query:", e);
if (transaction != null)
{
transaction.Rollback();
}
throw;
}
finally
{
if (transaction != null)
{
transaction.Dispose();
}
WriteLock.Release();
}
}
private static Dictionary<string, string[]> GetTypeMapDictionary()
{
var dict = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase);

View File

@ -47,15 +47,18 @@ namespace MediaBrowser.Server.Implementations.Sync
string[] queries = {
"create table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Profile TEXT, Quality TEXT, Bitrate INT, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, Category TEXT, ParentId TEXT, UnwatchedOnly BIT, ItemLimit INT, SyncNewContent BIT, DateCreated DateTime, DateLastModified DateTime, ItemCount int)",
"create index if not exists idx_SyncJobs on SyncJobs(Id)",
"create index if not exists idx_SyncJobs1 on SyncJobs(TargetId)",
"create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, ItemName TEXT, MediaSourceId TEXT, JobId TEXT, TemporaryPath TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT, AdditionalFiles TEXT, MediaSource TEXT, IsMarkedForRemoval BIT, JobItemIndex INT, ItemDateModifiedTicks BIGINT)",
"create index if not exists idx_SyncJobItems1 on SyncJobItems(Id)",
"drop index if exists idx_SyncJobItems2",
"drop index if exists idx_SyncJobItems3",
"drop index if exists idx_SyncJobs1",
"drop index if exists idx_SyncJobs",
"drop index if exists idx_SyncJobItems1",
"create index if not exists idx_SyncJobItems4 on SyncJobItems(TargetId,ItemId,Status,Progress,DateCreated)",
"create index if not exists idx_SyncJobItems5 on SyncJobItems(TargetId,Status,ItemId,Progress)",
"create index if not exists idx_SyncJobs2 on SyncJobs(TargetId,Status,ItemIds,Progress)",
"pragma shrink_memory"
};
@ -615,6 +618,8 @@ namespace MediaBrowser.Server.Implementations.Sync
{
var result = new Dictionary<string, SyncedItemProgress>();
var now = DateTime.UtcNow;
using (var connection = CreateConnection(true).Result)
{
using (var cmd = connection.CreateCommand())
@ -641,37 +646,26 @@ namespace MediaBrowser.Server.Implementations.Sync
cmd.CommandText += " where " + string.Join(" AND ", whereClauses.ToArray());
}
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
cmd.CommandText += ";" + cmd.CommandText
.Replace("select ItemId,Status,Progress from SyncJobItems", "select ItemIds,Status,Progress from SyncJobs")
.Replace("'Synced'", "'Completed','CompletedWithError'");
//Logger.Debug(cmd.CommandText);
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
{
LogQueryTime("GetSyncedItemProgresses", cmd, now);
while (reader.Read())
{
var itemId = reader.GetString(0);
AddStatusResult(reader, result, false);
}
if (!reader.IsDBNull(1))
if (reader.NextResult())
{
while (reader.Read())
{
var status = (SyncJobItemStatus)Enum.Parse(typeof(SyncJobItemStatus), reader.GetString(1), true);
if (status == SyncJobItemStatus.Synced)
{
result[itemId] = new SyncedItemProgress
{
Status = SyncJobItemStatus.Synced
};
}
else
{
SyncedItemProgress currentStatus;
double progress = reader.IsDBNull(2) ? 0.0 : reader.GetDouble(2);
if (!result.TryGetValue(itemId, out currentStatus) || (currentStatus.Status != SyncJobItemStatus.Synced && progress >= currentStatus.Progress))
{
result[itemId] = new SyncedItemProgress
{
Status = status,
Progress = progress
};
}
}
AddStatusResult(reader, result, true);
}
}
}
@ -681,6 +675,96 @@ namespace MediaBrowser.Server.Implementations.Sync
return result;
}
private void LogQueryTime(string methodName, IDbCommand cmd, DateTime startDate)
{
var elapsed = (DateTime.UtcNow - startDate).TotalMilliseconds;
var slowThreshold = 1000;
#if DEBUG
slowThreshold = 50;
#endif
if (elapsed >= slowThreshold)
{
Logger.Debug("{2} query time (slow): {0}ms. Query: {1}",
Convert.ToInt32(elapsed),
cmd.CommandText,
methodName);
}
else
{
//Logger.Debug("{2} query time: {0}ms. Query: {1}",
// Convert.ToInt32(elapsed),
// cmd.CommandText,
// methodName);
}
}
private void AddStatusResult(IDataReader reader, Dictionary<string, SyncedItemProgress> result, bool multipleIds)
{
if (reader.IsDBNull(0))
{
return;
}
var itemIds = new List<string>();
var ids = reader.GetString(0);
if (multipleIds)
{
itemIds = ids.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
}
else
{
itemIds.Add(ids);
}
if (!reader.IsDBNull(1))
{
SyncJobItemStatus status;
var statusString = reader.GetString(1);
if (string.Equals(statusString, "Completed", StringComparison.OrdinalIgnoreCase) ||
string.Equals(statusString, "CompletedWithError", StringComparison.OrdinalIgnoreCase))
{
status = SyncJobItemStatus.Synced;
}
else
{
status = (SyncJobItemStatus)Enum.Parse(typeof(SyncJobItemStatus), statusString, true);
}
if (status == SyncJobItemStatus.Synced)
{
foreach (var itemId in itemIds)
{
result[itemId] = new SyncedItemProgress
{
Status = SyncJobItemStatus.Synced
};
}
}
else
{
double progress = reader.IsDBNull(2) ? 0.0 : reader.GetDouble(2);
foreach (var itemId in itemIds)
{
SyncedItemProgress currentStatus;
if (!result.TryGetValue(itemId, out currentStatus) || (currentStatus.Status != SyncJobItemStatus.Synced && progress >= currentStatus.Progress))
{
result[itemId] = new SyncedItemProgress
{
Status = status,
Progress = progress
};
}
}
}
}
}
public QueryResult<SyncJobItem> GetJobItems(SyncJobItemQuery query)
{
return GetJobItemReader(query, BaseJobItemSelectText, GetJobItem);

View File

@ -144,6 +144,10 @@ namespace MediaBrowser.Server.Implementations.Sync
{
mediaSource.Id = item.Id;
mediaSource.SupportsTranscoding = false;
if (mediaSource.Protocol == Model.MediaInfo.MediaProtocol.File)
{
mediaSource.ETag = item.Id;
}
}
public Task CloseMediaSource(string liveStreamId, CancellationToken cancellationToken)

View File

@ -163,7 +163,7 @@ namespace MediaBrowser.ServerApplication
{
_logger.Info("Found a duplicate process. Giving it time to exit.");
if (!duplicate.WaitForExit(15000))
if (!duplicate.WaitForExit(20000))
{
_logger.Info("The duplicate process did not exit.");
return true;

View File

@ -64,25 +64,25 @@ namespace MediaBrowser.XbmcMetadata.Savers
writer.WriteElementString("aired", episode.PremiereDate.Value.ToLocalTime().ToString(formatString));
}
if (episode.AirsAfterSeasonNumber.HasValue)
if (episode.AirsAfterSeasonNumber.HasValue && episode.AirsAfterSeasonNumber.Value != -1)
{
writer.WriteElementString("airsafter_season", episode.AirsAfterSeasonNumber.Value.ToString(UsCulture));
}
if (episode.AirsBeforeEpisodeNumber.HasValue)
if (episode.AirsBeforeEpisodeNumber.HasValue && episode.AirsBeforeEpisodeNumber.Value != -1)
{
writer.WriteElementString("airsbefore_episode", episode.AirsBeforeEpisodeNumber.Value.ToString(UsCulture));
}
if (episode.AirsBeforeEpisodeNumber.HasValue)
if (episode.AirsBeforeEpisodeNumber.HasValue && episode.AirsBeforeEpisodeNumber.Value != -1)
{
writer.WriteElementString("displayepisode", episode.AirsBeforeEpisodeNumber.Value.ToString(UsCulture));
}
if (episode.AirsBeforeSeasonNumber.HasValue)
if (episode.AirsBeforeSeasonNumber.HasValue && episode.AirsBeforeSeasonNumber.Value != -1)
{
writer.WriteElementString("airsbefore_season", episode.AirsBeforeSeasonNumber.Value.ToString(UsCulture));
}
var season = episode.AiredSeasonNumber;
if (season.HasValue)
if (season.HasValue && season.Value != -1)
{
writer.WriteElementString("displayseason", season.Value.ToString(UsCulture));
}