mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
Add Tracklist to Album Modal
This commit is contained in:
parent
90d9741056
commit
d243a8c8c4
16 changed files with 283 additions and 104 deletions
|
@ -14,6 +14,7 @@ namespace Lidarr.Api.V3.Albums
|
|||
public string Title { get; set; }
|
||||
public int ArtistId { get; set; }
|
||||
public List<string> AlbumLabel { get; set; }
|
||||
public string ForeignAlbumId { get; set; }
|
||||
public bool Monitored { get; set; }
|
||||
public string Path { get; set; }
|
||||
public int ProfileId { get; set; }
|
||||
|
@ -42,6 +43,7 @@ namespace Lidarr.Api.V3.Albums
|
|||
Id = model.Id,
|
||||
ArtistId = model.ArtistId,
|
||||
AlbumLabel = model.Label,
|
||||
ForeignAlbumId = model.ForeignAlbumId,
|
||||
Path = model.Path,
|
||||
ProfileId = model.ProfileId,
|
||||
Monitored = model.Monitored,
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Lidarr.Api.V3.TrackFiles
|
|||
private readonly IMediaFileService _mediaFileService;
|
||||
private readonly IRecycleBinProvider _recycleBinProvider;
|
||||
private readonly IArtistService _artistService;
|
||||
private readonly IAlbumService _albumService;
|
||||
private readonly IUpgradableSpecification _upgradableSpecification;
|
||||
private readonly Logger _logger;
|
||||
|
||||
|
@ -31,6 +32,7 @@ namespace Lidarr.Api.V3.TrackFiles
|
|||
IMediaFileService mediaFileService,
|
||||
IRecycleBinProvider recycleBinProvider,
|
||||
IArtistService artistService,
|
||||
IAlbumService albumService,
|
||||
IUpgradableSpecification upgradableSpecification,
|
||||
Logger logger)
|
||||
: base(signalRBroadcaster)
|
||||
|
@ -38,6 +40,7 @@ namespace Lidarr.Api.V3.TrackFiles
|
|||
_mediaFileService = mediaFileService;
|
||||
_recycleBinProvider = recycleBinProvider;
|
||||
_artistService = artistService;
|
||||
_albumService = albumService;
|
||||
_upgradableSpecification = upgradableSpecification;
|
||||
_logger = logger;
|
||||
|
||||
|
@ -62,10 +65,11 @@ namespace Lidarr.Api.V3.TrackFiles
|
|||
{
|
||||
var artistIdQuery = Request.Query.ArtistId;
|
||||
var trackFileIdsQuery = Request.Query.TrackFileIds;
|
||||
var albumIdQuery = Request.Query.AlbumId;
|
||||
|
||||
if (!artistIdQuery.HasValue && !trackFileIdsQuery.HasValue)
|
||||
if (!artistIdQuery.HasValue && !trackFileIdsQuery.HasValue && !albumIdQuery.HasValue)
|
||||
{
|
||||
throw new BadRequestException("artistId or trackFileIds must be provided");
|
||||
throw new BadRequestException("artistId, albumId, or trackFileIds must be provided");
|
||||
}
|
||||
|
||||
if (artistIdQuery.HasValue)
|
||||
|
@ -76,6 +80,14 @@ namespace Lidarr.Api.V3.TrackFiles
|
|||
return _mediaFileService.GetFilesByArtist(artistId).ConvertAll(f => f.ToResource(artist, _upgradableSpecification));
|
||||
}
|
||||
|
||||
if (albumIdQuery.HasValue)
|
||||
{
|
||||
int albumId = Convert.ToInt32(albumIdQuery.Value);
|
||||
var album = _albumService.GetAlbum(albumId);
|
||||
|
||||
return _mediaFileService.GetFilesByAlbum(album.ArtistId, album.Id).ConvertAll(f => f.ToResource(album.Artist, _upgradableSpecification));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
string episodeFileIdsValue = trackFileIdsQuery.Value.ToString();
|
||||
|
|
|
@ -24,26 +24,28 @@ namespace Lidarr.Api.V3.Tracks
|
|||
private List<TrackResource> GetEpisodes()
|
||||
{
|
||||
var artistIdQuery = Request.Query.ArtistId;
|
||||
var albumIdQuery = Request.Query.AlbumId;
|
||||
var trackIdsQuery = Request.Query.TrackIds;
|
||||
|
||||
if (!artistIdQuery.HasValue && !trackIdsQuery.HasValue)
|
||||
if (!artistIdQuery.HasValue && !trackIdsQuery.HasValue && !albumIdQuery.HasValue)
|
||||
{
|
||||
throw new BadRequestException("artistId or trackIds must be provided");
|
||||
}
|
||||
|
||||
if (artistIdQuery.HasValue)
|
||||
if (artistIdQuery.HasValue && !albumIdQuery.HasValue)
|
||||
{
|
||||
int artistId = Convert.ToInt32(artistIdQuery.Value);
|
||||
var albumId = Request.Query.AlbumId.HasValue ? (int)Request.Query.AlbumId : (int?)null;
|
||||
|
||||
if (albumId.HasValue)
|
||||
{
|
||||
return MapToResource(_trackService.GetTracksByAlbum(artistId, albumId.Value), false, false);
|
||||
}
|
||||
|
||||
return MapToResource(_trackService.GetTracksByArtist(artistId), false, false);
|
||||
}
|
||||
|
||||
if (albumIdQuery.HasValue)
|
||||
{
|
||||
int albumId = Convert.ToInt32(albumIdQuery.Value);
|
||||
|
||||
return MapToResource(_trackService.GetTracksByAlbum(albumId), false, false);
|
||||
}
|
||||
|
||||
string trackIdsValue = trackIdsQuery.Value.ToString();
|
||||
|
||||
var trackIds = trackIdsValue.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -71,7 +71,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
{
|
||||
|
||||
var artist = _artistService.GetArtist(artistId);
|
||||
var tracks = _trackService.GetTracksByAlbum(artistId, albumId);
|
||||
var tracks = _trackService.GetTracksByAlbum(albumId);
|
||||
var files = _mediaFileService.GetFilesByAlbum(artistId, albumId);
|
||||
|
||||
return GetPreviews(artist, tracks, files)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
|
@ -57,7 +57,7 @@ namespace NzbDrone.Core.Music
|
|||
foreach (var album in albums)
|
||||
{
|
||||
album.Monitored = monitored;
|
||||
var tracks = _trackService.GetTracksByAlbum(album.ArtistId, album.Id);
|
||||
var tracks = _trackService.GetTracksByAlbum(album.Id);
|
||||
foreach (var track in tracks)
|
||||
{
|
||||
track.Monitored = monitored;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using NLog;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Music.Events;
|
||||
|
@ -37,7 +37,7 @@ namespace NzbDrone.Core.Music
|
|||
|
||||
album = _albumService.FindById(album.ForeignAlbumId);
|
||||
|
||||
var existingTracks = _trackService.GetTracksByAlbum(album.ArtistId, album.Id);
|
||||
var existingTracks = _trackService.GetTracksByAlbum(album.Id);
|
||||
|
||||
var updateList = new List<Track>();
|
||||
var newList = new List<Track>();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
|
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Music
|
|||
{
|
||||
Track Find(int artistId, int albumId, int trackNumber);
|
||||
List<Track> GetTracks(int artistId);
|
||||
List<Track> GetTracks(int artistId, int albumId);
|
||||
List<Track> GetTracksByAlbum(int albumId);
|
||||
List<Track> GetTracksByFileId(int fileId);
|
||||
List<Track> TracksWithFiles(int artistId);
|
||||
PagingSpec<Track> TracksWithoutFiles(PagingSpec<Track> pagingSpec);
|
||||
|
@ -51,10 +51,9 @@ namespace NzbDrone.Core.Music
|
|||
return Query.Where(s => s.ArtistId == artistId).ToList();
|
||||
}
|
||||
|
||||
public List<Track> GetTracks(int artistId, int albumId)
|
||||
public List<Track> GetTracksByAlbum(int albumId)
|
||||
{
|
||||
return Query.Where(s => s.ArtistId == artistId)
|
||||
.AndWhere(s => s.AlbumId == albumId)
|
||||
return Query.Where(s => s.AlbumId == albumId)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using NLog;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Music
|
|||
Track FindTrack(int artistId, int albumId, int trackNumber);
|
||||
Track FindTrackByTitle(int artistId, int albumId, string releaseTitle);
|
||||
List<Track> GetTracksByArtist(int artistId);
|
||||
List<Track> GetTracksByAlbum(int artistId, int albumId);
|
||||
List<Track> GetTracksByAlbum(int albumId);
|
||||
//List<Track> GetTracksByAlbumTitle(string artistId, string albumTitle);
|
||||
List<Track> TracksWithFiles(int artistId);
|
||||
//PagingSpec<Track> TracksWithoutFiles(PagingSpec<Track> pagingSpec);
|
||||
|
@ -70,16 +70,16 @@ namespace NzbDrone.Core.Music
|
|||
return _trackRepository.GetTracks(artistId).ToList();
|
||||
}
|
||||
|
||||
public List<Track> GetTracksByAlbum(int artistId, int albumId)
|
||||
public List<Track> GetTracksByAlbum(int albumId)
|
||||
{
|
||||
return _trackRepository.GetTracks(artistId, albumId);
|
||||
return _trackRepository.GetTracksByAlbum(albumId);
|
||||
}
|
||||
|
||||
public Track FindTrackByTitle(int artistId, int albumId, string releaseTitle)
|
||||
{
|
||||
// TODO: can replace this search mechanism with something smarter/faster/better
|
||||
var normalizedReleaseTitle = Parser.Parser.NormalizeEpisodeTitle(releaseTitle).Replace(".", " ");
|
||||
var tracks = _trackRepository.GetTracks(artistId, albumId);
|
||||
var tracks = _trackRepository.GetTracksByAlbum(albumId);
|
||||
|
||||
var matches = tracks.Select(
|
||||
track => new
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue