fix(amazon): emit external Amazon URL with region domain (#2330)
This commit is contained in:
@@ -23,6 +23,7 @@ import org.jsoup.nodes.Node;
|
||||
import org.jsoup.nodes.TextNode;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
@@ -323,6 +324,7 @@ public class AmazonBookParser implements BookParser, DetailedMetadataProvider {
|
||||
|
||||
return BookMetadata.builder()
|
||||
.provider(MetadataProvider.Amazon)
|
||||
.externalUrl(buildExternalUrl(amazonBookId))
|
||||
.title(titleInfo.title())
|
||||
.subtitle(titleInfo.subtitle())
|
||||
.authors(new ArrayList<>(getAuthors(doc)))
|
||||
@@ -345,6 +347,15 @@ public class AmazonBookParser implements BookParser, DetailedMetadataProvider {
|
||||
.build();
|
||||
}
|
||||
|
||||
private String buildExternalUrl(String asin) {
|
||||
String baseUri = getBaseURI();
|
||||
|
||||
return UriComponentsBuilder.fromUriString(baseUri)
|
||||
.path("/dp/{asin}")
|
||||
.build(asin)
|
||||
.toString();
|
||||
}
|
||||
|
||||
private String buildQueryUrl(FetchMetadataRequest fetchMetadataRequest, Book book) {
|
||||
String baseURI = getBaseURI();
|
||||
String isbnCleaned = ParserUtils.cleanIsbn(fetchMetadataRequest.getIsbn());
|
||||
|
||||
Reference in New Issue
Block a user