Exemplo n.º 1
0
 public void GetArtistByNameAndWebsite(ArtistDto artistDto)
 {
     var query = string.Format(SparqlResources.SearchArtistByNameAndWebsite, artistDto.Name.ToLower(),
         artistDto.Wiki?.ToLower(), artistDto.Website?.ToLower());
     var resultSet = sparqlRemoteEndpoint.QueryWithResultSet(query);
     DbpediaHelper.UpdateArtistData(artistDto, resultSet);
 }
Exemplo n.º 2
0
 public static ArtistDto CreateFindWebsiteResponse(JObject response, ArtistDto artistDto)
 {
     var result = (response[EchonestResources.Response] as JObject)[EchonestResources.Urls] as JObject;
     if (result != null)
         artistDto.Website = result[EchonestResources.OfficialWebsite]?.ToString();
         artistDto.Wiki = result[EchonestResources.Wiki]?.ToString();
     return artistDto;
 }
Exemplo n.º 3
0
 public static ArtistDto CreateSearchArtistResponse(JObject response)
 {
     ArtistDto artist = null;
     var result = ((response[EchonestResources.Response] as JObject)[EchonestResources.Artists] as JArray)?.First;
     if (result != null)
         artist = new ArtistDto
         {
             EchonestId = result[EchonestResources.Id].ToString(),
             EchonestName = result[EchonestResources.Name].ToString()
         };
     return artist;
 }
Exemplo n.º 4
0
        public static void UpdateArtistData(ArtistDto artistDto, SparqlResultSet resultSet)
        {
            var result = resultSet.Results.FirstOrDefault();
            if (result == null) return;

            artistDto.Id = result.Value(SparqlResources.Artist).ToString();
            if (result.HasValue(SparqlResources.Wiki))
            {
                artistDto.Wiki = result.Value(SparqlResources.Wiki)?.ToString();
            }
            if (result.HasValue(SparqlResources.Homepage))
            {
                artistDto.Website = result.Value(SparqlResources.Homepage)?.ToString();
            }
            if (result.HasValue(SparqlResources.Thumbnail))
            {
                artistDto.Thumbnail = result.Value(SparqlResources.Thumbnail)?.ToString();
            }
            if (result.HasValue(SparqlResources.Abstract))
            {
                artistDto.Abstract = result.Value(SparqlResources.Abstract)?.ToString();
            }
        }
Exemplo n.º 5
0
 public async Task FindWebsite(ArtistDto artistDto)
 {
     var response = await EchonestHelper.GetWebsiteResponse(artistDto.EchonestId);
     EchonestHelper.CreateFindWebsiteResponse(response, artistDto);
 }