Added album soundtrack links
This commit is contained in:
parent
682dea1d70
commit
c1ad234b79
|
@ -31,7 +31,7 @@ namespace MediaBrowser.Common.Configuration
|
|||
|
||||
configuration = xmlSerializer.DeserializeFromBytes(type, buffer);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
catch (Exception)
|
||||
{
|
||||
configuration = Activator.CreateInstance(type);
|
||||
}
|
||||
|
|
|
@ -95,6 +95,37 @@ namespace MediaBrowser.Controller.Dto
|
|||
|
||||
AttachBasicFields(dto, item, fields);
|
||||
|
||||
if (fields.Contains(ItemFields.SoundtrackIds))
|
||||
{
|
||||
var series = item as Series;
|
||||
|
||||
if (series != null)
|
||||
{
|
||||
AttachSoundtrackIds(dto, series, user);
|
||||
}
|
||||
|
||||
var movie = item as Movie;
|
||||
|
||||
if (movie != null)
|
||||
{
|
||||
AttachSoundtrackIds(dto, movie, user);
|
||||
}
|
||||
|
||||
var album = item as MusicAlbum;
|
||||
|
||||
if (album != null)
|
||||
{
|
||||
AttachSoundtrackIds(dto, album, user);
|
||||
}
|
||||
|
||||
var game = item as Game;
|
||||
|
||||
if (game != null)
|
||||
{
|
||||
AttachSoundtrackIds(dto, game, user);
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure all the tasks we kicked off have completed.
|
||||
if (tasks.Count > 0)
|
||||
{
|
||||
|
@ -104,6 +135,132 @@ namespace MediaBrowser.Controller.Dto
|
|||
return dto;
|
||||
}
|
||||
|
||||
private void AttachSoundtrackIds(BaseItemDto dto, Movie item, User user)
|
||||
{
|
||||
var tmdb = item.GetProviderId(MetadataProviders.Tmdb);
|
||||
|
||||
if (string.IsNullOrEmpty(tmdb))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var recursiveChildren = user == null
|
||||
? _libraryManager.RootFolder.RecursiveChildren
|
||||
: user.RootFolder.GetRecursiveChildren(user);
|
||||
|
||||
dto.SoundtrackIds = recursiveChildren
|
||||
.Where(i =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(tmdb) &&
|
||||
string.Equals(tmdb, i.GetProviderId(MetadataProviders.Tmdb), StringComparison.OrdinalIgnoreCase) &&
|
||||
i is MusicAlbum)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.Select(GetClientItemId)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private void AttachSoundtrackIds(BaseItemDto dto, Series item, User user)
|
||||
{
|
||||
var tvdb = item.GetProviderId(MetadataProviders.Tvdb);
|
||||
|
||||
if (string.IsNullOrEmpty(tvdb))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var recursiveChildren = user == null
|
||||
? _libraryManager.RootFolder.RecursiveChildren
|
||||
: user.RootFolder.GetRecursiveChildren(user);
|
||||
|
||||
dto.SoundtrackIds = recursiveChildren
|
||||
.Where(i =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(tvdb) &&
|
||||
string.Equals(tvdb, i.GetProviderId(MetadataProviders.Tvdb), StringComparison.OrdinalIgnoreCase) &&
|
||||
i is MusicAlbum)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.Select(GetClientItemId)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private void AttachSoundtrackIds(BaseItemDto dto, Game item, User user)
|
||||
{
|
||||
var gamesdb = item.GetProviderId(MetadataProviders.Gamesdb);
|
||||
|
||||
if (string.IsNullOrEmpty(gamesdb))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var recursiveChildren = user == null
|
||||
? _libraryManager.RootFolder.RecursiveChildren
|
||||
: user.RootFolder.GetRecursiveChildren(user);
|
||||
|
||||
dto.SoundtrackIds = recursiveChildren
|
||||
.Where(i =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(gamesdb) &&
|
||||
string.Equals(gamesdb, i.GetProviderId(MetadataProviders.Gamesdb), StringComparison.OrdinalIgnoreCase) &&
|
||||
i is MusicAlbum)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.Select(GetClientItemId)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private void AttachSoundtrackIds(BaseItemDto dto, MusicAlbum item, User user)
|
||||
{
|
||||
var tmdb = item.GetProviderId(MetadataProviders.Tmdb);
|
||||
var tvdb = item.GetProviderId(MetadataProviders.Tvdb);
|
||||
var gamesdb = item.GetProviderId(MetadataProviders.Gamesdb);
|
||||
|
||||
if (string.IsNullOrEmpty(tmdb) && string.IsNullOrEmpty(tvdb) && string.IsNullOrEmpty(gamesdb))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var recursiveChildren = user == null
|
||||
? _libraryManager.RootFolder.RecursiveChildren
|
||||
: user.RootFolder.GetRecursiveChildren(user);
|
||||
|
||||
dto.SoundtrackIds = recursiveChildren
|
||||
.Where(i =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(tmdb) &&
|
||||
string.Equals(tmdb, i.GetProviderId(MetadataProviders.Tmdb), StringComparison.OrdinalIgnoreCase) &&
|
||||
i is Movie)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(tvdb) &&
|
||||
string.Equals(tvdb, i.GetProviderId(MetadataProviders.Tvdb), StringComparison.OrdinalIgnoreCase) &&
|
||||
i is Series)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(gamesdb) &&
|
||||
string.Equals(gamesdb, i.GetProviderId(MetadataProviders.Gamesdb), StringComparison.OrdinalIgnoreCase) &&
|
||||
i is Game)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.Select(GetClientItemId)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches the user specific info.
|
||||
/// </summary>
|
||||
|
@ -235,10 +392,7 @@ namespace MediaBrowser.Controller.Dto
|
|||
dto.OriginalRunTimeTicks = item.OriginalRunTimeTicks;
|
||||
}
|
||||
|
||||
if (fields.Contains(ItemFields.DisplayMediaType))
|
||||
{
|
||||
dto.DisplayMediaType = item.DisplayMediaType;
|
||||
}
|
||||
dto.DisplayMediaType = item.DisplayMediaType;
|
||||
|
||||
if (fields.Contains(ItemFields.MetadataSettings))
|
||||
{
|
||||
|
@ -436,30 +590,27 @@ namespace MediaBrowser.Controller.Dto
|
|||
}
|
||||
|
||||
// Add audio info
|
||||
if (fields.Contains(ItemFields.AudioInfo))
|
||||
var audio = item as Audio;
|
||||
if (audio != null)
|
||||
{
|
||||
var audio = item as Audio;
|
||||
if (audio != null)
|
||||
{
|
||||
dto.Album = audio.Album;
|
||||
dto.AlbumArtist = audio.AlbumArtist;
|
||||
dto.Artists = new[] { audio.Artist };
|
||||
}
|
||||
dto.Album = audio.Album;
|
||||
dto.AlbumArtist = audio.AlbumArtist;
|
||||
dto.Artists = new[] { audio.Artist };
|
||||
}
|
||||
|
||||
var album = item as MusicAlbum;
|
||||
var album = item as MusicAlbum;
|
||||
|
||||
if (album != null)
|
||||
{
|
||||
var songs = album.RecursiveChildren.OfType<Audio>().ToList();
|
||||
if (album != null)
|
||||
{
|
||||
var songs = album.RecursiveChildren.OfType<Audio>().ToList();
|
||||
|
||||
dto.AlbumArtist = songs.Select(i => i.AlbumArtist).FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
||||
dto.AlbumArtist = songs.Select(i => i.AlbumArtist).FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
||||
|
||||
dto.Artists =
|
||||
songs.Select(i => i.Artist ?? string.Empty)
|
||||
.Where(i => !string.IsNullOrEmpty(i))
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToArray();
|
||||
}
|
||||
dto.Artists =
|
||||
songs.Select(i => i.Artist ?? string.Empty)
|
||||
.Where(i => !string.IsNullOrEmpty(i))
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
// Add video info
|
||||
|
@ -510,36 +661,33 @@ namespace MediaBrowser.Controller.Dto
|
|||
dto.IndexNumberEnd = episode.IndexNumberEnd;
|
||||
}
|
||||
|
||||
if (fields.Contains(ItemFields.SeriesInfo))
|
||||
// Add SeriesInfo
|
||||
var series = item as Series;
|
||||
|
||||
if (series != null)
|
||||
{
|
||||
// Add SeriesInfo
|
||||
var series = item as Series;
|
||||
dto.AirDays = series.AirDays;
|
||||
dto.AirTime = series.AirTime;
|
||||
dto.Status = series.Status;
|
||||
}
|
||||
|
||||
if (series != null)
|
||||
{
|
||||
dto.AirDays = series.AirDays;
|
||||
dto.AirTime = series.AirTime;
|
||||
dto.Status = series.Status;
|
||||
}
|
||||
if (episode != null)
|
||||
{
|
||||
series = item.FindParent<Series>();
|
||||
|
||||
if (episode != null)
|
||||
{
|
||||
series = item.FindParent<Series>();
|
||||
dto.SeriesId = GetClientItemId(series);
|
||||
dto.SeriesName = series.Name;
|
||||
}
|
||||
|
||||
dto.SeriesId = GetClientItemId(series);
|
||||
dto.SeriesName = series.Name;
|
||||
}
|
||||
// Add SeasonInfo
|
||||
var season = item as Season;
|
||||
|
||||
// Add SeasonInfo
|
||||
var season = item as Season;
|
||||
if (season != null)
|
||||
{
|
||||
series = item.FindParent<Series>();
|
||||
|
||||
if (season != null)
|
||||
{
|
||||
series = item.FindParent<Series>();
|
||||
|
||||
dto.SeriesId = GetClientItemId(series);
|
||||
dto.SeriesName = series.Name;
|
||||
}
|
||||
dto.SeriesId = GetClientItemId(series);
|
||||
dto.SeriesName = series.Name;
|
||||
}
|
||||
|
||||
var game = item as Game;
|
||||
|
|
|
@ -162,6 +162,12 @@ namespace MediaBrowser.Model.Dto
|
|||
/// <value>The trailer urls.</value>
|
||||
public List<MediaUrl> RemoteTrailers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the soundtrack ids.
|
||||
/// </summary>
|
||||
/// <value>The soundtrack ids.</value>
|
||||
public string[] SoundtrackIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the provider ids.
|
||||
/// </summary>
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace MediaBrowser.Model.Entities
|
|||
/// </summary>
|
||||
public enum MetadataProviders
|
||||
{
|
||||
Gamesdb,
|
||||
/// <summary>
|
||||
/// The imdb
|
||||
/// </summary>
|
||||
|
|
|
@ -131,6 +131,11 @@ namespace MediaBrowser.Model.Querying
|
|||
/// </summary>
|
||||
SeriesInfo,
|
||||
|
||||
/// <summary>
|
||||
/// The soundtrack ids
|
||||
/// </summary>
|
||||
SoundtrackIds,
|
||||
|
||||
/// <summary>
|
||||
/// The sort name of the item
|
||||
/// </summary>
|
||||
|
|
|
@ -38,7 +38,9 @@ namespace MediaBrowser.ServerApplication
|
|||
{
|
||||
bool createdNew;
|
||||
|
||||
_singleInstanceMutex = new Mutex(true, @"Local\" + typeof(App).Assembly.GetName().Name, out createdNew);
|
||||
var runningPath = Process.GetCurrentProcess().MainModule.FileName.Replace(Path.DirectorySeparatorChar.ToString(), string.Empty);
|
||||
|
||||
_singleInstanceMutex = new Mutex(true, @"Local\" + runningPath, out createdNew);
|
||||
|
||||
if (!createdNew)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user