Skip to content

Instantly share code, notes, and snippets.

  • Star 85 You must be signed in to star a gist
  • Fork 16 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rodrigoborgesdeoliveira/987683cfbfcc8d800192da1e73adc486 to your computer and use it in GitHub Desktop.
Example of the YouTube videos URL formats
http://www.youtube.com/watch?v=-wtIMTCHWuI
http://youtube.com/watch?v=-wtIMTCHWuI
http://m.youtube.com/watch?v=-wtIMTCHWuI
https://www.youtube.com/watch?v=lalOy8Mbfdc
https://youtube.com/watch?v=lalOy8Mbfdc
https://m.youtube.com/watch?v=lalOy8Mbfdc
http://www.youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail
http://youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail
http://m.youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail
https://www.youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail
https://youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail
https://m.youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail
http://www.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index
http://youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index
http://m.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index
https://www.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index
https://youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index
https://m.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index
http://www.youtube.com/watch?v=0zM3nApSvMg#t=0m10s
http://youtube.com/watch?v=0zM3nApSvMg#t=0m10s
http://m.youtube.com/watch?v=0zM3nApSvMg#t=0m10s
https://www.youtube.com/watch?v=0zM3nApSvMg#t=0m10s
https://youtube.com/watch?v=0zM3nApSvMg#t=0m10s
https://m.youtube.com/watch?v=0zM3nApSvMg#t=0m10s
http://www.youtube.com/watch?v=cKZDdG9FTKY&feature=channel
http://youtube.com/watch?v=cKZDdG9FTKY&feature=channel
http://m.youtube.com/watch?v=cKZDdG9FTKY&feature=channel
https://www.youtube.com/watch?v=oTJRivZTMLs&feature=channel
https://youtube.com/watch?v=oTJRivZTMLs&feature=channel
https://m.youtube.com/watch?v=oTJRivZTMLs&feature=channel
http://www.youtube.com/watch?v=lalOy8Mbfdc&playnext_from=TL&videos=osPknwzXEas&feature=sub
http://youtube.com/watch?v=lalOy8Mbfdc&playnext_from=TL&videos=osPknwzXEas&feature=sub
http://m.youtube.com/watch?v=lalOy8Mbfdc&playnext_from=TL&videos=osPknwzXEas&feature=sub
https://www.youtube.com/watch?v=lalOy8Mbfdc&playnext_from=TL&videos=osPknwzXEas&feature=sub
https://youtube.com/watch?v=lalOy8Mbfdc&playnext_from=TL&videos=osPknwzXEas&feature=sub
https://m.youtube.com/watch?v=lalOy8Mbfdc&playnext_from=TL&videos=osPknwzXEas&feature=sub
http://www.youtube.com/watch?v=lalOy8Mbfdc&feature=youtu.be
http://youtube.com/watch?v=lalOy8Mbfdc&feature=youtu.be
http://m.youtube.com/watch?v=lalOy8Mbfdc&feature=youtu.be
https://www.youtube.com/watch?v=lalOy8Mbfdc&feature=youtu.be
https://youtube.com/watch?v=lalOy8Mbfdc&feature=youtu.be
https://m.youtube.com/watch?v=lalOy8Mbfdc&feature=youtu.be
http://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player
http://youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player
http://m.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player
https://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player
https://youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player
https://m.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player
http://www.youtube.com/watch?v=ishbTyLs6ps&list=PLGup6kBfcU7Le5laEaCLgTKtlDcxMqGxZ&index=106&shuffle=2655
http://youtube.com/watch?v=ishbTyLs6ps&list=PLGup6kBfcU7Le5laEaCLgTKtlDcxMqGxZ&index=106&shuffle=2655
http://m.youtube.com/watch?v=ishbTyLs6ps&list=PLGup6kBfcU7Le5laEaCLgTKtlDcxMqGxZ&index=106&shuffle=2655
https://www.youtube.com/watch?v=ishbTyLs6ps&list=PLGup6kBfcU7Le5laEaCLgTKtlDcxMqGxZ&index=106&shuffle=2655
https://youtube.com/watch?v=ishbTyLs6ps&list=PLGup6kBfcU7Le5laEaCLgTKtlDcxMqGxZ&index=106&shuffle=2655
https://m.youtube.com/watch?v=ishbTyLs6ps&list=PLGup6kBfcU7Le5laEaCLgTKtlDcxMqGxZ&index=106&shuffle=2655
http://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ
http://youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ
http://m.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ
https://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ
https://youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ
https://m.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ
http://www.youtube.com/watch?app=desktop&v=dQw4w9WgXcQ
http://youtube.com/watch?app=desktop&v=dQw4w9WgXcQ
http://m.youtube.com/watch?app=desktop&v=dQw4w9WgXcQ
https://www.youtube.com/watch?app=desktop&v=dQw4w9WgXcQ
https://youtube.com/watch?app=desktop&v=dQw4w9WgXcQ
https://m.youtube.com/watch?app=desktop&v=dQw4w9WgXcQ
http://www.youtube.com/v/dQw4w9WgXcQ
http://youtube.com/v/dQw4w9WgXcQ
http://m.youtube.com/v/dQw4w9WgXcQ
https://www.youtube.com/v/dQw4w9WgXcQ
https://youtube.com/v/dQw4w9WgXcQ
https://m.youtube.com/v/dQw4w9WgXcQ
http://www.youtube.com/v/-wtIMTCHWuI?version=3&autohide=1
http://youtube.com/v/-wtIMTCHWuI?version=3&autohide=1
http://m.youtube.com/v/-wtIMTCHWuI?version=3&autohide=1
https://www.youtube.com/v/-wtIMTCHWuI?version=3&autohide=1
https://youtube.com/v/-wtIMTCHWuI?version=3&autohide=1
https://m.youtube.com/v/-wtIMTCHWuI?version=3&autohide=1
http://www.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0
http://youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0
http://m.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0
https://www.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0
https://www.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0
https://youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0
https://m.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0
http://www.youtube.com/v/dQw4w9WgXcQ?feature=youtube_gdata_player
http://youtube.com/v/dQw4w9WgXcQ?feature=youtube_gdata_player
http://m.youtube.com/v/dQw4w9WgXcQ?feature=youtube_gdata_player
https://www.youtube.com/v/dQw4w9WgXcQ?feature=youtube_gdata_player
https://youtube.com/v/dQw4w9WgXcQ?feature=youtube_gdata_player
https://m.youtube.com/v/dQw4w9WgXcQ?feature=youtube_gdata_player
http://youtu.be/-wtIMTCHWuI
https://youtu.be/-wtIMTCHWuI
http://youtu.be/dQw4w9WgXcQ?feature=youtube_gdata_player
https://youtu.be/dQw4w9WgXcQ?feature=youtube_gdata_player
http://youtu.be/oTJRivZTMLs?list=PLToa5JuFMsXTNkrLJbRlB--76IAOjRM9b
https://youtu.be/oTJRivZTMLs?list=PLToa5JuFMsXTNkrLJbRlB--76IAOjRM9b
http://youtu.be/oTJRivZTMLs&feature=channel
https://youtu.be/oTJRivZTMLs&feature=channel
http://youtu.be/lalOy8Mbfdc?t=1
http://youtu.be/lalOy8Mbfdc?t=1s
https://youtu.be/lalOy8Mbfdc?t=1
https://youtu.be/lalOy8Mbfdc?t=1s
http://youtu.be/M9bq_alk-sw?si=B_RZg_I-lLaa7UU-
https://youtu.be/M9bq_alk-sw?si=B_RZg_I-lLaa7UU-
http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D-wtIMTCHWuI&format=json
http://youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D-wtIMTCHWuI&format=json
http://m.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D-wtIMTCHWuI&format=json
https://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D-wtIMTCHWuI&format=json
https://youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D-wtIMTCHWuI&format=json
https://m.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D-wtIMTCHWuI&format=json
http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare
http://youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare
http://m.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare
https://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare
https://youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare
https://m.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare
http://www.youtube.com/attribution_link?a=8g8kPrPIi-ecwIsS&u=/watch%3Fv%3DyZv2daTWRZU%26feature%3Dem-uploademail
http://youtube.com/attribution_link?a=8g8kPrPIi-ecwIsS&u=/watch%3Fv%3DyZv2daTWRZU%26feature%3Dem-uploademail
http://m.youtube.com/attribution_link?a=8g8kPrPIi-ecwIsS&u=/watch%3Fv%3DyZv2daTWRZU%26feature%3Dem-uploademail
https://www.youtube.com/attribution_link?a=8g8kPrPIi-ecwIsS&u=/watch%3Fv%3DyZv2daTWRZU%26feature%3Dem-uploademail
https://youtube.com/attribution_link?a=8g8kPrPIi-ecwIsS&u=/watch%3Fv%3DyZv2daTWRZU%26feature%3Dem-uploademail
https://m.youtube.com/attribution_link?a=8g8kPrPIi-ecwIsS&u=/watch%3Fv%3DyZv2daTWRZU%26feature%3Dem-uploademail
http://www.youtube.com/embed/lalOy8Mbfdc
http://youtube.com/embed/lalOy8Mbfdc
http://m.youtube.com/embed/lalOy8Mbfdc
https://www.youtube.com/embed/lalOy8Mbfdc
https://youtube.com/embed/lalOy8Mbfdc
https://m.youtube.com/embed/lalOy8Mbfdc
http://www.youtube.com/embed/nas1rJpm7wY?rel=0
http://youtube.com/embed/nas1rJpm7wY?rel=0
http://m.youtube.com/embed/nas1rJpm7wY?rel=0
https://www.youtube.com/embed/nas1rJpm7wY?rel=0
https://youtube.com/embed/nas1rJpm7wY?rel=0
https://m.youtube.com/embed/nas1rJpm7wY?rel=0
http://www.youtube-nocookie.com/embed/lalOy8Mbfdc?rel=0
https://www.youtube-nocookie.com/embed/lalOy8Mbfdc?rel=0
http://www.youtube.com/e/dQw4w9WgXcQ
http://youtube.com/e/dQw4w9WgXcQ
http://m.youtube.com/e/dQw4w9WgXcQ
https://www.youtube.com/e/dQw4w9WgXcQ
https://youtube.com/e/dQw4w9WgXcQ
https://m.youtube.com/e/dQw4w9WgXcQ
https://youtube.com/user/GitHub#p/a/u/1/lalOy8Mbfdc
https://www.youtube.com/user/GitHub#p/u/1/lalOy8Mbfdc
https://www.youtube.com/user/GitHub#p/u/1/lalOy8Mbfdc?rel=0
https://www.youtube.com/user/GitHub#p/a/u/2/lalOy8Mbfdc
https://www.youtube.com/user/GitHub#p/u/11/lalOy8Mbfdc
https://www.youtube.com/user/GitHub#p/u/1/lalOy8Mbfdc
https://www.youtube.com/GitHub?v=lalOy8Mbfdc
http://www.youtube.com/?v=dQw4w9WgXcQ
http://youtube.com/?v=dQw4w9WgXcQ&feature=youtube_gdata_player
http://youtube.com/?v=lalOy8Mbfdc&feature=channel
http://youtube.com/?vi=dQw4w9WgXcQ
http://youtube.com/?vi=dQw4w9WgXcQ&feature=youtube_gdata_player
http://youtube.com/?vi=lalOy8Mbfdc&feature=channel
http://www.youtube.com/?feature=player_embedded&v=dQw4w9WgXcQ
http://youtube.com/?feature=channel&v=lalOy8Mbfdc
http://youtube.com/watch?vi=dQw4w9WgXcQ
http://youtube.com/watch?vi=dQw4w9WgXcQ&feature=youtube_gdata_player
http://youtube.com/watch?vi=lalOy8Mbfdc&feature=channel
http://youtube.com/vi/dQw4w9WgXcQ
http://youtube.com/vi/dQw4w9WgXcQ?feature=youtube_gdata_player
http://youtube.com/vi/lalOy8Mbfdc&feature=channel
http://www.youtube-nocookie.com/v/6L3ZvIMwZFM?version=3&hl=en_US&rel=0
@rodrigoborgesdeoliveira
Copy link
Author

@TheaZane that one is the same as https://www.youtube.com/watch?v=fKF0uaABJtc. For whatever reason you got the ? and = encoded.

@EmuAnon34
Copy link

Here’s what you get when you use Request Desktop Website on mobile. https://www.youtube.com/watch?app=desktop&v=dQw4w9WgXcQ

@rodrigoborgesdeoliveira
Copy link
Author

Thanks, @EmuAnon34.

@VladimirSlavik
Copy link

The same format also appears when you open on desktop a mobile url (m.youtube.com).

@rodrigoborgesdeoliveira
Copy link
Author

Thanks, @VladimirSlavik. Added.

@VladimirSlavik
Copy link

VladimirSlavik commented Aug 22, 2022

Ah! Sorry for the confusion, that was not what I meant. Let me try again.

The m.y... mobile URL, when opened on a desktop browser, redirects to the www.y...?app=desktop... kind of URL.

At least, that's the part where I am certain. I never saw the format you added last.

@rodrigoborgesdeoliveira
Copy link
Author

Got it. Yeah, the https://m.youtube.com/watch?app=desktop&v=dQw4w9WgXcQ turns out to be a valid URL, just not the final URL, since it redirects to youtube.com.

@EmuAnon34
Copy link

@rodrigoborgesdeoliveira @VladimirSlavik Pretty much every www. url has an m. equivalent.

@watn3y
Copy link

watn3y commented Oct 20, 2022

I made a little regex that matches the video ID in 99% of those examples. It's not bulletproof but probably good enough for most usecases.

/(?<=[=\/&])[a-zA-Z0-9_\-]{11}(?=[=\/&?#\n\r]|$)/

Be sure to improve on this if you can.

It can be tested here

@asdfletcher-yesler
Copy link

asdfletcher-yesler commented Dec 13, 2022

Is there an example link with prefix https://youtube.com ? Seems like this might be missing from the examples

(And http://m.youtube.com?)

@rodrigoborgesdeoliveira
Copy link
Author

@NebularNerd
Copy link

Thanks for this list, it's come in handy for a couple of little projects πŸ™‚

@rodrigoborgesdeoliveira
Copy link
Author

Thanks for this list, it's come in handy for a couple of little projects πŸ™‚

πŸ™‚

@wu-lee
Copy link

wu-lee commented Jan 30, 2023

Are the URLs like this one valid?

https://www.youtube.com/user/IngridMichaelsonVEVO#p/a/u/1/QdK8U-VIH_o

In that, yes, they go to a You Tube user's channel, but I suspect everything after the # is ignored, so the video ID isn't used. In fact that anchor suffix could be anything at all, and it would be correct not to parse the video ID.

@wu-lee
Copy link

wu-lee commented Jan 30, 2023

Likewise, I wonder about these URLs with a vi in place of a v. They all either go to a 404-not-found or are redirected to youtube.com's front page. Even if I insert an ID I know works with other URLs - so it's not simply the video has been taken down.

http://youtube.com/?vi=dQw4w9WgXcQ&feature=youtube_gdata_player
http://youtube.com/watch?vi=dQw4w9WgXcQ&feature=youtube_gdata_player
http://youtube.com/vi/dQw4w9WgXcQ?feature=youtube_gdata_player
http://youtube.com/vi/oTJRivZTMLs&feature=channel
http://youtube.com/watch?vi=oTJRivZTMLs&feature=channel

@wu-lee
Copy link

wu-lee commented Jan 30, 2023

And URLs like this, with a v= parameter and no watch:

http://youtube.com/?v=XXXXXXXXXXX&feature=youtube_gdata_player
http://www.youtube.com/?v=XXXXXXXXXXX
http://www.youtube.com/?feature=player_embedded&v=XXXXXXXXXXX
http://youtube.com/?v=XXXXXXXXXXX&feature=channel
http://youtube.com/?feature=channel&v=XXXXXXXXXXX

I've not made an exhaustive test, but it does seem to find a lot of questionable URLs. It's quite possible these work for someone else, but has anyone evidence these URLs ever did link to a video?

@NebularNerd
Copy link

I've tried a couple and it seems some of the weirder looking ones may or do not work, I've left them in my regex for potential matches if I ever find one in the wild and want to quickly get the ID

@rodrigoborgesdeoliveira
Copy link
Author

Thanks for reporting these @wu-lee. I'm going to do some tests over the weekend and leave some comments in the list for any of the links that don't work anymore. It might be the case that YouTube has deprecated these URLs.

@wu-lee
Copy link

wu-lee commented Jan 31, 2023

I think these URLs with vi components may be for thumbnail images associated with videos. For example, this is one:

https://i.ytimg.com/vi/XXXXXXXXXXX/default.jpg

@Revnoplex
Copy link

Are query strings that use & first instead of ? valid?
because its on lines 118 and 119, and python's urllib parsing library did not recognise it and made the query strings part of the path.
eg:

from urllib import parse

components = parse.urlparse("https://youtu.be/oTJRivZTMLs&feature=channel")
print(components.path)

results in an output of

oTJRivZTMLs&feature=channel

while normally

from urllib import parse

components = parse.urlparse("https://youtu.be/dQw4w9WgXcQ?feature=youtube_gdata_player")
print(components.path)

results in just

dQw4w9WgXcQ

So either this is a mistake on the urls listed or a bug with the python urllib library

@rodrigoborgesdeoliveira
Copy link
Author

It's neither a mistake nor a bug. The &feature=channel is indeed part of the path, not a query string parameter. However, YouTube's url shortener service (the youtu.be) will do the job of parsing the path parameter into what youtube.com needs, and so it'll translate and redirect https://youtu.be/oTJRivZTMLs&feature=channel into something like https://www.youtube.com/watch?v=oTJRivZTMLs&feature=channel&feature=youtu.be.

@Snailedlt
Copy link

Here's a python regex that matches all of the links in this gist:

^((https?://(?:www\.)?(?:m\.)?youtube\.com))/((?:oembed\?url=https?%3A//(?:www\.)youtube.com/watch\?(?:v%3D)(?P<video_id_1>[\w\-]{10,20})&format=json)|(?:attribution_link\?a=.*watch(?:%3Fv%3D|%3Fv%3D)(?P<video_id_2>[\w\-]{10,20}))(?:%26feature.*))|(https?:)?(\/\/)?((www\.|m\.)?youtube(-nocookie)?\.com\/((watch)?\?(app=desktop&)?(feature=\w*&)?v=|embed\/|v\/|e\/)|youtu\.be\/)(?P<video_id_3>[\w\-]{10,20})

Python 3 implementation:

def get_youtube_video_id_by_url(url):
    regex = r"^((https?://(?:www\.)?(?:m\.)?youtube\.com))/((?:oembed\?url=https?%3A//(?:www\.)youtube.com/watch\?(?:v%3D)(?P<video_id_1>[\w\-]{10,20})&format=json)|(?:attribution_link\?a=.*watch(?:%3Fv%3D|%3Fv%3D)(?P<video_id_2>[\w\-]{10,20}))(?:%26feature.*))|(https?:)?(\/\/)?((www\.|m\.)?youtube(-nocookie)?\.com\/((watch)?\?(app=desktop&)?(feature=\w*&)?v=|embed\/|v\/|e\/)|youtu\.be\/)(?P<video_id_3>[\w\-]{10,20})"
    match = re.match(regex, url, re.IGNORECASE)
    if match:
        return (
            match.group("video_id_1")
            or match.group("video_id_2")
            or match.group("video_id_3")
        )
    else:
        return None

It matches everything in the gist, but can probably be improved upon for performance, so feel free to suggest improvements!
Just test them here first: https://regex101.com/

@Revnoplex
Copy link

I've written a regexless version in python using its built-in url parser. Full code here. You will also notice the version that works with playlists. That one works with the following urls

def extract_video_id(url: str) -> Optional[str]:
    """
    This should work for every url listed here:
    https://gist.github.com/rodrigoborgesdeoliveira/987683cfbfcc8d800192da1e73adc486#file-activeyoutubeurlformats-txt
    and more.
    Args:
        url (str): The url to strip the id from
    Returns:
        Optional[str]: The video id with the rest of the url removed
    """
    components = parse.urlparse(url.replace("&", "?", 1) if "?" not in url else url)
    queries = parse.parse_qs(components.query)
    encoded_query_matches = {'u', 'url'}.intersection(set(queries.keys()))
    if 'v' in queries:
        return queries["v"][0]
    elif encoded_query_matches:
        return extract_video_id(parse.unquote(queries[encoded_query_matches.pop()][0]))
    elif components.netloc == "i.ytimg.com":
        return pathlib.Path(components.path).parts[2]
    elif pathlib.Path(components.path).name not in ["playlist"]:
        return pathlib.Path(components.path).name

@tacerus
Copy link

tacerus commented Aug 26, 2023

Hi,

recently links generated using the "Share" button under a video will contain some additional ?si= query parameter:

https://youtu.be/_UuD60EZGkg?si=eP5r-sAojFjjVYCY

Not sure what it is for, probably more tracking?

@rodrigoborgesdeoliveira
Copy link
Author

Oh, interesting. Thanks, @tacerus!

@heartlog
Copy link

Hi,

recently links generated using the "Share" button under a video will contain some additional ?si= query parameter:

https://youtu.be/_UuD60EZGkg?si=eP5r-sAojFjjVYCY

Not sure what it is for, probably more tracking?

Yea, most probably it's true.
And have you noticed that every time you share a URL, the tracking ID changes, even for the same video on the same device? If it's a tracking parameter, then it can track the sender and receiver of the YouTube URL. In short, Google can know who your close relatives and friends are. This is surely a messed up thing.

@ChristopherGabba
Copy link

For those using javascript/typescript, I have a function and regex working for all combinations above plus youtube shorts:

export function getVideoIdFromYoutubeUrl(url: string) {
  const regex = /(?:youtu\.be\/|youtube\.com(?:\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=|shorts\/)|youtu\.be\/|embed\/|v\/|m\/|watch\?(?:[^=]+=[^&]+&)*?v=))([^"&?\/\s]{11})/gm;
  return regex.exec(url)[1];
}
export function validateYoutubeTestUrls() {
  const youtubeTestUrls: { key: number; value: string }[] = [
    { key: 1, value: "http://www.youtube.com/watch?v=-wtIMTCHWuI" },
    { key: 2, value: "http://youtube.com/watch?v=-wtIMTCHWuI" },
    { key: 3, value: "http://m.youtube.com/watch?v=-wtIMTCHWuI" },
    { key: 4, value: "https://www.youtube.com/watch?v=lalOy8Mbfdc" },
    { key: 5, value: "https://youtube.com/watch?v=lalOy8Mbfdc" },
    { key: 6, value: "https://m.youtube.com/watch?v=lalOy8Mbfdc" },
    { key: 7, value: "http://www.youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail" },
    { key: 8, value: "http://youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail" },
    { key: 9, value: "http://m.youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail" },
    { key: 10, value: "https://www.youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail" },
    { key: 11, value: "https://youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail" },
    { key: 12, value: "https://m.youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail" },
    { key: 13, value: "http://www.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index" },
    { key: 14, value: "http://youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index" },
    { key: 15, value: "http://m.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index" },
    { key: 16, value: "https://www.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index" },
    { key: 17, value: "https://youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index" },
    { key: 18, value: "https://m.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index" },
    { key: 19, value: "http://www.youtube.com/watch?v=0zM3nApSvMg#t=0m10s" },
    { key: 20, value: "http://youtube.com/watch?v=0zM3nApSvMg#t=0m10s" },
    { key: 21, value: "http://m.youtube.com/watch?v=0zM3nApSvMg#t=0m10s" },
    { key: 22, value: "https://www.youtube.com/watch?v=0zM3nApSvMg#t=0m10s" },
    { key: 23, value: "https://youtube.com/watch?v=0zM3nApSvMg#t=0m10s" },
    { key: 24, value: "https://m.youtube.com/watch?v=0zM3nApSvMg#t=0m10s" },
    { key: 25, value: "http://www.youtube.com/watch?v=cKZDdG9FTKY&feature=channel" },
    { key: 26, value: "http://youtube.com/watch?v=cKZDdG9FTKY&feature=channel" },
    { key: 27, value: "http://m.youtube.com/watch?v=cKZDdG9FTKY&feature=channel" },
    { key: 28, value: "https://www.youtube.com/watch?v=oTJRivZTMLs&feature=channel" },
    { key: 29, value: "https://youtube.com/watch?v=oTJRivZTMLs&feature=channel" },
    { key: 30, value: "https://m.youtube.com/watch?v=oTJRivZTMLs&feature=channel" },
    { key: 31, value: "http://www.youtube.com/watch?v=lalOy8Mbfdc&playnext_from=TL&videos=osPknwzXEas&feature=sub",},
    { key: 32, value: "http://youtube.com/watch?v=lalOy8Mbfdc&playnext_from=TL&videos=osPknwzXEas&feature=sub", },
    { key: 33, value: "http://m.youtube.com/watch?v=lalOy8Mbfdc&playnext_from=TL&videos=osPknwzXEas&feature=sub" },
    { key: 34, value: "https://www.youtube.com/watch?v=lalOy8Mbfdc&playnext_from=TL&videos=osPknwzXEas&feature=sub", },
    { key: 35, value: "https://youtube.com/watch?v=lalOy8Mbfdc&playnext_from=TL&videos=osPknwzXEas&feature=sub" },
    { key: 36, value: "https://m.youtube.com/watch?v=lalOy8Mbfdc&playnext_from=TL&videos=osPknwzXEas&feature=sub",},
    { key: 37, value: "http://www.youtube.com/watch?v=lalOy8Mbfdc&feature=youtu.be" },
    { key: 38, value: "http://youtube.com/watch?v=lalOy8Mbfdc&feature=youtu.be" },
    { key: 39, value: "http://m.youtube.com/watch?v=lalOy8Mbfdc&feature=youtu.be" },
    { key: 40, value: "https://www.youtube.com/watch?v=lalOy8Mbfdc&feature=youtu.be" },
    { key: 41, value: "https://youtube.com/watch?v=lalOy8Mbfdc&feature=youtu.be" },
    { key: 42, value: "https://m.youtube.com/watch?v=lalOy8Mbfdc&feature=youtu.be" },
    { key: 43, value: "http://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player" },
    { key: 44, value: "http://youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player" },
    { key: 45, value: "http://m.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player" },
    { key: 46, value: "https://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player" },
    { key: 47, value: "https://youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player" },
    { key: 48, value: "https://m.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player" },
    { key: 49,  value: "http://www.youtube.com/watch?v=ishbTyLs6ps&list=PLGup6kBfcU7Le5laEaCLgTKtlDcxMqGxZ&index=106&shuffle=2655", },
    { key: 50, value: "http://youtube.com/watch?v=ishbTyLs6ps&list=PLGup6kBfcU7Le5laEaCLgTKtlDcxMqGxZ&index=106&shuffle=2655", }, { key: 51,value: "http://m.youtube.com/watch?v=ishbTyLs6ps&list=PLGup6kBfcU7Le5laEaCLgTKtlDcxMqGxZ&index=106&shuffle=2655", }, { key: 52, value: "https://www.youtube.com/watch?v=ishbTyLs6ps&list=PLGup6kBfcU7Le5laEaCLgTKtlDcxMqGxZ&index=106&shuffle=2655", },
    { key: 53, value: "https://youtube.com/watch?v=ishbTyLs6ps&list=PLGup6kBfcU7Le5laEaCLgTKtlDcxMqGxZ&index=106&shuffle=2655", },
    { key: 54, value: "https://m.youtube.com/watch?v=ishbTyLs6ps&list=PLGup6kBfcU7Le5laEaCLgTKtlDcxMqGxZ&index=106&shuffle=2655",  },
    { key: 55, value: "http://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ" },
    { key: 56, value: "http://youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ" },
    { key: 57, value: "http://m.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ" },
    { key: 58, value: "https://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ" },
    { key: 59, value: "https://youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ" },
    { key: 60, value: "https://m.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ" },
    { key: 61, value: "http://www.youtube.com/watch?app=desktop&v=dQw4w9WgXcQ" },
    { key: 62, value: "http://youtube.com/watch?app=desktop&v=dQw4w9WgXcQ" },
    { key: 63, value: "http://m.youtube.com/watch?app=desktop&v=dQw4w9WgXcQ" },
    { key: 64, value: "https://www.youtube.com/watch?app=desktop&v=dQw4w9WgXcQ" },
    { key: 65, value: "https://youtube.com/watch?app=desktop&v=dQw4w9WgXcQ" },
    { key: 66, value: "https://m.youtube.com/watch?app=desktop&v=dQw4w9WgXcQ" },
    { key: 67, value: "http://www.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index" },
    { key: 69, value: "http://www.youtube.com/v/0zM3nApSvMg?fs=1&amp;hl=en_US&amp;rel=0" },
    { key: 70, value: "http://www.youtube.com/watch?v=0zM3nApSvMg#t=0m10s" },
    { key: 71, value: "http://www.youtube.com/embed/0zM3nApSvMg?rel=0" },
    { key: 72, value: "http://www.youtube.com/watch?v=0zM3nApSvMg" },
    { key: 73, value: "http://youtu.be/0zM3nApSvMg" },
    { key: 74, value: "https://youtube.com/shorts/0dPkkQeRwTI?feature=share" },
    { key: 75, value: "https://youtube.com/shorts/0dPkkQeRwTI" },
    { key: 76, value: "https://youtu.be/59kf86v_Cpc?si=Cj_xm4a6BX71d1yd" },
  ]
  youtubeTestUrls.forEach((keyValuePair) => {
    const videoId = getVideoIdFromYoutubeUrl(keyValuePair.value)
    const isElevenCharacters = videoId?.length === 11
    console.log("id for", keyValuePair.key, "is: ", videoId, "| valid:", isElevenCharacters)
  })

}

OUTPUT:

 LOG  id for 1 is:  -wtIMTCHWuI | isvalid: true
 LOG  id for 2 is:  -wtIMTCHWuI | isvalid: true
 LOG  id for 3 is:  -wtIMTCHWuI | isvalid: true
 LOG  id for 4 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 5 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 6 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 7 is:  yZv2daTWRZU | isvalid: true
 LOG  id for 8 is:  yZv2daTWRZU | isvalid: true
 LOG  id for 9 is:  yZv2daTWRZU | isvalid: true
 LOG  id for 10 is:  yZv2daTWRZU | isvalid: true
 LOG  id for 11 is:  yZv2daTWRZU | isvalid: true
 LOG  id for 12 is:  yZv2daTWRZU | isvalid: true
 LOG  id for 13 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 14 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 15 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 16 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 17 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 18 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 19 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 20 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 21 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 22 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 23 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 24 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 25 is:  cKZDdG9FTKY | isvalid: true
 LOG  id for 26 is:  cKZDdG9FTKY | isvalid: true
 LOG  id for 27 is:  cKZDdG9FTKY | isvalid: true
 LOG  id for 28 is:  oTJRivZTMLs | isvalid: true
 LOG  id for 29 is:  oTJRivZTMLs | isvalid: true
 LOG  id for 30 is:  oTJRivZTMLs | isvalid: true
 LOG  id for 31 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 32 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 33 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 34 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 35 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 36 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 37 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 38 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 39 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 40 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 41 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 42 is:  lalOy8Mbfdc | isvalid: true
 LOG  id for 43 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 44 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 45 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 46 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 47 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 48 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 49 is:  ishbTyLs6ps | isvalid: true
 LOG  id for 50 is:  ishbTyLs6ps | isvalid: true
 LOG  id for 51 is:  ishbTyLs6ps | isvalid: true
 LOG  id for 52 is:  ishbTyLs6ps | isvalid: true
 LOG  id for 53 is:  ishbTyLs6ps | isvalid: true
 LOG  id for 54 is:  ishbTyLs6ps | isvalid: true
 LOG  id for 55 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 56 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 57 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 58 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 59 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 60 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 61 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 62 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 63 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 64 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 65 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 66 is:  dQw4w9WgXcQ | isvalid: true
 LOG  id for 67 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 69 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 70 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 71 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 72 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 73 is:  0zM3nApSvMg | isvalid: true
 LOG  id for 74 is:  0dPkkQeRwTI | isvalid: true
 LOG  id for 75 is:  0dPkkQeRwTI | isvalid: true
 LOG  id for 76 is:  59kf86v_Cpc | isvalid: true

@mlatushko
Copy link

I have a function and regex

  • Thank you.

And these:

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

Vβ–ˆ(?-is)^(?:(?!https?[:\/]|www\.|m(?:usic)?\.yo|youtu\.?be[\/\.]|watch[\/\?]|embed\/|YTv(?:[=: ]+)|YouTube: )\V)*?(?:(?:https?[:\/]+|www\.|m\.|music\.)+youtu(?<1>\.)?be(?:\.com\/|watch|live(?=\/)|o?embed(?:\/|\?url=\S+?)?|\?app=\w+|shorts|attribution_link\?[&\w\-=]*[au]=\/?|ytsc\w+|[\?&]*(?:li)?[ve]i?\b[\/=]|\?feature=[\-a-z_\.]+|[\?&]t(?:ime_continue)?=\d+|-nocookie|%[23][56FD]|\.com\/shorts\/)*(?(<1>)\/|)|YTv(?:[=: ]+)|YouTube: )(?(?<=watch)\/|)([a-zA-Z\d\-_]{11}\b)(?>[\?&#][&#%a-zA-Z\-\d=;_\.]*|&feature=[\-a-z_\.]+)?(?=\s|\Z)

β–ˆ\2

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

@Revnoplex
Copy link

Revnoplex commented Nov 11, 2023

For some reason, youtube blocks access to the site via the 11th one. It brings up the "our systems have detected unusual traffic from your computer network" message but with no captcha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment