mirror of
https://github.com/sphildreth/roadie
synced 2024-11-10 14:54:11 +00:00
Subsonic API work
This commit is contained in:
parent
b4c05efd88
commit
45451f445d
4 changed files with 13 additions and 6 deletions
|
@ -107,8 +107,6 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetArtist(SubsonicRequest request)
|
||||
{
|
||||
var postedForm = Request.Form.FirstOrDefault();
|
||||
request.id = request.id ?? (postedForm.Key == "id" ? postedForm.Value.FirstOrDefault() : string.Empty);
|
||||
var result = await this.SubsonicService.GetArtist(request, null);
|
||||
return this.BuildResponse(request, result, "artist");
|
||||
}
|
||||
|
@ -478,7 +476,7 @@ namespace Roadie.Api.Controllers
|
|||
modelDictionary["callback"] = queryDictionary.ContainsKey("callback") ? queryDictionary["callback"].First() : null;
|
||||
modelDictionary["f"] = queryDictionary.ContainsKey("f") ? queryDictionary["f"].First() : null;
|
||||
modelDictionary["fromYear"] = queryDictionary.ContainsKey("fromYear") ? SafeParser.ToNumber<int?>(queryDictionary["fromYear"].First()) : null;
|
||||
modelDictionary["Genre"] = queryDictionary.ContainsKey("genre") ? queryDictionary["genre"].First() : null;
|
||||
modelDictionary["genre"] = queryDictionary.ContainsKey("genre") ? queryDictionary["genre"].First() : null;
|
||||
modelDictionary["id"] = queryDictionary.ContainsKey("id") ? queryDictionary["id"].First() : null;
|
||||
modelDictionary["musicFolderId"] = queryDictionary.ContainsKey("musicFolderId") ? SafeParser.ToNumber<int?>(queryDictionary["musicFolderId"].First()) : null;
|
||||
modelDictionary["offset"] = queryDictionary.ContainsKey("offset") ? SafeParser.ToNumber<int?>(queryDictionary["offset"].First()) : null;
|
||||
|
@ -497,7 +495,7 @@ namespace Roadie.Api.Controllers
|
|||
modelDictionary["v"] = queryDictionary.ContainsKey("v") ? queryDictionary["v"].First() : null;
|
||||
|
||||
// Setup model dictionary from Posted Body values
|
||||
if (!bindingContext.HttpContext.Request.Method.Equals("GET", StringComparison.OrdinalIgnoreCase))
|
||||
if (!bindingContext.HttpContext.Request.Method.Equals("GET", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(bindingContext.HttpContext.Request.ContentType))
|
||||
{
|
||||
var formCollection = bindingContext.HttpContext.Request.Form;
|
||||
if (formCollection != null && formCollection.Any())
|
||||
|
|
|
@ -128,12 +128,21 @@ namespace Roadie.Api.Services
|
|||
select a.Id
|
||||
).ToArray();
|
||||
}
|
||||
int[] genreReleaseIds = new int[0];
|
||||
if(!string.IsNullOrEmpty(request.FilterByGenre))
|
||||
{
|
||||
genreReleaseIds = (from rg in this.DbContext.ReleaseGenres
|
||||
join g in this.DbContext.Genres on rg.GenreId equals g.Id
|
||||
where g.Name == request.FilterByGenre
|
||||
select rg.ReleaseId).ToArray();
|
||||
}
|
||||
var result = (from r in this.DbContext.Releases.Include("Artist")
|
||||
join a in this.DbContext.Artists on r.ArtistId equals a.Id
|
||||
where (request.FilterMinimumRating == null || r.Rating >= request.FilterMinimumRating.Value)
|
||||
where (request.FilterToArtistId == null || r.Artist.RoadieId == request.FilterToArtistId)
|
||||
where (request.FilterToCollectionId == null || collectionReleaseIds.Contains(r.Id))
|
||||
where (!request.FilterFavoriteOnly || favoriteReleaseIds.Contains(r.Id))
|
||||
where (request.FilterByGenre == null || genreReleaseIds.Contains(r.Id))
|
||||
where (request.FilterFromYear == null || r.ReleaseDate != null && r.ReleaseDate.Value.Year <= request.FilterFromYear)
|
||||
where (request.FilterToYear == null || r.ReleaseDate != null && r.ReleaseDate.Value.Year >= request.FilterToYear)
|
||||
where (request.FilterValue == "" || (r.Title.Contains(request.FilterValue) || r.AlternateNames.Contains(request.FilterValue)))
|
||||
|
|
|
@ -109,6 +109,7 @@ namespace Roadie.Library.Models.Pagination
|
|||
public bool FilterTopPlayedOnly { get; set; }
|
||||
public int? FilterFromYear { get; internal set; }
|
||||
public int? FilterToYear { get; internal set; }
|
||||
public string FilterByGenre { get; internal set; }
|
||||
|
||||
public PagedRequest()
|
||||
{ }
|
||||
|
|
|
@ -275,8 +275,7 @@ namespace Roadie.Library.Models.ThirdPartyApi.Subsonic
|
|||
break;
|
||||
|
||||
case ListType.ByGenre:
|
||||
pagedRequest.Sort = "Genre.Text";
|
||||
pagedRequest.Order = "ASC";
|
||||
pagedRequest.FilterByGenre = this.Genre;
|
||||
break;
|
||||
|
||||
case ListType.ByYear:
|
||||
|
|
Loading…
Reference in a new issue