mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
New: Unmapped files view (#888)
* New: Unmapped files view Displays all trackfiles that haven't been matched to a track. Generalised the file details component and adds it to the album details screen. * Add sorting by quality * New: MediaServiceTests & MediaRepoTests
This commit is contained in:
parent
74cb2a6f52
commit
4413c7e46c
36 changed files with 1507 additions and 404 deletions
|
@ -4,6 +4,8 @@ using NzbDrone.Core.MediaFiles;
|
|||
using NzbDrone.Core.Qualities;
|
||||
using Lidarr.Http.REST;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using System.Linq;
|
||||
|
||||
namespace Lidarr.Api.V1.TrackFiles
|
||||
{
|
||||
|
@ -16,34 +18,43 @@ namespace Lidarr.Api.V1.TrackFiles
|
|||
public long Size { get; set; }
|
||||
public DateTime DateAdded { get; set; }
|
||||
public QualityModel Quality { get; set; }
|
||||
public int QualityWeight { get; set; }
|
||||
public MediaInfoResource MediaInfo { get; set; }
|
||||
|
||||
public bool QualityCutoffNotMet { get; set; }
|
||||
|
||||
public ParsedTrackInfo AudioTags { get; set; }
|
||||
}
|
||||
|
||||
public static class TrackFileResourceMapper
|
||||
{
|
||||
private static TrackFileResource ToResource(this TrackFile model)
|
||||
private static int QualityWeight(QualityModel quality)
|
||||
{
|
||||
if (quality == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qualityWeight = Quality.DefaultQualityDefinitions.Single(q => q.Quality == quality.Quality).Weight;
|
||||
qualityWeight += quality.Revision.Real * 10;
|
||||
qualityWeight += quality.Revision.Version;
|
||||
return qualityWeight;
|
||||
}
|
||||
|
||||
public static TrackFileResource ToResource(this TrackFile model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
|
||||
return new TrackFileResource
|
||||
{
|
||||
Id = model.Id,
|
||||
|
||||
ArtistId = model.Artist.Value.Id,
|
||||
AlbumId = model.AlbumId,
|
||||
RelativePath = model.Artist.Value.Path.GetRelativePath(model.Path),
|
||||
Path = model.Path,
|
||||
Size = model.Size,
|
||||
DateAdded = model.DateAdded,
|
||||
// SceneName = model.SceneName,
|
||||
Quality = model.Quality,
|
||||
QualityWeight = QualityWeight(model.Quality),
|
||||
MediaInfo = model.MediaInfo.ToResource()
|
||||
//QualityCutoffNotMet
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public static TrackFileResource ToResource(this TrackFile model, NzbDrone.Core.Music.Artist artist, IUpgradableSpecification upgradableSpecification)
|
||||
|
@ -60,8 +71,8 @@ namespace Lidarr.Api.V1.TrackFiles
|
|||
RelativePath = artist.Path.GetRelativePath(model.Path),
|
||||
Size = model.Size,
|
||||
DateAdded = model.DateAdded,
|
||||
//SceneName = model.SceneName,
|
||||
Quality = model.Quality,
|
||||
QualityWeight = QualityWeight(model.Quality),
|
||||
MediaInfo = model.MediaInfo.ToResource(),
|
||||
QualityCutoffNotMet = upgradableSpecification.QualityCutoffNotMet(artist.QualityProfile.Value, model.Quality)
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue