add soundtracks to theme media result
This commit is contained in:
parent
8349b1f83a
commit
9758adb8a5
|
@ -116,7 +116,7 @@ namespace MediaBrowser.Api
|
|||
/// </summary>
|
||||
[Route("/Items/{Id}/ThemeMedia", "GET")]
|
||||
[Api(Description = "Gets theme videos and songs for an item")]
|
||||
public class GetThemeMedia : IReturn<ThemeMediaResult>
|
||||
public class GetThemeMedia : IReturn<AllThemeMediaResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the user id.
|
||||
|
@ -435,11 +435,6 @@ namespace MediaBrowser.Api
|
|||
|
||||
return items;
|
||||
}
|
||||
|
||||
private int FavoriteCount(IEnumerable<BaseItem> items, Guid userId)
|
||||
{
|
||||
return items.AsParallel().Count(i => _userDataManager.GetUserData(userId, i.GetUserDataKey()).IsFavorite);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the specified request.
|
||||
|
@ -572,7 +567,9 @@ namespace MediaBrowser.Api
|
|||
return ToOptimizedResult(new AllThemeMediaResult
|
||||
{
|
||||
ThemeSongsResult = themeSongs,
|
||||
ThemeVideosResult = themeVideos
|
||||
ThemeVideosResult = themeVideos,
|
||||
|
||||
SoundtrackSongsResult = GetSoundtrackSongs(request.Id, request.UserId, request.InheritFromParent)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -650,8 +647,7 @@ namespace MediaBrowser.Api
|
|||
}
|
||||
|
||||
// Get everything
|
||||
var fields =
|
||||
Enum.GetNames(typeof(ItemFields))
|
||||
var fields = Enum.GetNames(typeof(ItemFields))
|
||||
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
||||
.ToList();
|
||||
|
||||
|
@ -669,7 +665,7 @@ namespace MediaBrowser.Api
|
|||
};
|
||||
}
|
||||
|
||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
|
||||
public object Get(GetYearIndex request)
|
||||
{
|
||||
|
@ -687,11 +683,61 @@ namespace MediaBrowser.Api
|
|||
.Select(i => new ItemIndex
|
||||
{
|
||||
ItemCount = i.Count(),
|
||||
Name = i.Key == -1 ? string.Empty : i.Key.ToString(UsCulture)
|
||||
Name = i.Key == -1 ? string.Empty : i.Key.ToString(_usCulture)
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return ToOptimizedResult(lookup);
|
||||
}
|
||||
|
||||
public ThemeMediaResult GetSoundtrackSongs(string id, Guid? userId, bool inheritFromParent)
|
||||
{
|
||||
var user = userId.HasValue ? _userManager.GetUserById(userId.Value) : null;
|
||||
|
||||
var item = string.IsNullOrEmpty(id)
|
||||
? (userId.HasValue
|
||||
? user.RootFolder
|
||||
: (Folder)_libraryManager.RootFolder)
|
||||
: _dtoService.GetItemByDtoId(id, userId);
|
||||
|
||||
while (GetSoundtrackSongIds(item).Count == 0 && inheritFromParent && item.Parent != null)
|
||||
{
|
||||
item = item.Parent;
|
||||
}
|
||||
|
||||
// Get everything
|
||||
var fields = Enum.GetNames(typeof(ItemFields))
|
||||
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
||||
.ToList();
|
||||
|
||||
var dtos = GetSoundtrackSongIds(item)
|
||||
.Select(_libraryManager.GetItemById)
|
||||
.OfType<MusicAlbum>()
|
||||
.SelectMany(i => i.RecursiveChildren)
|
||||
.OfType<Audio>()
|
||||
.OrderBy(i => i.SortName)
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));
|
||||
|
||||
var items = dtos.ToArray();
|
||||
|
||||
return new ThemeMediaResult
|
||||
{
|
||||
Items = items,
|
||||
TotalRecordCount = items.Length,
|
||||
OwnerId = _dtoService.GetDtoId(item)
|
||||
};
|
||||
}
|
||||
|
||||
private List<Guid> GetSoundtrackSongIds(BaseItem item)
|
||||
{
|
||||
var hasSoundtracks = item as IHasSoundtracks;
|
||||
|
||||
if (hasSoundtracks != null)
|
||||
{
|
||||
return hasSoundtracks.SoundtrackIds;
|
||||
}
|
||||
|
||||
return new List<Guid>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
|
|||
|
||||
if (!updateInfo.IsUpdateAvailable)
|
||||
{
|
||||
Logger.Debug("No application update available.");
|
||||
progress.Report(100);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -11,9 +11,12 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||
/// </summary>
|
||||
public class MusicAlbum : Folder, IHasAlbumArtist, IHasArtist, IHasMusicGenres
|
||||
{
|
||||
public List<Guid> SoundtrackIds { get; set; }
|
||||
|
||||
public MusicAlbum()
|
||||
{
|
||||
Artists = new List<string>();
|
||||
SoundtrackIds = new List<Guid>();
|
||||
}
|
||||
|
||||
public string LastFmImageUrl { get; set; }
|
||||
|
|
|
@ -25,11 +25,6 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// </summary>
|
||||
public abstract class BaseItem : IHasProviderIds, ILibraryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// MusicAlbums in the library that are the soundtrack for this item
|
||||
/// </summary>
|
||||
public List<Guid> SoundtrackIds { get; set; }
|
||||
|
||||
protected BaseItem()
|
||||
{
|
||||
Genres = new List<string>();
|
||||
|
@ -43,7 +38,6 @@ namespace MediaBrowser.Controller.Entities
|
|||
Tags = new List<string>();
|
||||
ThemeSongIds = new List<Guid>();
|
||||
ThemeVideoIds = new List<Guid>();
|
||||
SoundtrackIds = new List<Guid>();
|
||||
LocalTrailerIds = new List<Guid>();
|
||||
LockedFields = new List<MetadataFields>();
|
||||
Taglines = new List<string>();
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
public class Game : BaseItem
|
||||
public class Game : BaseItem, IHasSoundtracks
|
||||
{
|
||||
public List<Guid> SoundtrackIds { get; set; }
|
||||
|
||||
public Game()
|
||||
{
|
||||
MultiPartGameFiles = new List<string>();
|
||||
SoundtrackIds = new List<Guid>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
17
MediaBrowser.Controller/Entities/IHasSoundtracks.cs
Normal file
17
MediaBrowser.Controller/Entities/IHasSoundtracks.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IHasSoundtracks
|
||||
/// </summary>
|
||||
public interface IHasSoundtracks
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the soundtrack ids.
|
||||
/// </summary>
|
||||
/// <value>The soundtrack ids.</value>
|
||||
List<Guid> SoundtrackIds { get; set; }
|
||||
}
|
||||
}
|
|
@ -11,13 +11,16 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||
/// <summary>
|
||||
/// Class Movie
|
||||
/// </summary>
|
||||
public class Movie : Video, IHasCriticRating
|
||||
public class Movie : Video, IHasCriticRating, IHasSoundtracks
|
||||
{
|
||||
public List<Guid> SpecialFeatureIds { get; set; }
|
||||
|
||||
public List<Guid> SoundtrackIds { get; set; }
|
||||
|
||||
public Movie()
|
||||
{
|
||||
SpecialFeatureIds = new List<Guid>();
|
||||
SoundtrackIds = new List<Guid>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -193,6 +193,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
return false;
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public bool IsMissingEpisode
|
||||
{
|
||||
get
|
||||
|
@ -201,11 +202,13 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
}
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public bool IsUnaired
|
||||
{
|
||||
get { return PremiereDate.HasValue && PremiereDate.Value.ToLocalTime().Date >= DateTime.Now.Date; }
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public bool IsVirtualUnaired
|
||||
{
|
||||
get { return LocationType == Model.Entities.LocationType.Virtual && IsUnaired; }
|
||||
|
|
|
@ -149,21 +149,25 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
return IndexNumber != null ? IndexNumber.Value.ToString("0000") : Name;
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public bool IsMissingSeason
|
||||
{
|
||||
get { return LocationType == Model.Entities.LocationType.Virtual && Children.OfType<Episode>().All(i => i.IsMissingEpisode); }
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public bool IsUnaired
|
||||
{
|
||||
get { return Children.OfType<Episode>().All(i => i.IsUnaired); }
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public bool IsVirtualUnaired
|
||||
{
|
||||
get { return LocationType == Model.Entities.LocationType.Virtual && IsUnaired; }
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public bool IsMissingOrVirtualUnaired
|
||||
{
|
||||
get { return LocationType == Model.Entities.LocationType.Virtual && Children.OfType<Episode>().All(i => i.IsVirtualUnaired || i.IsMissingEpisode); }
|
||||
|
|
|
@ -11,9 +11,10 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
/// <summary>
|
||||
/// Class Series
|
||||
/// </summary>
|
||||
public class Series : Folder
|
||||
public class Series : Folder, IHasSoundtracks
|
||||
{
|
||||
public List<Guid> SpecialFeatureIds { get; set; }
|
||||
public List<Guid> SoundtrackIds { get; set; }
|
||||
|
||||
public int SeasonCount { get; set; }
|
||||
|
||||
|
@ -22,6 +23,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
AirDays = new List<DayOfWeek>();
|
||||
|
||||
SpecialFeatureIds = new List<Guid>();
|
||||
SoundtrackIds = new List<Guid>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
|
@ -7,12 +8,15 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// <summary>
|
||||
/// Class Trailer
|
||||
/// </summary>
|
||||
public class Trailer : Video, IHasCriticRating
|
||||
public class Trailer : Video, IHasCriticRating, IHasSoundtracks
|
||||
{
|
||||
public List<Guid> SoundtrackIds { get; set; }
|
||||
|
||||
public Trailer()
|
||||
{
|
||||
RemoteTrailers = new List<MediaUrl>();
|
||||
Taglines = new List<string>();
|
||||
SoundtrackIds = new List<Guid>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -90,6 +90,7 @@
|
|||
<Compile Include="Entities\GameSystem.cs" />
|
||||
<Compile Include="Entities\IByReferenceItem.cs" />
|
||||
<Compile Include="Entities\IHasCriticRating.cs" />
|
||||
<Compile Include="Entities\IHasSoundtracks.cs" />
|
||||
<Compile Include="Entities\IItemByName.cs" />
|
||||
<Compile Include="Entities\ILibraryItem.cs" />
|
||||
<Compile Include="Entities\ImageSourceInfo.cs" />
|
||||
|
|
|
@ -19,11 +19,15 @@ namespace MediaBrowser.Model.Querying
|
|||
|
||||
public ThemeMediaResult ThemeSongsResult { get; set; }
|
||||
|
||||
public ThemeMediaResult SoundtrackSongsResult { get; set; }
|
||||
|
||||
public AllThemeMediaResult()
|
||||
{
|
||||
ThemeVideosResult = new ThemeMediaResult();
|
||||
|
||||
ThemeSongsResult = new ThemeMediaResult();
|
||||
|
||||
SoundtrackSongsResult = new ThemeMediaResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,17 +60,19 @@ namespace MediaBrowser.Providers.Music
|
|||
foreach (var movie in allItems
|
||||
.Where(i => (i is Movie) || (i is Trailer)))
|
||||
{
|
||||
var hasSoundtracks = (IHasSoundtracks) movie;
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var tmdbId = movie.GetProviderId(MetadataProviders.Tmdb);
|
||||
|
||||
if (string.IsNullOrEmpty(tmdbId))
|
||||
{
|
||||
movie.SoundtrackIds = new List<Guid>();
|
||||
hasSoundtracks.SoundtrackIds = new List<Guid>();
|
||||
continue;
|
||||
}
|
||||
|
||||
movie.SoundtrackIds = allAlbums
|
||||
hasSoundtracks.SoundtrackIds = allAlbums
|
||||
.Where(i => string.Equals(tmdbId, i.GetProviderId(MetadataProviders.Tmdb), StringComparison.OrdinalIgnoreCase))
|
||||
.Select(i => i.Id)
|
||||
.ToList();
|
||||
|
|
|
@ -102,9 +102,14 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
|
||||
if (fields.Contains(ItemFields.SoundtrackIds))
|
||||
{
|
||||
dto.SoundtrackIds = item.SoundtrackIds
|
||||
.Select(i => i.ToString("N"))
|
||||
.ToArray();
|
||||
var hasSoundtracks = item as IHasSoundtracks;
|
||||
|
||||
if (hasSoundtracks != null)
|
||||
{
|
||||
dto.SoundtrackIds = hasSoundtracks.SoundtrackIds
|
||||
.Select(i => i.ToString("N"))
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
var itemByName = item as IItemByName;
|
||||
|
@ -131,12 +136,9 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
//counts = item.ItemCounts;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if (!item.UserItemCounts.TryGetValue(user.Id, out counts))
|
||||
{
|
||||
if (!item.UserItemCounts.TryGetValue(user.Id, out counts))
|
||||
{
|
||||
counts = new ItemByNameCounts();
|
||||
}
|
||||
counts = new ItemByNameCounts();
|
||||
}
|
||||
|
||||
dto.ChildCount = counts.TotalCount;
|
||||
|
@ -967,6 +969,10 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
if (album != null)
|
||||
{
|
||||
dto.Artists = album.Artists;
|
||||
|
||||
dto.SoundtrackIds = album.SoundtrackIds
|
||||
.Select(i => i.ToString("N"))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
var hasAlbumArtist = item as IHasAlbumArtist;
|
||||
|
|
Loading…
Reference in New Issue
Block a user