Platinum Partner

Extract Artist And Title From A Song Title String

Extract the artist and the title of the song from a string formatted as: ARTIST - TITLE.EXT
This code strips the extension, splits the string, trims each part and capitalize it correctly (fixed pythons string.title() bug for handling apostrophes)


#filename = "rihanna - please don't stop the music.pdf"
artist, title = [re.sub("([a-zA-Z])'([A-Z])", lambda m: m.group(1) + "'" + m.group(2).lower(), t.strip().title()) for t in filename[:filename.rfind('.')].split('-')]
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}