Zod- / jsVideoUrlParser

A javascript parser to extract informations like provider, channel, id, start time from YouTube, Vimeo, Dailymotion, Twitch,... urls
MIT License
231 stars 73 forks source link

[Feature request] Youtube shorts support #112

Open westiti opened 1 year ago

westiti commented 1 year ago

Can you please add support for Youtube shorts? That will be great.

FoxxMD commented 1 year ago

Quick and dirty:

import videoUrlParser from "js-video-url-parser";

videoUrlParser.plugins.youtube.parseVideoUrl = function(url) {
    let match = url.match(
        /(?:(?:v|vi|be|videos|embed)\/(?!videoseries)|(?:v|ci)=)([\w-]{11})/i
    );
    if(match) {
        return match[1];
    }
    // match youtube shorts
    match = url.match(/youtube.com\/shorts\/([\w-]{11})/i);
    if(match) {
        return match[1];
    }
    return undefined;
};