Skip to content

Instantly share code, notes, and snippets.

@kellnerd
Last active November 17, 2022 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellnerd/62a651295367645fa68955c57a6459eb to your computer and use it in GitHub Desktop.
Save kellnerd/62a651295367645fa68955c57a6459eb to your computer and use it in GitHub Desktop.
function addVocalAttribute(id, creditedAs) {
MB.relationshipEditor.relationshipDialogDispatch({
type: 'update-attribute',
action: {
type: 'update-multiselect-attribute',
// rootKey,
action: {
type: 'update-value-autocomplete',
// valueKey,
action: {
type: 'select-item',
item: {
id,
// ...
},
},
},
},
});
if (creditedAs) {
MB.relationshipEditor.relationshipDialogDispatch({
type: 'update-attribute',
action: {
type: 'update-multiselect-attribute',
// rootKey,
action: {
type: 'set-value-credit',
// valueKey,
creditedAs,
},
},
});
}
}
/********************************************************************************************************************
* Equivalent code to add the rel without opening a dialog. Currently causes a sentry error... *
* Based on https://github.com/kellnerd/musicbrainz-scripts/blob/beta/src/relationship-editor/createRelationship.js *
********************************************************************************************************************/
/**
* @param {Object} [options]
* @param {ArtistT} options.artist The performing artist.
* @param {string} [options.roleName] Credited name of the voice actor's role (optional).
* @param {string} [options.artistCredit] Credited name of the performing artist (optional).
*/
function createVoiceActorRelationship({ artist, roleName, artistCredit }) {
createRelationship({
target: artist,
linkTypeID: 60, // performance -> performer -> vocals
entity0_credit: artistCredit,
attributes: [{
type: { gid: 'd3a36e62-a7c4-4eb9-839f-adfebe87ac12' },
typeID: 561,
typeName: 'spoken vocals',
credited_as: roleName,
}],
});
}
@kellnerd
Copy link
Author

kellnerd commented Nov 14, 2022

Setting attributes in a relationship dialog will be simplified by metabrainz/musicbrainz-server#2733.
Now I only have to figure out why createVoiceActorRelationship does not work as expected....

@kellnerd
Copy link
Author

I have created a separate gist with a complete code sample for the second issue:
https://gist.github.com/kellnerd/dc39236e58d5fb39b41a53a883eacb09

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment