コード例 #1
0
        private async Task <SearchAlbumViewModel> MapIntoAlbumVm(AlbumLookup a, LidarrSettings settings)
        {
            var vm = new SearchAlbumViewModel
            {
                ForeignAlbumId = a.foreignAlbumId,
                Monitored      = a.monitored,
                Rating         = a.ratings?.value ?? 0m,
                ReleaseDate    = a.releaseDate,
                Title          = a.title,
                Disk           = a.images?.FirstOrDefault(x => x.coverType.Equals("disc"))?.url?.ToHttpsUrl(),
                Genres         = a.genres
            };

            if (a.artistId > 0)
            {
                //TODO THEY HAVE FIXED THIS IN DEV
                // The JSON is different for some stupid reason
                // Need to lookup the artist now and all the images -.-"
                var artist = await _lidarrApi.GetArtist(a.artistId, settings.ApiKey, settings.FullUri);

                vm.ArtistName      = artist.artistName;
                vm.ForeignArtistId = artist.foreignArtistId;
            }
            else
            {
                vm.ForeignArtistId = a.artist?.foreignArtistId;
                vm.ArtistName      = a.artist?.artistName;
            }

            vm.Cover = a.images?.FirstOrDefault(x => x.coverType.Equals("cover"))?.url?.ToHttpsUrl();
            if (vm.Cover.IsNullOrEmpty())
            {
                vm.Cover = a.remoteCover;
            }

            await Rules.StartSpecificRules(vm, SpecificRules.LidarrAlbum);

            await RunSearchRules(vm);

            return(vm);
        }
コード例 #2
0
        public async Task Should_Be_Monitored_And_Fully_Available()
        {
            ContextMock.Setup(x => x.GetAll()).Returns(new List <LidarrAlbumCache>
            {
                new LidarrAlbumCache
                {
                    ForeignAlbumId  = "abc",
                    PercentOfTracks = 100
                }
            }.AsQueryable());
            var request = new SearchAlbumViewModel {
                ForeignAlbumId = "abc"
            };
            var result = await Rule.Execute(request, string.Empty);

            Assert.True(result.Success);
            Assert.False(request.Approved);
            Assert.True(request.Monitored);
            Assert.That(request.PartiallyAvailable, Is.EqualTo(false));
            Assert.That(request.FullyAvailable, Is.EqualTo(true));
        }
コード例 #3
0
        public IHttpActionResult Search([FromUri] SearchAlbumViewModel searchData)
        {
            var albums = _service.SearchAlbum(searchData);

            return(Ok(albums));
        }