import re
import click


def get_ytid(link):
    """Return YouTube-ID for a YouTube link."""
    exp = "(v|list)=([-_\w]+)"
    match = re.search(exp, link["url"])

    if not match:
        click.echo("No ytid found for {}".format(link["url"]), err=True)
        return False
    else:
        if (match.group(1) == 'list'):
            click.echo('Downloading all tracks from playlist...')
        return match.group(2)