Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions server/src/scripts/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const GENRE_SEARCH_TAGS: Record<string, string> = {
};

const QUOTA_PER_GENRE = parseInt(process.argv[3], 10) || 10;
const MIN_RELEASES = parseInt(process.argv[4], 10) || 3;

async function mbFetch<T>(url: string): Promise<T | null> {
for (let attempt = 1; attempt <= 4; attempt++) {
Expand Down Expand Up @@ -168,14 +169,16 @@ async function importAlbum(

async function importDecade(startYear: number) {
const endYear = startYear + 9;
console.log(`\n=== Import for ${startYear}-${endYear} (kvote ${QUOTA_PER_GENRE}/sjanger) ===`);

console.log(`\n=== Import for ${startYear}-${endYear} (kvote ${QUOTA_PER_GENRE}/sjanger, min ${MIN_RELEASES} utgaver) ===`);
for (const [genreName, tag] of Object.entries(GENRE_SEARCH_TAGS)) {
console.log(`\n--- ${genreName} (${startYear}-${endYear}) ---`);

const query =
`primarytype:album AND NOT secondarytype:* AND tag:"${tag}" ` +
`AND firstreleasedate:[${startYear} TO ${endYear}]`;
`AND firstreleasedate:[${startYear} TO ${endYear}]` +
`AND releases:[${MIN_RELEASES} TO *]`;


let imported = 0;
let offset = 0;
Expand Down Expand Up @@ -245,4 +248,7 @@ async function main() {
console.log(`\nImport for ${targetYear}-tallet er fullført!`);
}

main();
main().catch((err) => {
console.error('Fatal feil:', err);
process.exit(1);
});