From f4c25b24711ddc1e042bf691d5b4c5dfdbf4a8e3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 27 Aug 2015 15:59:42 -0400 Subject: update m3u tuners --- .../LiveTv/EmbyTV/EmbyTV.cs | 2 +- .../LiveTv/TunerHosts/M3UTunerHost.cs | 153 +++++++++------------ 2 files changed, 68 insertions(+), 87 deletions(-) (limited to 'MediaBrowser.Server.Implementations/LiveTv') diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index b69cdacef3..8b717e5d44 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -455,7 +455,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV } } - throw new ApplicationException("Tuner not found."); + throw new NotImplementedException(); } public Task> GetRecordingStreamMediaSources(string recordingId, CancellationToken cancellationToken) diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index e19b17ca42..3783e4b089 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -39,68 +39,45 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts var url = info.Url; var urlHash = url.GetMD5().ToString("N"); - int position = 0; string line; // Read the file and display it line by line. var file = new StreamReader(url); var channels = new List(); + + string channnelName = null; + string channelNumber = null; + while ((line = file.ReadLine()) != null) { line = line.Trim(); - if (!String.IsNullOrWhiteSpace(line)) + if (string.IsNullOrWhiteSpace(line)) { - if (position == 0 && !line.StartsWith("#EXTM3U")) - { - throw new ApplicationException("wrong file"); - } - if (position % 2 == 0) - { - if (position != 0) - { - channels.Last().Path = line; - } - else - { - line = line.Replace("#EXTM3U", ""); - line = line.Trim(); - var vars = line.Split(' ').ToList(); - foreach (var variable in vars) - { - var list = variable.Replace('"', ' ').Split('='); - switch (list[0]) - { - case ("id"): - //_id = list[1]; - break; - } - } - } - } - else + continue; + } + + if (line.StartsWith("#EXTM3U", StringComparison.OrdinalIgnoreCase)) + { + continue; + } + + if (line.StartsWith("#EXTINF:", StringComparison.OrdinalIgnoreCase)) + { + var parts = line.Split(new[] { ':' }, 2).Last().Split(new[] { ',' }, 2); + channelNumber = parts[0]; + channnelName = parts[1]; + } + else if (!string.IsNullOrWhiteSpace(channelNumber)) + { + channels.Add(new M3UChannel { - if (!line.StartsWith("#EXTINF:")) { throw new ApplicationException("Bad file"); } - line = line.Replace("#EXTINF:", ""); - var nameStart = line.LastIndexOf(','); - line = line.Substring(0, nameStart); - var vars = line.Split(' ').ToList(); - vars.RemoveAt(0); - channels.Add(new M3UChannel()); - foreach (var variable in vars) - { - var list = variable.Replace('"', ' ').Split('='); - switch (list[0]) - { - case "tvg-id": - channels.Last().Id = ChannelIdPrefix + urlHash + list[1]; - channels.Last().Number = list[1]; - break; - case "tvg-name": - channels.Last().Name = list[1]; - break; - } - } - } - position++; + Name = channnelName, + Number = channelNumber, + Id = ChannelIdPrefix + urlHash + channelNumber, + Path = line + }); + + channelNumber = null; + channnelName = null; } } file.Close(); @@ -125,6 +102,35 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts } protected override async Task GetChannelStream(TunerHostInfo info, string channelId, string streamId, CancellationToken cancellationToken) + { + var sources = await GetChannelStreamMediaSources(info, channelId, cancellationToken).ConfigureAwait(false); + + return sources.First(); + } + + class M3UChannel : ChannelInfo + { + public string Path { get; set; } + + public M3UChannel() + { + } + } + + public async Task Validate(TunerHostInfo info) + { + if (!File.Exists(info.Url)) + { + throw new FileNotFoundException(); + } + } + + protected override bool IsValidChannelId(string channelId) + { + return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase); + } + + protected override async Task> GetChannelStreamMediaSources(TunerHostInfo info, string channelId, CancellationToken cancellationToken) { var urlHash = info.Url.GetMD5().ToString("N"); var prefix = ChannelIdPrefix + urlHash; @@ -133,29 +139,29 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts return null; } - channelId = channelId.Substring(prefix.Length); + //channelId = channelId.Substring(prefix.Length); var channels = await GetChannels(info, true, cancellationToken).ConfigureAwait(false); var m3uchannels = channels.Cast(); - var channel = m3uchannels.FirstOrDefault(c => c.Id == channelId); + var channel = m3uchannels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase)); if (channel != null) { var path = channel.Path; MediaProtocol protocol = MediaProtocol.File; - if (path.StartsWith("http")) + if (path.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { protocol = MediaProtocol.Http; } - else if (path.StartsWith("rtmp")) + else if (path.StartsWith("rtmp", StringComparison.OrdinalIgnoreCase)) { protocol = MediaProtocol.Rtmp; } - else if (path.StartsWith("rtsp")) + else if (path.StartsWith("rtsp", StringComparison.OrdinalIgnoreCase)) { protocol = MediaProtocol.Rtsp; } - return new MediaSourceInfo + var mediaSource = new MediaSourceInfo { Path = channel.Path, Protocol = protocol, @@ -179,35 +185,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts RequiresOpening = false, RequiresClosing = false }; - } - throw new ApplicationException("Host doesnt provide this channel"); - } - - class M3UChannel : ChannelInfo - { - public string Path { get; set; } - - public M3UChannel() - { - } - } - public async Task Validate(TunerHostInfo info) - { - if (!File.Exists(info.Url)) - { - throw new FileNotFoundException(); + return new List { mediaSource }; } - } - - protected override bool IsValidChannelId(string channelId) - { - return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase); - } - - protected override Task> GetChannelStreamMediaSources(TunerHostInfo info, string channelId, CancellationToken cancellationToken) - { - throw new NotImplementedException(); + return new List { }; } protected override Task IsAvailableInternal(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken) -- cgit v1.2.3 From 274d8176b31a97bb9c8432e4f3a4ba9401a4b1e6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 28 Aug 2015 20:50:39 -0400 Subject: update hls --- MediaBrowser.Api/Playback/Hls/BaseHlsService.cs | 2 +- .../Folders/DefaultImageProvider.cs | 2 +- .../LiveTv/EmbyTV/EntryPoint.cs | 33 ++-------------------- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Model.Signed.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +-- 7 files changed, 10 insertions(+), 39 deletions(-) (limited to 'MediaBrowser.Server.Implementations/LiveTv') diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index 61fd7a55a0..5d377366a0 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -326,7 +326,7 @@ namespace MediaBrowser.Api.Playback.Hls var length = frame - previousSegment; // Don't allow really long segments because this could result in long download times - if (length > 12000) + if (length > 10000) { Logger.Debug("Cannot stream copy video due to long segment length of {0}ms", length); return false; diff --git a/MediaBrowser.Providers/Folders/DefaultImageProvider.cs b/MediaBrowser.Providers/Folders/DefaultImageProvider.cs index 6c719713be..506e983c6c 100644 --- a/MediaBrowser.Providers/Folders/DefaultImageProvider.cs +++ b/MediaBrowser.Providers/Folders/DefaultImageProvider.cs @@ -127,7 +127,7 @@ namespace MediaBrowser.Providers.Folders if (view != null) { - return !view.UserId.HasValue; + return true; } return item is ICollectionFolder; diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs index a297c866ad..713cb9cd30 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs @@ -1,41 +1,12 @@ -using MediaBrowser.Common.Configuration; -using MediaBrowser.Common.Security; -using MediaBrowser.Controller.Plugins; -using MediaBrowser.Model.LiveTv; +using MediaBrowser.Controller.Plugins; namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV { public class EntryPoint : IServerEntryPoint { - private readonly IConfigurationManager _config; - private readonly ISecurityManager _manager; - - public EntryPoint(IConfigurationManager config, ISecurityManager manager) - { - _config = config; - _manager = manager; - } - - public async void Run() + public void Run() { EmbyTV.Current.Start(); - - if (GetConfiguration().ListingProviders.Count > 0 || GetConfiguration().TunerHosts.Count > 0) - { - try - { - await _manager.GetRegistrationStatus("livetvguide").ConfigureAwait(false); - } - catch - { - - } - } - } - - private LiveTvOptions GetConfiguration() - { - return _config.GetConfiguration("livetv"); } public void Dispose() diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index a0702fb687..f92e054925 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.632 + 3.0.633 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Emby Theater and Emby Server. Not intended for plugin developer consumption. Copyright © Emby 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 56e6f5c693..04d4deb7c9 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.632 + 3.0.633 MediaBrowser.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index 654d33b5cd..2a75ac3a89 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.632 + 3.0.633 MediaBrowser.Model - Signed Edition Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index b72d50d69f..da83094106 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.632 + 3.0.633 Media Browser.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - + -- cgit v1.2.3