Stories
Slash Boxes
Comments

SoylentNews is people

posted by Fnord666 on Friday July 19 2019, @05:08PM   Printer-friendly
from the interesting dept.

Over the years I have viewed many a video on YouTube. I quickly noticed an "ID" string that appeared in each video URL. Here's an example: https://www.youtube.com/watch?v=ShvnDSgjfXw -- see that string "ShvnDSgjfXw"? What characters are permitted? How long is it?

Along the way, I came upon an amazingly useful utility: youtube-dl. I accidentally discovered that it will happily download a YouTube video given just the Video ID. (Don't let the name of the utility mislead you; it seems to work fine with Instagram, Twitter, Sound Cloud... it's amazing!)

Now with my curiosity suitably piqued, I started a genuine search for what the parameters were that defined a valid YouTube Video ID. This question on "Web Applications Stack Exchange" was most helpful. Especially this response.

It appears that the Video ID (and the Channel ID) are modified base64 encodings of 64-bit (and 128-bit) integers. The primary change is that the base64 encoding produces two characters that are verboten in URLs. A generated "/" is replaced with "-" and a generated "+" is replaced with a "_".

There is no official documentation claiming that the ID lengths are guaranteed to always be 11 or 22 characters long, but empirical evidence suggests that is the current, de-facto standard.

There is even mention of " the maximally-constrained regular expression (RegEx) for the videoId" being:

[0-9A-Za-z_-]{10}[048AEIMQUYcgkosw]

Things get even more interesting if you are using Windows. Under NTFS, file names default to be case-preserving, but case-insensitive. Say I create a file called "Foo.txt" and then get a directory listing. Sure enough, I see: "Foo.txt" displayed. The fun comes if I do "DIR foo.txt" or "DIR FOO.TXT" or any other variation... they all find the same file: "Foo.txt"; this is counter to Unix where filenames are case-sensitive and each of those variations would be treated as separate and distinct files. Though it is possible to make an NTFS volume case-sensitive, it is not for the faint of heart!

One could, therefore, reverse-engineer the integer that produced the Video ID and use that in addition (or for the adventuresome: instead of) the Video ID.

The whole discussion was well-worth the read and highly recommended for anyone who would like more information on where it came from and how it came about.


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 2) by DannyB on Friday July 19 2019, @06:16PM (4 children)

    by DannyB (5839) Subscriber Badge on Friday July 19 2019, @06:16PM (#869090) Journal

    Hear [youtube.com] Har is a YouTube video with an image of the characters of the video's actual URL.

    --
    The lower I set my standards the more accomplishments I have.
    Starting Score:    1  point
    Karma-Bonus Modifier   +1  

    Total Score:   2  
  • (Score: 2) by edIII on Friday July 19 2019, @09:38PM (3 children)

    by edIII (791) on Friday July 19 2019, @09:38PM (#869172)

    How? From what I remember about uploading YouTube videos (API or not), was that you received the URL after, not before.

    --
    Technically, lunchtime is at any moment. It's just a wave function.
    • (Score: 1, Informative) by Anonymous Coward on Saturday July 20 2019, @07:30AM

      by Anonymous Coward on Saturday July 20 2019, @07:30AM (#869322)

      In some cases if you are doing multi part videos you can get it before.

      So you mark it like that. Do the upload slow enough that you are encoding the new video with the id in it.

    • (Score: 1, Funny) by Anonymous Coward on Saturday July 20 2019, @12:48PM (1 child)

      by Anonymous Coward on Saturday July 20 2019, @12:48PM (#869357)

      That s easy: keep uploading until the content matches the URL

      • (Score: 2) by DannyB on Monday July 22 2019, @01:23PM

        by DannyB (5839) Subscriber Badge on Monday July 22 2019, @01:23PM (#869923) Journal

        Easier, and can be done in the lifetime of the universe:
        10 Receive URL from the future
        20 Incorporate URL into video
        30 Upload video
        40 Send URL to the past
        50 GOSUB 10
        60 Profit

        --
        The lower I set my standards the more accomplishments I have.