Last active
November 5, 2023 22:49
-
-
Save jsundram/bfc4a66b15d3d5b0aa355b9bf3840a1d to your computer and use it in GitHub Desktop.
Given a cantata number, spit out some useful links, and copy them to a paste-able format suitable for, e.g. quip.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
def main(bwv): | |
bwv0 = '%03d' % int(bwv) | |
links = { | |
# label: (url template, raw?) | |
bwv: ('http://www.bach-cantatas.com/BWV{slug}.htm', True), | |
'allofbach permalink': ('https://www.bachvereniging.nl/en/bwv/bwv-{slug}', True), | |
'translation': ('https://www.emmanuelmusic.org/bach-translations/bwv-{slug}', False), | |
'wikipedia': ('https://en.wikipedia.org/w/index.php?title=BWV_{slug}', True), | |
'note': ('https://www.emmanuelmusic.org/bach-notes/bwv-{slug}', False), | |
} | |
for (label, (link, raw)) in links.items(): | |
slug = bwv if raw else bwv0 | |
url = link.format(slug=slug) | |
print(f" * [{label}]({url})") | |
if __name__ == '__main__': | |
try: | |
main(sys.argv[1]) | |
except IndexError: | |
print("Please provide a cantata BWV number") | |
print("suggested usage: ") | |
print("./linker.py 31 | pbcopy") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment