youtube_title_parse
youtube_title_parse copied to clipboard
Parse song & artist names from YouTube video titles
youtube title parse
Parse the title of a YouTube video to try and get artist & song name.
Description
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.
Installation
To install youtube_title_parse, simply run:
pip install youtube_title_parse
Usage
CLI
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
Module
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"
Credits
This module is originally a Python3 rewrite of the equivalent npm library, get-artist-title, but adds some extra functionality to catch more patterns.
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
License
youtube-title-parse is made available under the MIT license.