[musicbrainz-works] Fixes for JASRAC and NexTone codes

This commit is contained in:
SuperSaltyGamer
2024-02-22 21:23:32 +02:00
parent 720953bc26
commit ffe21775ef
13 changed files with 720 additions and 371 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

17
dist/vgmdb.user.js vendored

File diff suppressed because one or more lines are too long

818
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -10,12 +10,13 @@
"dependencies": {
"handsontable": "^13.0.0",
"jszip": "^3.9.1",
"opencv-wasm": "^4.3.0-10",
"xml-formatter": "^3.2.0"
},
"devDependencies": {
"@types/tampermonkey": "^4.0.10",
"typescript": "^5.1.6",
"vite": "^4.4.7"
"@types/tampermonkey": "^5.0.2",
"typescript": "^5.3.3",
"vite": "^5.1.4"
},
"scripts": {
"start": "node out/scripts/build.js",

View File

@@ -14,13 +14,16 @@ interface MessageContainer<T> {
interface Work {
name: string | null
iswc: string | null
nextone: string | null
codes: {
external: boolean
jasrac: string | null
nextone: string | null
}
lyricists: string[]
composers: string[]
arrangers: string[]
publishers: string[]
sources: string[]
workCodes: boolean,
context: {
tokens: string[]
}

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @namespace ame-musicbrainz-works
// @name Ame (MusicBrainz - Works)
// @version 0.3.0
// @version 0.3.1
// @author SuperSaltyGamer
// @run-at document-end
// @match https://musicbrainz.org/*

View File

@@ -39,7 +39,7 @@ export async function onIswcNetSearchPage() {
moreEl.after(fromHTML(`<div style="padding: .5rem;">Install <a href="https://musicbrainz.org/doc/Guides/Userscripts#Userscripts:_Works">Bulk copy-paste work codes</a> for better integration.</div>`));
} else {
copyEl.click();
work.workCodes = true;
work.codes.external = true;
}
work.sources.push(location.href);

View File

@@ -52,20 +52,25 @@ export function onMincWorkPage() {
const iswc = pathSelector(document, "//h3/text()[.!='-']")?.nodeValue?.replaceAll(" ", "") || null;
const jasrac = pathSelector(document, "//a[@href='#jasrac']/following-sibling::*/span[2][.!='']")?.innerText?.trim() || null;
const nextone = pathSelector(document, "//a[@href='#nextone']/following-sibling::*/span[2][.!='']")?.innerText?.trim() || null;
const lyricists = new Set(pathSelectorAll(document, "//td[contains(., '作詞')]/parent::tr/*[2]").map(el => el.innerText.trim()).filter(Boolean));
const composers = new Set(pathSelectorAll(document, "//td[contains(., '作曲')]/parent::tr/*[2]").map(el => el.innerText.trim()).filter(Boolean));
const arrangers = new Set(pathSelectorAll(document, "//td[contains(., '編曲')]/parent::tr/*[2]").map(el => el.innerText.trim()).filter(Boolean));
const publishers = new Set(pathSelectorAll(document, "//td[contains(., '出版者')]/parent::tr/*[2]").map(el => el.innerText.trim()).filter(Boolean));
const lyricists = pathSelectorAll(document, "//td[contains(., '作詞')]/parent::tr/*[2]").map(getCredit).filter(Boolean);
const composers = pathSelectorAll(document, "//td[contains(., '作曲')]/parent::tr/*[2]").map(getCredit).filter(Boolean);
const arrangers = pathSelectorAll(document, "//td[contains(., '編曲')]/parent::tr/*[2]").map(getCredit).filter(Boolean);
const publishers = pathSelectorAll(document, "//td[contains(., '出版者')]/parent::tr/*[2]").map(getCredit).filter(Boolean);
if (iswc) work.iswc = iswc;
if (nextone) work.nextone = nextone;
work.lyricists = Array.from(lyricists);
work.composers = Array.from(composers);
work.arrangers = Array.from(arrangers);
work.publishers = Array.from(publishers);
if (jasrac) work.codes.jasrac = jasrac;
if (nextone) work.codes.nextone = nextone;
work.lyricists = lyricists;
work.composers = composers;
work.arrangers = arrangers;
work.publishers = publishers;
work.sources.push(location.href);
work.sources = Array.from(new Set(work.sources));
beep(50, 1000);
});
}
function getCredit(el: HTMLElement): string {
return el.firstChild?.textContent?.split("\n")[0]?.replace(/\s*\/\s*$/, "") ?? "";
}

View File

@@ -28,13 +28,16 @@ export async function onMusicBrainzEditWorkPage() {
await setBusValue(MessageType.Work, {
name: nameEl.value || null,
iswc: iswcEl.value || null,
nextone: null,
codes: {
external: false,
jasrac: null,
nextone: null
},
lyricists: [],
composers: [],
arrangers: [],
publishers: [],
sources: [],
workCodes: false,
context: {
tokens: Array.from(getArtistsOnPage((parent === window ? document.body : parent.document.body)))
}
@@ -49,10 +52,11 @@ export async function onMusicBrainzEditWorkPage() {
done = true;
if (work.iswc) setReactInputValue(iswcEl, work.iswc);
if (work.nextone) setWorkCode("nextone", work.nextone);
if (work.codes.jasrac) setWorkCode("jasrac", work.codes.jasrac);
if (work.codes.nextone) setWorkCode("nextone", work.codes.nextone);
if (work.sources.length) noteEl.value = `Filled out with Ame (MusicBrainz - Works):\n${work.sources.join("\n")}\n`;
if (work.workCodes) {
if (work.codes.external) {
const pasteWorkCodesEl = document.querySelector<HTMLButtonElement>("#ROpdebee_MB_Paste_Work");
pasteWorkCodesEl?.click();
}

View File

@@ -5,6 +5,7 @@
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"strict": true,
"skipLibCheck": true,
"noEmit": true
}
}

View File

@@ -4,6 +4,7 @@
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"skipLibCheck": true,
"outDir": "out/scripts/"
},
"include": [