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

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
*.properties *.properties
.DS_Store .DS_Store
*.csv *.csv
/vendor

View File

@ -66,6 +66,21 @@ function renderTable(records, sortField) {
function apiResponseParsing(record) { function apiResponseParsing(record) {
record.sortName = titleCleaner(record.name); 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; return record;
} }
@ -101,28 +116,16 @@ function searchCleaner(str) {
.replaceAll(" ", ""); .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({ function RecordTemplate({
name, name,
artists, artists,
coverURL, coverURL,
description,
format, format,
genre, genre,
identifier, identifier,
label, label,
year, year,
discogsURL,
}) { }) {
return `${coverURL ? `<img src="${coverURL}"/>` : ""} return `${coverURL ? `<img src="${coverURL}"/>` : ""}
<h1>${name}</h1> <h1>${name}</h1>
@ -130,8 +133,13 @@ function RecordTemplate({
<span>${identifier}</span><br/> <span>${identifier}</span><br/>
<span>${genre}, ${label}, ${year}</span><br/> <span>${genre}, ${label}, ${year}</span><br/>
<span>${format}</span> <span>${format}</span>
<div class="description"> <div>
<p>${description}</p> <a
target="_blank"
href="${discogsURL}"
>
Data provided by Discogs.
</a>
</div>`; </div>`;
} }