NAME
Regexp::Pattern::YouTube - Regexp patterns related to YouTube
VERSION
This document describes version 0.005 of Regexp::Pattern::YouTube (from Perl distribution Regexp-Pattern-YouTube), released on 2020-08-21.
SYNOPSIS
use Regexp::Pattern; # exports re()
my $re = re("YouTube::channel_id");
DESCRIPTION
Regexp::Pattern is a convention for organizing reusable regex patterns.
PATTERNS
channel_id
YouTube channel ID.
YouTube channel ID is an encoding of 128-bit number using a custom base-64 character set. It's 24 characters long.
Caveats:
Like with video ID format, there's no official guarantee that the channel ID will always be 24 characters, or that the allowed character set will stay the same.
This regex does not check whether a channel exists. To do that, you'll need to use the YouTube API.
Examples:
Example #1.
"UCq-Fj5jknLsUf-MWSy4_brA" =~ re("YouTube::channel_id", {-anchor=>1}); # matches
Incorrect length.
"UCq-Fj5jknLsUf-MWSy4_brAx" =~ re("YouTube::channel_id", {-anchor=>1}); # DOESN'T MATCH
Contains invalid character.
"UCq-Fj5jknLsUf+MWSy4_brA" =~ re("YouTube::channel_id", {-anchor=>1}); # DOESN'T MATCH
playlist_id
YouTube playlist ID.
YouTube playlist ID is an encoding of 192-bit number using a custom base-64 character set. It's 34 characters long.
Caveats:
Like with video and channel ID formats, there's no official guarantee that the playlist ID will always be 34 characters, or that the allowed character set will stay the same.
This regex does not check whether a playlist exists. To do that, you'll need to use the YouTube API.
Examples:
Example #1.
"PL9bw4S5ePsEHQKZ4uTtbNXNQGjjOB8bRk" =~ re("YouTube::playlist_id", {-anchor=>1}); # matches
Incorrect length.
"PL9bw4S5ePsEHQKZ4uTtbNXNQGjjOB8bRk-" =~ re("YouTube::playlist_id", {-anchor=>1}); # DOESN'T MATCH
Contains invalid character.
"PL9bw4S5ePsEHQKZ4u+tbNXNQGjjOB8bRk" =~ re("YouTube::playlist_id", {-anchor=>1}); # DOESN'T MATCH
video_id
YouTube video ID.
YouTube video ID is an encoding of 64-bit number in a custom base-64 character set. It's 11 characters long.
Caveats:
There's no official guarantee that the video ID will always be 11 characters, or that the allowed character set will stay the same. From Lhttps://groups.google.com/d/msg/youtube-api-gdata/maM-h-zKPZc/PJDlDWv77TEJ:
"We don't make any public guarantees about the format for video ids. While they're currently 11 character strings that contain letters, numbers and some punctuation, I wouldn't recommend hardcoding that into your application (unless you have an easy way of changing it in the future)."
This regex does not check whether a video exists. To do that, you'll need to use the YouTube API.
Examples:
Example #1.
"aNAtbYSxzuA" =~ re("YouTube::video_id", {-anchor=>1}); # matches
Incorrect length.
"aNAtbYSxzuA-" =~ re("YouTube::video_id", {-anchor=>1}); # DOESN'T MATCH
Contains invalid character.
"aNAtb+SxzuA" =~ re("YouTube::video_id", {-anchor=>1}); # DOESN'T MATCH
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/Regexp-Pattern-YouTube.
SOURCE
Source repository is at https://github.com/perlancar/perl-Regexp-Pattern-YouTube.
BUGS
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Regexp-Pattern-YouTube
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
SEE ALSO
Some utilities related to Regexp::Pattern: App::RegexpPatternUtils, rpgrep from App::rpgrep.
AUTHOR
perlancar <perlancar@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2020, 2018, 2016 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.