Parse the title of a YouTube video to try and get artist & song name.
Video titles on YouTube follow no strict format, and so passing the titles directly to music APIs to fetch metadata hardly works. This module attempts to recognize common patterns (using regex) and extract artist and song name.
To install youtube_title_parse, simply run:
pip install youtube_title_parse
youtube_title_parse
comes with a CLI that you can use directly:
$ youtube_title_parse "Seoul - Stay With Us (Official Video)"
Seoul - Stay With Us
You can also import youtube_title_parse
as a module.
If the module can successfully parse the input, get_artist_title
will return a tuple of the format [artist, title]
which you can use as below. If not found, [None, None]
is returned.
from youtube_title_parse import get_artist_title
artist, title = get_artist_title("Seoul - Stay With Us (Official Video)")
assert artist == "Seoul"
assert title == "Stay With Us"
This module is originally a Python3 rewrite of the equivalent npm library, get-artist-title
, but adds some extra functionality to catch more patterns.
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
youtube-title-parse is made available under the MIT license.