This commit is contained in:
Luke Pulverenti 2017-07-30 14:02:25 -04:00
parent f7f0d3eba0
commit 31841a31a9
8 changed files with 37 additions and 28 deletions

View File

@ -122,7 +122,7 @@ namespace Emby.Server.Implementations.Library
/// <param name="user">The user.</param> /// <param name="user">The user.</param>
private void OnUserDeleted(User user) private void OnUserDeleted(User user)
{ {
EventHelper.QueueEventIfNotNull(UserDeleted, this, new GenericEventArgs<User> { Argument = user }, _logger); EventHelper.FireEventIfNotNull(UserDeleted, this, new GenericEventArgs<User> { Argument = user }, _logger);
} }
#endregion #endregion

View File

@ -2154,7 +2154,7 @@ namespace Emby.Server.Implementations.LiveTv
await service.CancelTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false); await service.CancelTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false);
_lastRecordingRefreshTime = DateTime.MinValue; _lastRecordingRefreshTime = DateTime.MinValue;
EventHelper.QueueEventIfNotNull(TimerCancelled, this, new GenericEventArgs<TimerEventInfo> EventHelper.FireEventIfNotNull(TimerCancelled, this, new GenericEventArgs<TimerEventInfo>
{ {
Argument = new TimerEventInfo Argument = new TimerEventInfo
{ {
@ -2177,7 +2177,7 @@ namespace Emby.Server.Implementations.LiveTv
await service.CancelSeriesTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false); await service.CancelSeriesTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false);
_lastRecordingRefreshTime = DateTime.MinValue; _lastRecordingRefreshTime = DateTime.MinValue;
EventHelper.QueueEventIfNotNull(SeriesTimerCancelled, this, new GenericEventArgs<TimerEventInfo> EventHelper.FireEventIfNotNull(SeriesTimerCancelled, this, new GenericEventArgs<TimerEventInfo>
{ {
Argument = new TimerEventInfo Argument = new TimerEventInfo
{ {
@ -2516,7 +2516,7 @@ namespace Emby.Server.Implementations.LiveTv
_lastRecordingRefreshTime = DateTime.MinValue; _lastRecordingRefreshTime = DateTime.MinValue;
_logger.Info("New recording scheduled"); _logger.Info("New recording scheduled");
EventHelper.QueueEventIfNotNull(TimerCreated, this, new GenericEventArgs<TimerEventInfo> EventHelper.FireEventIfNotNull(TimerCreated, this, new GenericEventArgs<TimerEventInfo>
{ {
Argument = new TimerEventInfo Argument = new TimerEventInfo
{ {
@ -2558,7 +2558,7 @@ namespace Emby.Server.Implementations.LiveTv
_lastRecordingRefreshTime = DateTime.MinValue; _lastRecordingRefreshTime = DateTime.MinValue;
EventHelper.QueueEventIfNotNull(SeriesTimerCreated, this, new GenericEventArgs<TimerEventInfo> EventHelper.FireEventIfNotNull(SeriesTimerCreated, this, new GenericEventArgs<TimerEventInfo>
{ {
Argument = new TimerEventInfo Argument = new TimerEventInfo
{ {

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
@ -11,12 +10,10 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
@ -46,9 +43,16 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
get { return "M3U Tuner"; } get { return "M3U Tuner"; }
} }
private string GetFullChannelIdPrefix(TunerHostInfo info)
{
return ChannelIdPrefix + info.Url.GetMD5().ToString("N");
}
protected override async Task<List<ChannelInfo>> GetChannelsInternal(TunerHostInfo info, CancellationToken cancellationToken) protected override async Task<List<ChannelInfo>> GetChannelsInternal(TunerHostInfo info, CancellationToken cancellationToken)
{ {
var result = await new M3uParser(Logger, FileSystem, _httpClient, _appHost).Parse(info.Url, ChannelIdPrefix, info.Id, !info.EnableTvgId, cancellationToken).ConfigureAwait(false); var channelIdPrefix = GetFullChannelIdPrefix(info);
var result = await new M3uParser(Logger, FileSystem, _httpClient, _appHost).Parse(info.Url, channelIdPrefix, info.Id, cancellationToken).ConfigureAwait(false);
return result.Cast<ChannelInfo>().ToList(); return result.Cast<ChannelInfo>().ToList();
} }
@ -87,9 +91,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
protected override async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(TunerHostInfo info, string channelId, CancellationToken cancellationToken) protected override async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(TunerHostInfo info, string channelId, CancellationToken cancellationToken)
{ {
var urlHash = info.Url.GetMD5().ToString("N"); var channelIdPrefix = GetFullChannelIdPrefix(info);
var prefix = ChannelIdPrefix + urlHash;
if (!channelId.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) if (!channelId.StartsWith(channelIdPrefix, StringComparison.OrdinalIgnoreCase))
{ {
return null; return null;
} }

View File

@ -32,25 +32,21 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
_appHost = appHost; _appHost = appHost;
} }
public async Task<List<M3UChannel>> Parse(string url, string channelIdPrefix, string tunerHostId, bool enableStreamUrlAsIdentifier, CancellationToken cancellationToken) public async Task<List<M3UChannel>> Parse(string url, string channelIdPrefix, string tunerHostId, CancellationToken cancellationToken)
{ {
var urlHash = url.GetMD5().ToString("N");
// Read the file and display it line by line. // Read the file and display it line by line.
using (var reader = new StreamReader(await GetListingsStream(url, cancellationToken).ConfigureAwait(false))) using (var reader = new StreamReader(await GetListingsStream(url, cancellationToken).ConfigureAwait(false)))
{ {
return GetChannels(reader, urlHash, channelIdPrefix, tunerHostId, enableStreamUrlAsIdentifier); return GetChannels(reader, channelIdPrefix, tunerHostId);
} }
} }
public List<M3UChannel> ParseString(string text, string channelIdPrefix, string tunerHostId) public List<M3UChannel> ParseString(string text, string channelIdPrefix, string tunerHostId)
{ {
var urlHash = "text".GetMD5().ToString("N");
// Read the file and display it line by line. // Read the file and display it line by line.
using (var reader = new StringReader(text)) using (var reader = new StringReader(text))
{ {
return GetChannels(reader, urlHash, channelIdPrefix, tunerHostId, false); return GetChannels(reader, channelIdPrefix, tunerHostId);
} }
} }
@ -70,7 +66,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
} }
const string ExtInfPrefix = "#EXTINF:"; const string ExtInfPrefix = "#EXTINF:";
private List<M3UChannel> GetChannels(TextReader reader, string urlHash, string channelIdPrefix, string tunerHostId, bool enableStreamUrlAsIdentifier) private List<M3UChannel> GetChannels(TextReader reader, string channelIdPrefix, string tunerHostId)
{ {
var channels = new List<M3UChannel>(); var channels = new List<M3UChannel>();
string line; string line;
@ -97,13 +93,13 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
else if (!string.IsNullOrWhiteSpace(extInf) && !line.StartsWith("#", StringComparison.OrdinalIgnoreCase)) else if (!string.IsNullOrWhiteSpace(extInf) && !line.StartsWith("#", StringComparison.OrdinalIgnoreCase))
{ {
var channel = GetChannelnfo(extInf, tunerHostId, line); var channel = GetChannelnfo(extInf, tunerHostId, line);
if (string.IsNullOrWhiteSpace(channel.Id) || enableStreamUrlAsIdentifier) if (string.IsNullOrWhiteSpace(channel.Id))
{ {
channel.Id = channelIdPrefix + urlHash + line.GetMD5().ToString("N"); channel.Id = channelIdPrefix + line.GetMD5().ToString("N");
} }
else else
{ {
channel.Id = channelIdPrefix + urlHash + channel.Id.GetMD5().ToString("N"); channel.Id = channelIdPrefix + channel.Id.GetMD5().ToString("N");
} }
channel.Path = line; channel.Path = line;

View File

@ -199,6 +199,12 @@ namespace MediaBrowser.Api
[ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
public bool? EnableUserData { get; set; } public bool? EnableUserData { get; set; }
[ApiMember(Name = "SortBy", Description = "Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, CriticRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Revenue, Runtime", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string SortBy { get; set; }
[ApiMember(Name = "SortOrder", Description = "Sort Order - Ascending,Descending", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public SortOrder? SortOrder { get; set; }
} }
[Route("/Shows/{Id}/Seasons", "GET", Summary = "Gets seasons for a tv series")] [Route("/Shows/{Id}/Seasons", "GET", Summary = "Gets seasons for a tv series")]
@ -541,6 +547,11 @@ namespace MediaBrowser.Api
returnItems = UserViewBuilder.FilterForAdjacency(returnItems, request.AdjacentTo); returnItems = UserViewBuilder.FilterForAdjacency(returnItems, request.AdjacentTo);
} }
if (string.Equals(request.SortBy, ItemSortBy.Random, StringComparison.OrdinalIgnoreCase))
{
returnItems = returnItems.OrderBy(i => Guid.NewGuid());
}
var returnList = returnItems.ToList(); var returnList = returnItems.ToList();
var pagedItems = ApplyPaging(returnList, request.StartIndex, request.Limit); var pagedItems = ApplyPaging(returnList, request.StartIndex, request.Limit);

View File

@ -1089,7 +1089,7 @@ namespace MediaBrowser.Model.Dlna
{ {
if (!conditionProcessor.IsVideoAudioConditionSatisfied(applyCondition, audioChannels, audioBitrate, audioSampleRate, audioBitDepth, audioProfile, isSecondaryAudio)) if (!conditionProcessor.IsVideoAudioConditionSatisfied(applyCondition, audioChannels, audioBitrate, audioSampleRate, audioBitDepth, audioProfile, isSecondaryAudio))
{ {
LogConditionFailure(profile, "VideoAudioCodecProfile", applyCondition, mediaSource); LogConditionFailure(profile, "VideoAudioCodecProfile.ApplyConditions", applyCondition, mediaSource);
applyConditions = false; applyConditions = false;
break; break;
} }

View File

@ -46,13 +46,11 @@ namespace MediaBrowser.Model.LiveTv
public string FriendlyName { get; set; } public string FriendlyName { get; set; }
public bool ImportFavoritesOnly { get; set; } public bool ImportFavoritesOnly { get; set; }
public bool AllowHWTranscoding { get; set; } public bool AllowHWTranscoding { get; set; }
public bool EnableTvgId { get; set; }
public bool EnableStreamLooping { get; set; } public bool EnableStreamLooping { get; set; }
public TunerHostInfo() public TunerHostInfo()
{ {
AllowHWTranscoding = true; AllowHWTranscoding = true;
EnableTvgId = true;
} }
} }

View File

@ -1,3 +1,3 @@
using System.Reflection; using System.Reflection;
[assembly: AssemblyVersion("3.2.26.6")] [assembly: AssemblyVersion("3.2.26.7")]