aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/LibraryService.cs68
-rw-r--r--MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/SystemUpdateTask.cs1
-rw-r--r--MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs3
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs6
-rw-r--r--MediaBrowser.Controller/Entities/Game.cs6
-rw-r--r--MediaBrowser.Controller/Entities/IHasSoundtracks.cs17
-rw-r--r--MediaBrowser.Controller/Entities/Movies/Movie.cs5
-rw-r--r--MediaBrowser.Controller/Entities/TV/Episode.cs3
-rw-r--r--MediaBrowser.Controller/Entities/TV/Season.cs4
-rw-r--r--MediaBrowser.Controller/Entities/TV/Series.cs4
-rw-r--r--MediaBrowser.Controller/Entities/Trailer.cs6
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj1
-rw-r--r--MediaBrowser.Model/Querying/ThemeSongsResult.cs4
-rw-r--r--MediaBrowser.Providers/Music/SoundtrackPostScanTask.cs6
-rw-r--r--MediaBrowser.Server.Implementations/Dto/DtoService.cs22
15 files changed, 125 insertions, 31 deletions
diff --git a/MediaBrowser.Api/LibraryService.cs b/MediaBrowser.Api/LibraryService.cs
index aa2264398..f03d79795 100644
--- a/MediaBrowser.Api/LibraryService.cs
+++ b/MediaBrowser.Api/LibraryService.cs
@@ -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>();
+ }
}
}
diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/SystemUpdateTask.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/SystemUpdateTask.cs
index 88d56fead..c7a33b075 100644
--- a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/SystemUpdateTask.cs
+++ b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/SystemUpdateTask.cs
@@ -85,6 +85,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
if (!updateInfo.IsUpdateAvailable)
{
+ Logger.Debug("No application update available.");
progress.Report(100);
return;
}
diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs
index cb64cfdfe..09aefdac9 100644
--- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs
+++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs
@@ -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; }
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index f8b2fad23..9cd839b21 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -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>();
diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs
index 8a33eeb86..e8374c274 100644
--- a/MediaBrowser.Controller/Entities/Game.cs
+++ b/MediaBrowser.Controller/Entities/Game.cs
@@ -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>
diff --git a/MediaBrowser.Controller/Entities/IHasSoundtracks.cs b/MediaBrowser.Controller/Entities/IHasSoundtracks.cs
new file mode 100644
index 000000000..31defc9f4
--- /dev/null
+++ b/MediaBrowser.Controller/Entities/IHasSoundtracks.cs
@@ -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; }
+ }
+}
diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs
index 54ad9c1c9..eef348f61 100644
--- a/MediaBrowser.Controller/Entities/Movies/Movie.cs
+++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs
@@ -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>
diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs
index 96b120b8f..95d346733 100644
--- a/MediaBrowser.Controller/Entities/TV/Episode.cs
+++ b/MediaBrowser.Controller/Entities/TV/Episode.cs
@@ -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; }
diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs
index 5a53e8c0f..97a09b7b5 100644
--- a/MediaBrowser.Controller/Entities/TV/Season.cs
+++ b/MediaBrowser.Controller/Entities/TV/Season.cs
@@ -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); }
diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs
index 11fb198c2..02ea50c6b 100644
--- a/MediaBrowser.Controller/Entities/TV/Series.cs
+++ b/MediaBrowser.Controller/Entities/TV/Series.cs
@@ -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>
diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs
index c9fe471b3..26814ad40 100644
--- a/MediaBrowser.Controller/Entities/Trailer.cs
+++ b/MediaBrowser.Controller/Entities/Trailer.cs
@@ -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>
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 94ff5d305..f2837a1f1 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -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" />
diff --git a/MediaBrowser.Model/Querying/ThemeSongsResult.cs b/MediaBrowser.Model/Querying/ThemeSongsResult.cs
index 4c01e3b3d..9b0a1c61b 100644
--- a/MediaBrowser.Model/Querying/ThemeSongsResult.cs
+++ b/MediaBrowser.Model/Querying/ThemeSongsResult.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();
}
}
}
diff --git a/MediaBrowser.Providers/Music/SoundtrackPostScanTask.cs b/MediaBrowser.Providers/Music/SoundtrackPostScanTask.cs
index e18351248..a14f387b1 100644
--- a/MediaBrowser.Providers/Music/SoundtrackPostScanTask.cs
+++ b/MediaBrowser.Providers/Music/SoundtrackPostScanTask.cs
@@ -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();
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
index d327796f9..31b0c1a6a 100644
--- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs
+++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
@@ -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;