Skip to content

Instantly share code, notes, and snippets.

@jsundram
Last active November 5, 2023 22:49
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 jsundram/bfc4a66b15d3d5b0aa355b9bf3840a1d to your computer and use it in GitHub Desktop.
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.
#!/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