Wikipedia:Reference desk/Archives/Computing/2018 March 14

From Wikipedia, the free encyclopedia
Computing desk
< March 13 << Feb | March | Apr >> Current desk >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


March 14[edit]

YouTube video id[edit]

I've noticed YouTube video ids are always 11 characters long and contain only letters (upper and lower case), digits and the characters - and _.

But is it really an absolute rule? How can one be certain there isn't and there won't ever be a YouTube video id containing the characters +, = or , or . or #?

Thanks. Basemetal 07:37, 14 March 2018 (UTC)[reply]

It is a practice, not a rule. They are encoding a 64 bit integer in Base64. 11 characters gives you 66 bits. So the end result is 11 characters. But, what if they opt for a different ID in the future? The API for YouTube says that the 11 character rule should not be hard coded in any application because it may change at any time. 71.85.51.150 (talk) 09:46, 14 March 2018 (UTC)[reply]
The ID is currently 8 bytes, which is 64 bits. They use Base64 encoding with two minor changes. They don't pad the output. They changed the standard + and / characters to - and _. You can easily reverse the Base64 encoding to get the original 8-byte ID, with two extra 0's added to the end. 209.149.113.5 (talk) 12:08, 14 March 2018 (UTC)[reply]

Another YouTube video id question[edit]

Sometimes YouTube changes the last character of the video id I supply. For example when I try the video ids ___________, -----------, xxxxxxxxxxx, nnnnnnnnnnn, YouTube changes them to __________8, ----------8, xxxxxxxxxxw, nnnnnnnnnnk respectively. Could the last character be an error correcting character? If yes, does anyone know how to calculate the last character from the first ten to get a valid YouTube video id? Thanks. Basemetal 07:52, 14 March 2018 (UTC)[reply]

The actual ID is 64 bits. The 11 digit Base 64 encoding gives 66 bits. The extra 2 bits at the end are set to zero, which limits what the last character may be. 71.85.51.150 (talk) 09:47, 14 March 2018 (UTC)[reply]