A while back I made a YouTube video that knows its own URL. By that, I mean that the video’s URL was in the video itself. How is that possible? How was I able to record a video and know its URL ahead of time? Is it time travel?
I’ve actually done this twice. Here’s another one I uploaded 2 years ago.
This is where it gets interesting. I uploaded both videos using different methods. For the older video, I used the YouTube Resumable Upload API. You can find the documentation for it here.
Note: This method does not work anymore, but I will explain what I did anyway. Skip to the bottom if you aren’t interested.
Old method
First of all, in order to use the API, I have to authenticate my requests. That means I need an OAuth2 access token, as a normal API key did not work. After some research, I found a npm package that would help me. I started by creating an application at the Google Cloud Console. After creating an OAuth2 client id and secret, I wrote a script that utilized the npm package. In the end, I got an access token that would let me use the YouTube API.
I started by creating a YouTube video with the API, which showed up in YouTube Studio. Now I can see the link to my YouTube video! After recording the video, I used the API one more time to get the video uploaded.
API Policy change…
Now before you get excited and try to recreate this for yourself, there’s a problem. This API is restricted. If an application tries to upload a YouTube video using this API, the video gets flagged by YouTube for “Terms and Conditions”. This is what happened when I tried to use this method a second time. I was confused. Why didn’t it work? Turns out, at some point, Google restricted the API to only work properly with verified applications. In order to get your application verified, you had to submit an application. However, the application form clearly stated it would not be accepting any requests for private applications.
Unfortunately, that means this method would not work anymore. I would have to find a new method, but how would I do that? It makes sense though. If YouTube kept the API open, spammers could easily automate uploading YouTube videos. By restricting the API, this would no longer be possible. Unfortunately, that means that I wouldn’t be able to use any method similar to this, considering how YouTube and Google are serious about the use of their API.
Conclusion
In conclusion, I was able to use the YouTube Resumable Upload API to figure out my YouTube video’s URL before I uploaded it. Unfortunately, the API no longer works for me. In the future, I might make a post about how I was able to get around this restriction and post the second video. Make sure to check back on my blog often so you don’t miss it!
Leave a Reply