wrap up initial discogs work

This commit is contained in:
David 2022-04-02 17:21:02 -04:00
parent 8cff0ec6ab
commit 781d96ca14
2 changed files with 25 additions and 16 deletions

3
.gitignore vendored
View File

@ -2,4 +2,5 @@
/manager
*.properties
.DS_Store
*.csv
*.csv
/vendor

View File

@ -66,6 +66,21 @@ function renderTable(records, sortField) {
function apiResponseParsing(record) {
record.sortName = titleCleaner(record.name);
record.artists = record.artists.map((artist) => {
return artist.replace(/ \([0-9]+\)$/, "");
});
record.sortArtist = record.artists.reduce((acc, curr) => {
return (
acc +
curr
.replace(/^(An?|The)\s/i, "")
.toLowerCase()
.replaceAll('"', "")
.replaceAll(":", "")
.replaceAll("'", "")
.replaceAll(" ", "")
);
}, "");
return record;
}
@ -101,28 +116,16 @@ function searchCleaner(str) {
.replaceAll(" ", "");
}
// AlbumName string `json:"name"`
// Artists []string `json:"artists"`
// SortArtist string `json:"sortArtist"`
// Identifier string `json:"identifier"`
// Format string `json:"format"`
// Genre string `json:"genre"`
// Label string `json:"label"`
// Year string `json:"year"`
// Description string `json:"description"`
// CoverURL string `json:"coverURL"`
// DiscogsURL string `json:"discogsURL"`
function RecordTemplate({
name,
artists,
coverURL,
description,
format,
genre,
identifier,
label,
year,
discogsURL,
}) {
return `${coverURL ? `<img src="${coverURL}"/>` : ""}
<h1>${name}</h1>
@ -130,8 +133,13 @@ function RecordTemplate({
<span>${identifier}</span><br/>
<span>${genre}, ${label}, ${year}</span><br/>
<span>${format}</span>
<div class="description">
<p>${description}</p>
<div>
<a
target="_blank"
href="${discogsURL}"
>
Data provided by Discogs.
</a>
</div>`;
}