diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-02-23 00:52:30 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-02-23 00:52:30 -0500 |
| commit | 2d27b10d11552d160cb2b3c41c5e0e5bf60e7350 (patch) | |
| tree | ce3fefde2e9da005549491419eab2daa4ef2fd95 | |
| parent | 2d0ce724ea09bf51cb12b6b04ea63dfaf74b0ad2 (diff) | |
added chromecast boilerplate
12 files changed, 108 insertions, 122 deletions
diff --git a/MediaBrowser.Controller/Entities/Book.cs b/MediaBrowser.Controller/Entities/Book.cs index 29d6e4084..ea7ecfb4a 100644 --- a/MediaBrowser.Controller/Entities/Book.cs +++ b/MediaBrowser.Controller/Entities/Book.cs @@ -1,7 +1,7 @@ -using System.Linq; -using MediaBrowser.Controller.Providers; +using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using System.Collections.Generic; +using System.Linq; namespace MediaBrowser.Controller.Entities { diff --git a/MediaBrowser.Controller/Entities/IHasSoundtracks.cs b/MediaBrowser.Controller/Entities/IHasSoundtracks.cs index 31defc9f4..3ac2491fb 100644 --- a/MediaBrowser.Controller/Entities/IHasSoundtracks.cs +++ b/MediaBrowser.Controller/Entities/IHasSoundtracks.cs @@ -13,5 +13,17 @@ namespace MediaBrowser.Controller.Entities /// </summary> /// <value>The soundtrack ids.</value> List<Guid> SoundtrackIds { get; set; } + + /// <summary> + /// Gets the name. + /// </summary> + /// <value>The name.</value> + string Name { get; } + + /// <summary> + /// Gets the identifier. + /// </summary> + /// <value>The identifier.</value> + Guid Id { get; } } } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index e16683d6d..fa85f0edc 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -127,11 +127,6 @@ namespace MediaBrowser.Controller.Entities /// <returns>List{System.String}.</returns> public List<string> GetPlayableStreamFiles(string rootPath) { - if (PlayableStreamFileNames == null) - { - return null; - } - var allFiles = Directory.EnumerateFiles(rootPath, "*", SearchOption.AllDirectories).ToList(); return PlayableStreamFileNames.Select(name => allFiles.FirstOrDefault(f => string.Equals(System.IO.Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase))) diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs b/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs index 668c3a414..edf86cae8 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs @@ -2,6 +2,7 @@ using MediaBrowser.Controller.Providers; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Model.Library; namespace MediaBrowser.Controller.LiveTv { @@ -20,5 +21,7 @@ namespace MediaBrowser.Controller.LiveTv bool IsParentalAllowed(User user); Task RefreshMetadata(MetadataRefreshOptions options, CancellationToken cancellationToken); + + PlayAccess GetPlayAccess(User user); } } diff --git a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs index 170d7eb73..d17e2a7f9 100644 --- a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs @@ -5,6 +5,7 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; +using MediaBrowser.Model.Library; namespace MediaBrowser.Model.LiveTv { @@ -45,6 +46,12 @@ namespace MediaBrowser.Model.LiveTv public string Number { get; set; } /// <summary> + /// Gets or sets the play access. + /// </summary> + /// <value>The play access.</value> + public PlayAccess PlayAccess { get; set; } + + /// <summary> /// Gets or sets the name of the service. /// </summary> /// <value>The name of the service.</value> diff --git a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs index d761e88e6..f6b343bdb 100644 --- a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs @@ -5,6 +5,7 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; +using MediaBrowser.Model.Library; namespace MediaBrowser.Model.LiveTv { @@ -47,6 +48,12 @@ namespace MediaBrowser.Model.LiveTv public Guid? ChannelPrimaryImageTag { get; set; } /// <summary> + /// Gets or sets the play access. + /// </summary> + /// <value>The play access.</value> + public PlayAccess PlayAccess { get; set; } + + /// <summary> /// Gets or sets the name of the channel. /// </summary> /// <value>The name of the channel.</value> diff --git a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs index 6df9ef725..40aa5710e 100644 --- a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs @@ -5,6 +5,7 @@ using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; using System.ComponentModel; +using MediaBrowser.Model.Library; namespace MediaBrowser.Model.LiveTv { @@ -40,6 +41,12 @@ namespace MediaBrowser.Model.LiveTv public string ChannelId { get; set; } /// <summary> + /// Gets or sets the play access. + /// </summary> + /// <value>The play access.</value> + public PlayAccess PlayAccess { get; set; } + + /// <summary> /// Gets or sets the channel primary image tag. /// </summary> /// <value>The channel primary image tag.</value> diff --git a/MediaBrowser.Providers/Music/SoundtrackPostScanTask.cs b/MediaBrowser.Providers/Music/SoundtrackPostScanTask.cs index 1fd3fb9d9..0e5dfdb2b 100644 --- a/MediaBrowser.Providers/Music/SoundtrackPostScanTask.cs +++ b/MediaBrowser.Providers/Music/SoundtrackPostScanTask.cs @@ -1,12 +1,12 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Common.Extensions; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; -using MediaBrowser.Controller.Entities.Movies; -using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; -using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; +using System.Text; using System.Threading; using System.Threading.Tasks; @@ -39,126 +39,72 @@ namespace MediaBrowser.Providers.Music .OfType<MusicAlbum>() .ToList(); - AttachMovieSoundtracks(allItems, musicAlbums, cancellationToken); + var itemsWithSoundtracks = allItems.OfType<IHasSoundtracks>().ToList(); - progress.Report(25); + foreach (var item in itemsWithSoundtracks) + { + cancellationToken.ThrowIfCancellationRequested(); - AttachTvSoundtracks(allItems, musicAlbums, cancellationToken); + item.SoundtrackIds = GetSoundtrackIds(item, musicAlbums).ToList(); + } progress.Report(50); - AttachGameSoundtracks(allItems, musicAlbums, cancellationToken); - - progress.Report(75); + itemsWithSoundtracks = itemsWithSoundtracks.Where(i => i.SoundtrackIds.Count > 0).ToList(); - AttachAlbumLinks(allItems, musicAlbums, cancellationToken); + foreach (var album in musicAlbums) + { + cancellationToken.ThrowIfCancellationRequested(); + + album.SoundtrackIds = GetAlbumLinks(album.Id, itemsWithSoundtracks).ToList(); + } progress.Report(100); } - private void AttachMovieSoundtracks(IEnumerable<BaseItem> allItems, List<MusicAlbum> allAlbums, CancellationToken cancellationToken) + private IEnumerable<Guid> GetSoundtrackIds(IHasSoundtracks item, IEnumerable<MusicAlbum> albums) { - foreach (var movie in allItems - .Where(i => (i is Movie) || (i is Trailer))) - { - var hasSoundtracks = (IHasSoundtracks) movie; + var itemName = GetComparableName(item.Name); - cancellationToken.ThrowIfCancellationRequested(); - - var tmdbId = movie.GetProviderId(MetadataProviders.Tmdb); - - if (string.IsNullOrEmpty(tmdbId)) - { - hasSoundtracks.SoundtrackIds = new List<Guid>(); - continue; - } - - hasSoundtracks.SoundtrackIds = allAlbums - .Where(i => string.Equals(tmdbId, i.GetProviderId(MetadataProviders.Tmdb), StringComparison.OrdinalIgnoreCase)) - .Select(i => i.Id) - .ToList(); - } + return albums.Where(i => string.Equals(itemName, GetComparableName(i.Name), StringComparison.OrdinalIgnoreCase)).Select(i => i.Id); } - private void AttachTvSoundtracks(IEnumerable<BaseItem> allItems, List<MusicAlbum> allAlbums, CancellationToken cancellationToken) + private static string GetComparableName(string name) { - foreach (var series in allItems.OfType<Series>()) - { - cancellationToken.ThrowIfCancellationRequested(); - - var tvdbId = series.GetProviderId(MetadataProviders.Tvdb); - - if (string.IsNullOrEmpty(tvdbId)) - { - series.SoundtrackIds = new List<Guid>(); - continue; - } - - series.SoundtrackIds = allAlbums - .Where(i => string.Equals(tvdbId, i.GetProviderId(MetadataProviders.Tvdb), StringComparison.OrdinalIgnoreCase)) - .Select(i => i.Id) - .ToList(); - } + name = " " + name + " "; + + name = name.Replace(".", " ") + .Replace("_", " ") + .Replace("&", " ") + .Replace("!", " ") + .Replace("(", " ") + .Replace(")", " ") + .Replace(",", " ") + .Replace("-", " ") + .Replace(" a ", String.Empty, StringComparison.OrdinalIgnoreCase) + .Replace(" the ", String.Empty, StringComparison.OrdinalIgnoreCase) + .Replace(" ", String.Empty); + + return name.Trim(); } - private void AttachGameSoundtracks(IEnumerable<BaseItem> allItems, List<MusicAlbum> allAlbums, CancellationToken cancellationToken) + /// <summary> + /// Removes the diacritics. + /// </summary> + /// <param name="text">The text.</param> + /// <returns>System.String.</returns> + private static string RemoveDiacritics(string text) { - foreach (var game in allItems.OfType<Game>()) - { - cancellationToken.ThrowIfCancellationRequested(); - - var gamesdb = game.GetProviderId(MetadataProviders.Gamesdb); - - if (string.IsNullOrEmpty(gamesdb)) - { - game.SoundtrackIds = new List<Guid>(); - continue; - } - - game.SoundtrackIds = allAlbums - .Where(i => string.Equals(gamesdb, i.GetProviderId(MetadataProviders.Gamesdb), StringComparison.OrdinalIgnoreCase)) - .Select(i => i.Id) - .ToList(); - } + return String.Concat( + text.Normalize(NormalizationForm.FormD) + .Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) != + UnicodeCategory.NonSpacingMark) + ).Normalize(NormalizationForm.FormC); } - private void AttachAlbumLinks(List<BaseItem> allItems, IEnumerable<MusicAlbum> allAlbums, CancellationToken cancellationToken) + private IEnumerable<Guid> GetAlbumLinks(Guid albumId, IEnumerable<IHasSoundtracks> items) { - foreach (var album in allAlbums) - { - cancellationToken.ThrowIfCancellationRequested(); - - var tmdb = album.GetProviderId(MetadataProviders.Tmdb); - var tvdb = album.GetProviderId(MetadataProviders.Tvdb); - var gamesdb = album.GetProviderId(MetadataProviders.Gamesdb); - - if (string.IsNullOrEmpty(tmdb) && string.IsNullOrEmpty(tvdb) && string.IsNullOrEmpty(gamesdb)) - { - album.SoundtrackIds = new List<Guid>(); - continue; - } - - album.SoundtrackIds = allItems. - Where(i => - { - if (!string.IsNullOrEmpty(tmdb) && string.Equals(tmdb, i.GetProviderId(MetadataProviders.Tmdb), StringComparison.OrdinalIgnoreCase) && i is Movie) - { - return true; - } - if (!string.IsNullOrEmpty(tmdb) && string.Equals(tmdb, i.GetProviderId(MetadataProviders.Tmdb), StringComparison.OrdinalIgnoreCase) && i is Trailer) - { - return true; - } - if (!string.IsNullOrEmpty(tvdb) && string.Equals(tvdb, i.GetProviderId(MetadataProviders.Tvdb), StringComparison.OrdinalIgnoreCase) && i is Series) - { - return true; - } - - return !string.IsNullOrEmpty(gamesdb) && string.Equals(gamesdb, i.GetProviderId(MetadataProviders.Gamesdb), StringComparison.OrdinalIgnoreCase) && i is Game; - }) - .Select(i => i.Id) - .ToList(); - } + return items.Where(i => i.SoundtrackIds.Contains(albumId)).Select(i => i.Id); } } } diff --git a/MediaBrowser.Server.Implementations/FileOrganization/NameUtils.cs b/MediaBrowser.Server.Implementations/FileOrganization/NameUtils.cs index 75e5d92c3..23d0363cb 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/NameUtils.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/NameUtils.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Common.Extensions; +using MediaBrowser.Controller.Entities; using System; using System.Globalization; using System.Linq; @@ -58,7 +59,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization name = RemoveDiacritics(name); - name = " " + name.ToLower() + " "; + name = " " + name + " "; name = name.Replace(".", " ") .Replace("_", " ") @@ -68,8 +69,8 @@ namespace MediaBrowser.Server.Implementations.FileOrganization .Replace(")", " ") .Replace(",", " ") .Replace("-", " ") - .Replace(" a ", String.Empty) - .Replace(" the ", String.Empty) + .Replace(" a ", String.Empty, StringComparison.OrdinalIgnoreCase) + .Replace(" the ", String.Empty, StringComparison.OrdinalIgnoreCase) .Replace(" ", String.Empty); return name.Trim(); diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs index 22d683e1b..4e1bd860b 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -251,6 +251,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv if (user != null) { dto.UserData = _dtoService.GetUserItemDataDto(_userDataManager.GetUserData(user.Id, recording.GetUserDataKey())); + + dto.PlayAccess = recording.GetPlayAccess(user); } if (!string.IsNullOrEmpty(info.ProgramId)) @@ -321,6 +323,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv if (user != null) { dto.UserData = _dtoService.GetUserItemDataDto(_userDataManager.GetUserData(user.Id, info.GetUserDataKey())); + + dto.PlayAccess = info.GetPlayAccess(user); } var imageTag = GetImageTag(info); @@ -394,6 +398,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv if (user != null) { dto.UserData = _dtoService.GetUserItemDataDto(_userDataManager.GetUserData(user.Id, item.GetUserDataKey())); + + dto.PlayAccess = item.GetPlayAccess(user); } return dto; diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index db0f8eeb7..55c94a7d6 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -434,15 +434,13 @@ namespace MediaBrowser.WebDashboard.Api { var builder = new StringBuilder(); - builder.Append("<script type=\"text/javascript\">if (navigator.userAgent.toLowerCase().indexOf('compatible; msie 7')!=-1){alert(\"Please ensure you're running at least IE10 and that compatibility mode is disabled.\");}"); - builder.Append("</script>"); - var versionString = "?v=" + version; var files = new[] { "scripts/all.js" + versionString, - "thirdparty/jstree1.0/jquery.jstree.min.js" + "thirdparty/jstree1.0/jquery.jstree.min.js", + "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js" }; var tags = files.Select(s => string.Format("<script src=\"{0}\"></script>", s)).ToArray(); @@ -466,8 +464,9 @@ namespace MediaBrowser.WebDashboard.Api "site.js", "librarybrowser.js", "editorsidebar.js", - "librarymenu.js", + "chromecast.js", + "ratingdialog.js", "aboutpage.js", "allusersettings.js", @@ -547,7 +546,7 @@ namespace MediaBrowser.WebDashboard.Api "supporterpage.js", "episodes.js", "tvgenres.js", - "tvnextup.js", + "tvlatest.js", "tvpeople.js", "tvrecommended.js", "tvshows.js", diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index fd05ee7b0..6627acf6d 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -424,6 +424,9 @@ <Content Include="dashboard-ui\scripts\appsplayback.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Content Include="dashboard-ui\scripts\chromecast.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<Content Include="dashboard-ui\scripts\dashboardinfo.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -1255,7 +1258,7 @@ <Content Include="dashboard-ui\scripts\search.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
- <Content Include="dashboard-ui\scripts\tvnextup.js">
+ <Content Include="dashboard-ui\scripts\tvlatest.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\songs.html">
@@ -1437,7 +1440,7 @@ <Content Include="dashboard-ui\tvgenres.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
- <Content Include="dashboard-ui\tvnextup.html">
+ <Content Include="dashboard-ui\tvlatest.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\tvpeople.html">
|
