Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing elsif for https:youtu.be url #1

Closed
charleswroy opened this issue Nov 19, 2020 · 1 comment
Closed

Missing elsif for https:youtu.be url #1

charleswroy opened this issue Nov 19, 2020 · 1 comment

Comments

@charleswroy
Copy link

Greetings,

First of all, thank you for your module.

It seems that this type of link is not being detected by the module: https://youtu.be/FdeioVndUhs

See : https://youtube.googleblog.com/2009/12/make-way-for-youtube-links.html

I've hacked this modification :
} elsif ( $arg =~ m!\Ahttps?://youtu.be! && $arg =~ /($re)(?:&|\#|\z)/ ) {

In this sub:

sub extract_youtube_video_id {
    my $arg = shift;

    my $re = $Regexp::Pattern::YouTube::RE{video_id}{pat};
    if ($arg =~ /\A$re\z/) {
        return $arg;
    } elsif ($arg =~ m!\Ahttps?://.+/embed/! &&
                 $arg =~ m!/embed/($re)(?:\?|\#|\z)!) {
        return $1;
    } elsif ($arg =~ m!\Ahttps?://! &&
                 $arg =~ /=($re)(?:&|\#|\z)/) {
        return $1;
    } elsif ( $arg =~ m!\Ahttps?://youtu.be! && $arg =~ /($re)(?:&|\#|\z)/ ) {
        return $1;
    } else {
        # assume it's a filename like that generated by youtube-dl
        if ($arg =~ /-($re)(?:\.\w+)+(?:\s|\z)/) {
            return $1;
        }
    }
    undef;
}

I'm pretty sure my regex could be improved.

We now have a modified module for our project. But I would much rather use yours.

If you may include this proposition or improve on it?

Thank you,

Charles-William Roy

@perlancar
Copy link
Owner

Thanks, recognizing youtu.be links added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants