added chromecast boilerplate
This commit is contained in:
parent
2d0ce724ea
commit
2d27b10d11
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
@ -44,6 +45,12 @@ namespace MediaBrowser.Model.LiveTv
|
|||
/// <value>The number.</value>
|
||||
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>
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
@ -46,6 +47,12 @@ namespace MediaBrowser.Model.LiveTv
|
|||
/// <value>The channel primary image tag.</value>
|
||||
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>
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
@ -39,6 +40,12 @@ namespace MediaBrowser.Model.LiveTv
|
|||
/// </summary>
|
||||
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>
|
||||
|
|
|
@ -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);
|
||||
itemsWithSoundtracks = itemsWithSoundtracks.Where(i => i.SoundtrackIds.Count > 0).ToList();
|
||||
|
||||
progress.Report(75);
|
||||
|
||||
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();
|
||||
name = " " + name + " ";
|
||||
|
||||
var tvdbId = series.GetProviderId(MetadataProviders.Tvdb);
|
||||
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);
|
||||
|
||||
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();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in New Issue
Block a user