#!/bin/mksh # -*- mode: sh -*- #- # Copyright © 2021, 2022 # mirabilos # # Provided that these terms and disclaimer and all copyright notices # are retained or reproduced in an accompanying document, permission # is granted to deal in this work without restriction, including un‐ # limited rights to use, publicly perform, distribute, sell, modify, # merge, give away, or sublicence. # # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to # the utmost extent permitted by applicable law, neither express nor # implied; without malicious intent or gross negligence. In no event # may a licensor, author or contributor be held liable for indirect, # direct, other damage, loss, or other issues arising in any way out # of dealing in the work, even if advised of the possibility of such # damage or existence of a defect, except proven that it results out # of said person’s immediate fault when using the work as intended. #- # Prepare files for uploading to free-scores.com unset LANGUAGE export LC_ALL=C.UTF-8 bn=$(realpath "$1") cd "$(realpath "$0/..")/../.." top=$(realpath .) fn=${bn#"$top/"} fn=${fn%.msc[xz]} getmeta() { xmlstarlet <".git/t-music/$fn.meta.xml" sel -T -t \ -c "/MirScoreMetadata/$1" -n } getmtag() { getmeta "score/metaTag[@name=\"$1\"]" } getmtags() { xmlstarlet <".git/t-music/$fn.meta.xml" sel -T -t \ -m "/MirScoreMetadata/score/metaTag[starts-with(@name, \"$1\")]" \ -o '<' -v @name -o '>=' -c . -n -b } getjson() { jq <".git/t-music/$fn.metajson" -r "$@" } mksh -T- -c 'firefox-esr https://www.free-scores.com/espace-membres-uk/add_partitions.php' set -- $(getmtag com:tags) lang= key= for x in "$@"; do x=${x%,} case $x { (Church\ Slavonic|English|French|German|Italian|Latin|Nguni|Spanish|Swedish|Ukrainian|Welsh) lang+=\ $x ;; (*-Dur|*-Moll) key+=\ $x ;; } done print 'Type: Arrangement and transcription (most likely)' title=$(getmtag com:title) title=${title#* — } print -r -- Title: "$(getjson .title)" [[ -z $title ]] || print -r -- "$title" print -r -- Subtitle: "$(getjson .subtitle)" getjson '.textFramesData.titles + .textFramesData.subtitles' getmtags fsc: print -r -- Tonalité: "$(getjson '["C♭","G♭","D♭","A♭","E♭","B♭","F","C","G","D","A","E","B","F♯","C♯"][.keysig+7]+" major (or the corresponding minor)"')$key" print -r -- Composer: "$(getmtag composer)" print -r -- Arranger: "$(getmtag arranger)" print -r -- "[✓] If self is the publisher, check the case" print -r -- Instrument: "$(getjson '[.parts[].instrumentId] | join("; ")')" print -r -- "Style: A cappella? Religious? Hymn? Traditional? Folk? Early 20th century? Opera?" print -r -- " 500-Medieval-1400-Renaissance-1600-Baroque1750<1730-Classical1820<1780-Romantic1910" print -r -- "Date of composition: (see composer/arranger)" # Latin-1 seems to be usable as-is, don’t mangle © and Ü cop=$(getmtag copyright | sed \ -e 's/gemeinfrei/Public Domain/g' \ -e 's/MuseScore-Notensatz/MuseScore engraving/g' \ -e 's/Notensatz/engraving/g' \ -e 's/\/where applicable/g' \ -e 's/\/source/g' \ -e 's/-Arrangement/ arrangement/g' \ -e 's/Chorauszug/choral excerpt/g' \ -e 's/ und / and /g' \ -e 's/ von / by /g' \ -e 's/\/lyrics/g' \ -e 's/\/music/g' \ -e 's/ / /g' \ -e 's/‐/-/g' \ -e 's/‑/-/g' \ -e 's/‒/-/g' \ -e 's/–/-/g' \ -e 's/—/-/g' \ -e "s/’/'/g" \ -e 's/€/EUR/g' \ -e 's/№/No./g' \ -e 's/℗/(P)/g' \ -e 's/Ⓕ/(Copyfree)/g' \ -e 's/⓪/(CC0)/g' \ -e 's/🄯/(Copyleft)/g' \ ) # -e 's/C⃠/(PD)/g' \ # -e 's/F⃠/(unpermissive)/g' \ # -e 's/€⃠/(non-commercial)/g' \ print -r -- Copyright: "${cop//$'\n'/; }" print Description: desc=$(getmtag com:description) print -r -- "$desc" | grep -v 'Also online.*[/.]free-scores\.com/sheetmusic?p=' print -r -- Author, songwriter: "$(getmtag lyricist)" print -r -- Language: ${lang:-'?'} xmlstarlet <".git/t-music/$fn.meta.xml" sel -T -t \ -m '//lyrics/part[1]/staff' \ -o '‣ Lyrics, staff ' -v @idx -o ' (' -v @track -o ')' -n \ -m verse \ -i '@voice != 1' \ -o '(voice ' -v @voice -o ' verse #' -v @nr -o ') ' \ -b \ -v . -n \ -b \ -b if [[ $desc = *IMSLP* ]]; then desc=$(print -r -- "$desc" | grep -o 'IMSLP[: ]*#[0-9]\{1,\}' | head -1) desc=${desc#*'#'} print Source/Website: IMSLP \#$desc curl -s --http1.1 --head \ "https://imslp.org/index.php?title=Special:ReverseLookup&action=submit&indexsearch=$desc" | \ sed --posix -n '/^Location: *[htps]*[:/]*/s!!https://!p' fi print '「SAVE AND CONTINUE TO STEP 2」' tit=${fn##*/} print -r "PDF Title: $tit (A4 PDF)" print -r "MP3 Title: $tit (MuseScore MP3)" print -r 'Digital (Interpreted by computer, midi file converted in MP3).' print -r "MIDI Titre: $tit (MIDI)" print '「CONTINUE TO STEP 3」' print '「SUBMIT FOR VALIDATION」'