You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/Lidarr.Api.V1/Tracks/RenameTrackModule.cs

43 lines
1.2 KiB

using System.Collections.Generic;
using Lidarr.Http;
using Lidarr.Http.REST;
using NzbDrone.Core.MediaFiles;
namespace Lidarr.Api.V1.Tracks
{
public class RenameTrackModule : LidarrRestModule<RenameTrackResource>
{
private readonly IRenameTrackFileService _renameTrackFileService;
public RenameTrackModule(IRenameTrackFileService renameTrackFileService)
: base("rename")
{
_renameTrackFileService = renameTrackFileService;
GetResourceAll = GetTracks;
}
private List<RenameTrackResource> GetTracks()
{
int artistId;
if (Request.Query.ArtistId.HasValue)
{
artistId = (int)Request.Query.ArtistId;
}
else
{
throw new BadRequestException("artistId is missing");
}
if (Request.Query.albumId.HasValue)
{
var albumId = (int)Request.Query.albumId;
return _renameTrackFileService.GetRenamePreviews(artistId, albumId).ToResource();
}
return _renameTrackFileService.GetRenamePreviews(artistId).ToResource();
}
}
}