diff options
| author | Luke <luke.pulverenti@gmail.com> | 2015-08-29 14:07:27 -0400 |
|---|---|---|
| committer | Luke <luke.pulverenti@gmail.com> | 2015-08-29 14:07:27 -0400 |
| commit | 6f343203ce1d46f83e3b0d5d2865d30f9b9e6a36 (patch) | |
| tree | 99757b4beec8399d27fadbab7e4a8ac545c22bb7 /MediaBrowser.Server.Implementations | |
| parent | 3425b53376e2d7a624e238159414bde9e12f61e6 (diff) | |
| parent | 636bd5ab76b7cb78c1784d2004b1fe4eedeb4162 (diff) | |
Merge branch 'dev' of https://github.com/MediaBrowser/MediaBrowser into dev
Diffstat (limited to 'MediaBrowser.Server.Implementations')
19 files changed, 145 insertions, 169 deletions
diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs index 973519a77..8a659fb65 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs @@ -41,7 +41,7 @@ namespace MediaBrowser.Server.Implementations.Connect _timer = new Timer(TimerCallback, null, TimeSpan.FromSeconds(5), TimeSpan.FromHours(3)); } - private readonly string[] _ipLookups = { "http://bot.whatismyipaddress.com", "https://connect.mediabrowser.tv/service/ip" }; + private readonly string[] _ipLookups = { "http://bot.whatismyipaddress.com", "https://connect.emby.media/service/ip" }; private async void TimerCallback(object state) { diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index 4569503c0..7cd96c5f3 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -371,7 +371,7 @@ namespace MediaBrowser.Server.Implementations.Connect private string GetConnectUrl(string handler) { - return "https://connect.mediabrowser.tv/service/" + handler; + return "https://connect.emby.media/service/" + handler; } public async Task<UserLinkResult> LinkUser(string userId, string connectUsername) diff --git a/MediaBrowser.Server.Implementations/Library/MusicManager.cs b/MediaBrowser.Server.Implementations/Library/MusicManager.cs index b83256342..683e6c5cc 100644 --- a/MediaBrowser.Server.Implementations/Library/MusicManager.cs +++ b/MediaBrowser.Server.Implementations/Library/MusicManager.cs @@ -52,6 +52,18 @@ namespace MediaBrowser.Server.Implementations.Library return GetInstantMixFromGenres(genres, user); } + public IEnumerable<Audio> GetInstantMixFromFolder(Folder item, User user) + { + var genres = item + .GetRecursiveChildren(user, i => i is Audio) + .Cast<Audio>() + .SelectMany(i => i.Genres) + .Concat(item.Genres) + .DistinctNames(); + + return GetInstantMixFromGenres(genres, user); + } + public IEnumerable<Audio> GetInstantMixFromPlaylist(Playlist item, User user) { var genres = item @@ -113,6 +125,12 @@ namespace MediaBrowser.Server.Implementations.Library { return GetInstantMixFromSong(song, user); } + + var folder = item as Folder; + if (folder != null) + { + return GetInstantMixFromFolder(folder, user); + } return new Audio[] { }; } diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index b69cdacef..8b717e5d4 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<List<MediaSourceInfo>> GetRecordingStreamMediaSources(string recordingId, CancellationToken cancellationToken) diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs index a297c866a..713cb9cd3 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<LiveTvOptions>("livetv"); } public void Dispose() diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index e19b17ca4..3783e4b08 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<M3UChannel>(); + + 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(); @@ -126,6 +103,35 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts protected override async Task<MediaSourceInfo> 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<List<MediaSourceInfo>> GetChannelStreamMediaSources(TunerHostInfo info, string channelId, CancellationToken cancellationToken) + { var urlHash = info.Url.GetMD5().ToString("N"); var prefix = ChannelIdPrefix + urlHash; if (!channelId.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) @@ -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<M3UChannel>(); - 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<MediaSourceInfo> { mediaSource }; } - } - - protected override bool IsValidChannelId(string channelId) - { - return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase); - } - - protected override Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(TunerHostInfo info, string channelId, CancellationToken cancellationToken) - { - throw new NotImplementedException(); + return new List<MediaSourceInfo> { }; } protected override Task<bool> IsAvailableInternal(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken) diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index b2da2489d..f0312cef6 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -495,14 +495,6 @@ <Link>swagger-ui\swagger-ui.min.js</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> - <EmbeddedResource Include="UserViews\livetv\1.jpg" /> - <EmbeddedResource Include="UserViews\livetv\2.jpg" /> - <EmbeddedResource Include="UserViews\livetv\3.jpg" /> - <EmbeddedResource Include="UserViews\livetv\4.jpg" /> - <EmbeddedResource Include="UserViews\livetv\5.jpg" /> - <EmbeddedResource Include="UserViews\livetv\6.jpg" /> - <EmbeddedResource Include="UserViews\livetv\7.jpg" /> - <EmbeddedResource Include="UserViews\livetv\8.jpg" /> <EmbeddedResource Include="Localization\iso6392.txt" /> <EmbeddedResource Include="Localization\Ratings\be.txt" /> </ItemGroup> diff --git a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs index 7a993b7db..d913063c8 100644 --- a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs @@ -46,9 +46,16 @@ namespace MediaBrowser.Server.Implementations.Persistence public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress) { var innerProgress = new ActionableProgress<double>(); - innerProgress.RegisterAction(progress.Report); + innerProgress.RegisterAction(p => progress.Report(.95 * p)); await UpdateToLatestSchema(cancellationToken, innerProgress).ConfigureAwait(false); + + innerProgress = new ActionableProgress<double>(); + innerProgress.RegisterAction(p => progress.Report(95 + (.05 * p))); + + //await CleanDeadItems(cancellationToken, innerProgress).ConfigureAwait(false); + + progress.Report(100); } private async Task UpdateToLatestSchema(CancellationToken cancellationToken, IProgress<double> progress) @@ -92,6 +99,43 @@ namespace MediaBrowser.Server.Implementations.Persistence progress.Report(100); } + private async Task CleanDeadItems(CancellationToken cancellationToken, IProgress<double> progress) + { + var itemIds = _libraryManager.GetItemIds(new InternalItemsQuery + { + HasDeadParentId = true + }); + + var numComplete = 0; + var numItems = itemIds.Count; + + _logger.Debug("Cleaning {0} items with dead parent links", numItems); + + foreach (var itemId in itemIds) + { + cancellationToken.ThrowIfCancellationRequested(); + + var item = _libraryManager.GetItemById(itemId); + + if (item != null) + { + _logger.Debug("Cleaning item {0} type: {1} path: {2}", item.Name, item.GetType().Name, item.Path ?? string.Empty); + + await _libraryManager.DeleteItem(item, new DeleteOptions + { + DeleteFileLocation = false + }); + } + + numComplete++; + double percent = numComplete; + percent /= numItems; + progress.Report(percent * 100); + } + + progress.Report(100); + } + public IEnumerable<ITaskTrigger> GetDefaultTriggers() { return new ITaskTrigger[] diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index 04f09602f..00ebf7ea6 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -1096,6 +1096,14 @@ namespace MediaBrowser.Server.Implementations.Persistence } } + if (query.HasDeadParentId.HasValue) + { + if (query.HasDeadParentId.Value) + { + whereClauses.Add("ParentId NOT NULL AND ParentId NOT IN (select guid from TypedBaseItems)"); + } + } + if (addPaging) { if (query.StartIndex.HasValue && query.StartIndex.Value > 0) diff --git a/MediaBrowser.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs b/MediaBrowser.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs index 8cb76393e..2f219c299 100644 --- a/MediaBrowser.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs +++ b/MediaBrowser.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs @@ -39,7 +39,7 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks { var list = new ITaskTrigger[] { - new IntervalTrigger{ Interval = TimeSpan.FromHours(8)} + new IntervalTrigger{ Interval = TimeSpan.FromHours(12)} }.ToList(); diff --git a/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs b/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs index b11a7d167..844238228 100644 --- a/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs +++ b/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs @@ -11,8 +11,6 @@ using MediaBrowser.Server.Implementations.Photos; using MoreLinq; using System; using System.Collections.Generic; -using System.Globalization; -using System.IO; using System.Linq; using System.Threading.Tasks; @@ -152,9 +150,7 @@ namespace MediaBrowser.Server.Implementations.UserViews CollectionType.Games, CollectionType.Music, CollectionType.BoxSets, - CollectionType.Playlists, CollectionType.Channels, - CollectionType.LiveTv, CollectionType.Books, CollectionType.Photos, CollectionType.HomeVideos, @@ -170,7 +166,7 @@ namespace MediaBrowser.Server.Implementations.UserViews var view = (UserView)item; if (imageType == ImageType.Primary && IsUsingCollectionStrip(view)) { - if (itemsWithImages.Count == 0 && !string.Equals(view.ViewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase)) + if (itemsWithImages.Count == 0) { return false; } @@ -180,39 +176,5 @@ namespace MediaBrowser.Server.Implementations.UserViews return await base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex).ConfigureAwait(false); } - - protected override IEnumerable<String> GetStripCollageImagePaths(IHasImages primaryItem, IEnumerable<BaseItem> items) - { - var userView = primaryItem as UserView; - - if (userView != null && string.Equals(userView.ViewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase)) - { - var list = new List<string>(); - for (int i = 1; i <= 8; i++) - { - list.Add(ExtractLiveTvResource(i.ToString(CultureInfo.InvariantCulture), ApplicationPaths)); - } - return list; - } - - return base.GetStripCollageImagePaths(primaryItem, items); - } - - private string ExtractLiveTvResource(string name, IApplicationPaths paths) - { - var namespacePath = GetType().Namespace + ".livetv." + name + ".jpg"; - var tempPath = Path.Combine(paths.TempDirectory, Guid.NewGuid().ToString("N") + ".jpg"); - Directory.CreateDirectory(Path.GetDirectoryName(tempPath)); - - using (var stream = GetType().Assembly.GetManifestResourceStream(namespacePath)) - { - using (var fileStream = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.Read)) - { - stream.CopyTo(fileStream); - } - } - - return tempPath; - } } } diff --git a/MediaBrowser.Server.Implementations/UserViews/livetv/1.jpg b/MediaBrowser.Server.Implementations/UserViews/livetv/1.jpg Binary files differdeleted file mode 100644 index 2594b68a4..000000000 --- a/MediaBrowser.Server.Implementations/UserViews/livetv/1.jpg +++ /dev/null diff --git a/MediaBrowser.Server.Implementations/UserViews/livetv/2.jpg b/MediaBrowser.Server.Implementations/UserViews/livetv/2.jpg Binary files differdeleted file mode 100644 index e5c87b96b..000000000 --- a/MediaBrowser.Server.Implementations/UserViews/livetv/2.jpg +++ /dev/null diff --git a/MediaBrowser.Server.Implementations/UserViews/livetv/3.jpg b/MediaBrowser.Server.Implementations/UserViews/livetv/3.jpg Binary files differdeleted file mode 100644 index c19f7e612..000000000 --- a/MediaBrowser.Server.Implementations/UserViews/livetv/3.jpg +++ /dev/null diff --git a/MediaBrowser.Server.Implementations/UserViews/livetv/4.jpg b/MediaBrowser.Server.Implementations/UserViews/livetv/4.jpg Binary files differdeleted file mode 100644 index 93ee18044..000000000 --- a/MediaBrowser.Server.Implementations/UserViews/livetv/4.jpg +++ /dev/null diff --git a/MediaBrowser.Server.Implementations/UserViews/livetv/5.jpg b/MediaBrowser.Server.Implementations/UserViews/livetv/5.jpg Binary files differdeleted file mode 100644 index 4c2cd580d..000000000 --- a/MediaBrowser.Server.Implementations/UserViews/livetv/5.jpg +++ /dev/null diff --git a/MediaBrowser.Server.Implementations/UserViews/livetv/6.jpg b/MediaBrowser.Server.Implementations/UserViews/livetv/6.jpg Binary files differdeleted file mode 100644 index 6f496b6ac..000000000 --- a/MediaBrowser.Server.Implementations/UserViews/livetv/6.jpg +++ /dev/null diff --git a/MediaBrowser.Server.Implementations/UserViews/livetv/7.jpg b/MediaBrowser.Server.Implementations/UserViews/livetv/7.jpg Binary files differdeleted file mode 100644 index e7dba2760..000000000 --- a/MediaBrowser.Server.Implementations/UserViews/livetv/7.jpg +++ /dev/null diff --git a/MediaBrowser.Server.Implementations/UserViews/livetv/8.jpg b/MediaBrowser.Server.Implementations/UserViews/livetv/8.jpg Binary files differdeleted file mode 100644 index c69ba908c..000000000 --- a/MediaBrowser.Server.Implementations/UserViews/livetv/8.jpg +++ /dev/null |
