Last active
July 26, 2023 21:02
-
-
Save reisir/2757c292fdf4063ba6339691d3aa03ce to your computer and use it in GitHub Desktop.
Title Extraction for Rainmeter, removing duplicate or extraneous information from media titles
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
; Title Extraction snippet from reisir/mondtholomew | |
; Useful when the "title" of the media has duplicate or unnecessary information. | |
; For example, the song "Fake Friends" posted on the YouTube channel "MANON" has the title "MANON / Fake Friends (Music Video)" | |
; Title Extraction removes the duplicated artist name and "(Music Video)" from the information displayed | |
; [MeasureTitle] reports the following values when Title Extraction is disabled / enabled: | |
; TitleExtraction=0 -> MANON - MANON / Fake Friends (Music Video) | |
; TitleExtraction=1 -> MANON - Fake Friends | |
[Variables] | |
; ███████╗███████╗████████╗████████╗██╗███╗ ██╗ ██████╗ ███████╗ | |
; ██╔════╝██╔════╝╚══██╔══╝╚══██╔══╝██║████╗ ██║██╔════╝ ██╔════╝ | |
; ███████╗█████╗ ██║ ██║ ██║██╔██╗ ██║██║ ███╗███████╗ | |
; ╚════██║██╔══╝ ██║ ██║ ██║██║╚██╗██║██║ ██║╚════██║ | |
; ███████║███████╗ ██║ ██║ ██║██║ ╚████║╚██████╔╝███████║ | |
; ╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ | |
; You should provide your users access to these variables | |
; Title Extraction toggle variable | |
TitleExtraction=1 | |
; Removes matched featuring information | |
RemoveFeaturing=0 | |
; Removes " - Topic" and "VEVO" from artist names | |
SanitizeArtist=1 | |
; What "featuring", "feat." and "ft." are replaced with | |
__Featuring=ft. | |
; What to display between Artist and Title (not used in extraction) | |
__ArtistTitleSeparator=#CRLF# | |
; Default measure values | |
__ArtistNotAvailable=N/A | |
__TitleNotAvailable=N/A | |
; ██╗███╗ ██╗████████╗███████╗██████╗ ███╗ ██╗ █████╗ ██╗ | |
; ██║████╗ ██║╚══██╔══╝██╔════╝██╔══██╗████╗ ██║██╔══██╗██║ | |
; ██║██╔██╗ ██║ ██║ █████╗ ██████╔╝██╔██╗ ██║███████║██║ | |
; ██║██║╚██╗██║ ██║ ██╔══╝ ██╔══██╗██║╚██╗██║██╔══██║██║ | |
; ██║██║ ╚████║ ██║ ███████╗██║ ██║██║ ╚████║██║ ██║███████╗ | |
; ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝ | |
; You should place these at the end of or outside of the user editable variables. | |
; I usually keep these with the measures in a separate file | |
; Artist - Title separators. I've seen all of these used on YouTube. | |
Separators=[\-|\x|\×|\•|\–|\\|\/|\|] | |
SeparatorPattern=\s?#Separators#?\s? | |
; Escape the artist name cause sometimes people like to put $#!@?$ and whitespace in their names | |
Artist=[MeasureArtist:EscapeRegExp] | |
ft=[ft:EscapeRegExp] | |
; Parenthesis | |
Open=\(\[\{\【 | |
Close=\)\]\}\】 | |
; Extraneous information matches | |
Extra=video|audio|vi[s|z]uali[s|z]er | |
; Title Extraction stages | |
RemoveArtist="(?i)^#Artist##SeparatorPattern#|#SeparatorPattern##Artist#$":"" | |
RemoveAudioVideo="(?i)\s?[#Open#][^#Open#]*?(?:#Extra#)[^#Close#]*?[#Close#]\s?|\s?(?:official|music)\s?(?:official|music)?\s?(?:#Extra#)\s?":"" | |
StandardizeFeaturing="(?i)^[\,|\x|\&]\s?|^t\.\s|ft\.\s?|feat\.\s?|featuring\s?":"#__Featuring# " | |
MoveFeaturingToEnd="^(#ft#.*)\s?#Separators#\s?(.+?)$":"\2 \1","^#ft#\s?":"" | |
RemoveFeaturingParenthesis="[#Open#](#ft#.*)[#Close#]":"\1" | |
NotAvailable="":"[TitleNotAvailable]" | |
RemoveFeaturing1="#ft#.*":"" | |
RemoveFeaturing0="":"" | |
; Artist Sanitization stages | |
RemoveTopic="(?i)\s?-\s?topic":"" | |
RemoveVEVO="(?i)\s?VEVO":"" | |
; Build the subsitutes | |
Substitute1="#RemoveArtist#","#RemoveAudioVideo#","#StandardizeFeaturing#","#MoveFeaturingToEnd#","#RemoveFeaturingParenthesis#","[#RemoveFeaturing[#RemoveFeaturing]]","#NotAvailable#" | |
Substitute0="#NotAvailable#" | |
SanitizeArtist1="#RemoveTopic#","#RemoveVEVO#","":"[ArtistNotAvailable]" | |
SanitizeArtist0="":"[ArtistNotAvailable]" | |
; ███╗ ███╗███████╗ █████╗ ███████╗██╗ ██╗██████╗ ███████╗███████╗ | |
; ████╗ ████║██╔════╝██╔══██╗██╔════╝██║ ██║██╔══██╗██╔════╝██╔════╝ | |
; ██╔████╔██║█████╗ ███████║███████╗██║ ██║██████╔╝█████╗ ███████╗ | |
; ██║╚██╔╝██║██╔══╝ ██╔══██║╚════██║██║ ██║██╔══██╗██╔══╝ ╚════██║ | |
; ██║ ╚═╝ ██║███████╗██║ ██║███████║╚██████╔╝██║ ██║███████╗███████║ | |
; ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ | |
; For :EscapeRegExp | |
[ft] | |
Measure=String | |
String=#__Featuring# | |
UpdateDivider=-1 | |
; Rainmeter crashes if the right hand side of a substitute is empty | |
; or something like that so using these the user can't accidentally crash | |
[ArtistNotAvailable] | |
Measure=String | |
String=#__ArtistNotAvailable# | |
Substitute="":" " | |
UpdateDivider=-1 | |
[TitleNotAvailable] | |
Measure=String | |
String=#__TitleNotAvailable# | |
Substitute="":" " | |
UpdateDivider=-1 | |
[MeasureArtist] | |
Measure=Plugin | |
Plugin=WebNowPlaying | |
PlayerType=Artist | |
RegExpSubstitute=1 | |
Substitute="[#SanitizeArtist[#SanitizeArtist]]" | |
[MeasureTitle] | |
Measure=Plugin | |
Plugin=WebNowPlaying | |
PlayerType=Title | |
RegExpSubstitute=1 | |
Substitute="[#Substitute[#TitleExtraction]]" | |
DynamicVariables=1 | |
; Example meter | |
[ummy] | |
Meter=String | |
MeasureName=MeasureArtist | |
MeasureName2=MeasureTitle | |
Text=%1#__ArtistTitleSeparator#%2 | |
SolidColor=0,0,0,1 | |
AntiAlias=1 | |
FontFace=Quicksand | |
FontSize=24 | |
FontWeight=700 | |
StringAlign=Center | |
X=([[#CURRENTSECTION]:W] / 2) | |
DynamicVariables=1 | |
FontColor=255,255,255 | |
ClipString=2 | |
ClipStringW=352 | |
InlineSetting=Shadow | 2 | 2 | 3.5 | 250,150,250,200 | |
InlineSetting2=GradientColor | 180 | 255,0,0,255 ; 0.0 | 0,255,0,255 ; 0.5 | 0,0,255,255 ; 1.0 | |
Group=Title |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Known limitations:
When a song is uploaded on a channel that doesn't have the same name as the artist, title extraction fails. eg.
Starlight - Laura Les
uploaded oncow koi
. You could try to guess which part,Starlight
orLaura Les
is the artist and which the title. But doing that has a 50% of being wrong and it would inevitably mess up titles that actually contain-
Also, a prior version of Title Extraction used to crash when used on a NowPlaying measure. It looks like it doesn't crash anymore. But be aware that it did do that. And you shouldn't need to use this with local music collections anyway. Your local files shouldn't contain the duplicate information that Title Extraction removes in the first place.