[musicbrainz-works] Obtain arrangers from minc

This commit is contained in:
SuperSaltyGamer
2024-02-09 10:42:19 +02:00
parent 4b90185b19
commit bf9433150d
5 changed files with 12 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@@ -17,6 +17,7 @@ interface Work {
nextone: string | null
lyricists: string[]
composers: string[]
arrangers: string[]
publishers: string[]
sources: string[]
workCodes: boolean,

View File

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

View File

@@ -54,12 +54,14 @@ export function onMincWorkPage() {
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));
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);
work.sources.push(location.href);
work.sources = Array.from(new Set(work.sources));

View File

@@ -31,6 +31,7 @@ export async function onMusicBrainzEditWorkPage() {
nextone: null,
lyricists: [],
composers: [],
arrangers: [],
publishers: [],
sources: [],
workCodes: false,
@@ -56,8 +57,9 @@ export async function onMusicBrainzEditWorkPage() {
pasteWorkCodesEl?.click();
}
for (const composer of work.composers) await addRelationship("artist", "composed / composer", composer);
for (const lyricist of work.lyricists) await addRelationship("artist", "lyrics / lyricist", lyricist);
for (const composer of work.composers) await addRelationship("artist", "composed / composer", composer);
for (const arranger of work.arrangers) await addRelationship("artist", "arranged / arranger", arranger);
for (const publisher of work.publishers) await addRelationship("label", "published / publisher", publisher);
}
@@ -112,7 +114,7 @@ async function addRelationship(relatedType: string, relationshipType: string, va
const relationshipTypeEl = dialogEl.querySelector<HTMLInputElement>("input.relationship-type")!;
setReactInputValue(relationshipTypeEl, relationshipType);
dialogEl.querySelector<HTMLLIElement>("li.option-item")!.click();
pathSelector<HTMLLIElement>(dialogEl, `//li[contains(@class, 'option-item') and contains(., '${relationshipType}')]`)!.click();
const targetEl = dialogEl.querySelector<HTMLInputElement>(".relationship-target input")!;
setReactInputValue(targetEl, value);