mirror of
https://github.com/Readarr/Readarr
synced 2025-12-19 14:56:04 +01:00
59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using NzbDrone.Common.Extensions;
|
|
using NzbDrone.Core.Parser;
|
|
using Lidarr.Api.V3.Albums;
|
|
using Lidarr.Api.V3.Artist;
|
|
using Lidarr.Http;
|
|
|
|
namespace Lidarr.Api.V3.Parse
|
|
{
|
|
public class ParseModule : LidarrRestModule<ParseResource>
|
|
{
|
|
private readonly IParsingService _parsingService;
|
|
|
|
public ParseModule(IParsingService parsingService)
|
|
{
|
|
_parsingService = parsingService;
|
|
|
|
GetResourceSingle = Parse;
|
|
}
|
|
|
|
private ParseResource Parse()
|
|
{
|
|
var title = Request.Query.Title.Value as string;
|
|
var path = Request.Query.Path.Value as string;
|
|
var parsedEpisodeInfo = path.IsNotNullOrWhiteSpace() ? Parser.ParseMusicPath(path) : Parser.ParseMusicTitle(title);
|
|
|
|
if (parsedEpisodeInfo == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return new ParseResource
|
|
{
|
|
Title = title,
|
|
ParsedAlbumInfo = parsedEpisodeInfo
|
|
};
|
|
|
|
//var remoteEpisode = null //_parsingService.Map(parsedEpisodeInfo, 0, 0);
|
|
|
|
//if (remoteEpisode != null)
|
|
//{
|
|
// return new ParseResource
|
|
// {
|
|
// Title = title,
|
|
// ParsedAlbumInfo = remoteEpisode.ParsedEpisodeInfo,
|
|
// Artist = remoteEpisode.Series.ToResource(),
|
|
// Albums = remoteEpisode.Episodes.ToResource()
|
|
// };
|
|
//}
|
|
//else
|
|
//{
|
|
// return new ParseResource
|
|
// {
|
|
// Title = title,
|
|
// ParsedAlbumInfo = parsedEpisodeInfo
|
|
// };
|
|
//}
|
|
}
|
|
}
|
|
}
|