Skip to content

Instantly share code, notes, and snippets.

@Cyanogenoid
Created February 14, 2022 05:02
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 Cyanogenoid/6a638b3ec6de2e41a70ba4a90670a3c3 to your computer and use it in GitHub Desktop.
Save Cyanogenoid/6a638b3ec6de2e41a70ba4a90670a3c3 to your computer and use it in GitHub Desktop.
TouhouWiki plugin for Lyrics Reloaded (Musicbee plugin)
# the name of the provider. this will be shown in MusicBee's settings
name: 'TouhouWiki'
# the loader for this provider: static, search, api
loader: static
# prepare the input
variables:
# filters to apply to the title
title:
type: title
filters:
- [regex, ' ', '_'] # reference the filters of artist
validations:
- [not contains, currently no text]
config:
# the URL to request. {artist}, {album} and {title} are placeholders for the values from the song.
url: "https://en.touhouwiki.net/index.php?title=Lyrics:_{title}&action=edit"
# The regular expression to apply to the content of the website. The pattern must contain a named capturing group called "lyrics" like: (?<lyrics>.+?)
# variables are allowed as well
# pattern: ['\|\s*rom1.*?=(?<lyrics>.+?)(\|\s*eng1|\}\})', s]
pattern: ['\|\s*(kan|rom|eng)1.*?=\s*(?<lyrics>.+?)$', s]
post-filters:
- utf8_encode
- [regex, '\|\s*(kan|rom|eng)1\s*=\s*', "\n\n\n\n", s] # spacing between different languages
- [regex, '\|\s*(kan|rom|eng).*?=\s*', "\n", s] # strip verse markers
- [regex, '{{lang\|en\|(.*?)}}', "$1", s] # remove en annotations
- [regex, '{{alt-ja\|(.*?)\|(.*?)}}', "$1", s] # only take main option, skip alternative
- [regex, '== ?notes ?==.*', "", s] # remove notes
- [regex, '\|[^\n]*', "", s] # remove anything else starting with |
- [regex, '}}.*$', "", s] # remove anything past the closing braces
- trim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment