I created my own YouTube algorithm (to stop me wasting time)
Tags: Python, YouTube, API, AWS Lambda, Programming

Photo by NordWood Themes on Unsplash

https://snailworks.com/dox/p-v-c1.html

https://snailworks.com/dox/p-v-c2.html

https://snailworks.com/dox/p-v-c3.html

https://snailworks.com/dox/p-v-c4.html

https://snailworks.com/dox/p-v-c5.html

https://snailworks.com/dox/p-v-c6.html

https://snailworks.com/dox/p-v-c7.html

https://snailworks.com/dox/p-v-c8.html

https://snailworks.com/dox/p-v-c9.html

https://snailworks.com/dox/p-v-c10.html

https://snailworks.com/dox/a-v-c1.html

https://snailworks.com/dox/a-v-c10.html

https://snailworks.com/dox/a-v-c2.html

https://snailworks.com/dox/a-v-c3.html

https://snailworks.com/dox/a-v-c4.html

https://snailworks.com/dox/a-v-c5.html

https://snailworks.com/dox/a-v-c6.html

https://snailworks.com/dox/a-v-c7.html

https://snailworks.com/dox/a-v-c8.html

https://snailworks.com/dox/a-v-c9.html

https://snailworks.com/dox/a-v-d1.html

https://snailworks.com/dox/a-v-d2.html

https://snailworks.com/dox/a-v-d3.html

https://snailworks.com/dox/a-v-d4.html

https://snailworks.com/dox/a-v-d5.html

https://snailworks.com/dox/a-v-d6.html

https://snailworks.com/dox/a-v-d7.html

https://snailworks.com/fuj/u-v-c17.html

https://snailworks.com/fuj/u-v-c16.html

https://snailworks.com/fuj/u-v-c15.html

https://snailworks.com/fuj/u-v-c14.html

https://snailworks.com/fuj/u-v-c13.html

https://snailworks.com/fuj/u-v-c12.html

https://snailworks.com/fuj/u-v-c11.html

https://snailworks.com/fuj/u-v-c10.html

https://snailworks.com/fuj/u-v-c9.html

https://snailworks.com/fuj/u-v-c8.html

https://snailworks.com/fuj/u-v-c7.html

https://snailworks.com/fuj/u-v-c6.html

https://snailworks.com/fuj/u-v-c5.html

https://snailworks.com/fuj/u-v-c4.html

https://snailworks.com/fuj/u-v-c3.html

https://snailworks.com/fuj/u-v-c2.html

https://snailworks.com/fuj/u-v-c1.html

https://snailworks.com/dox/f-v-h1.html

https://snailworks.com/dox/f-v-h10.html

https://snailworks.com/dox/f-v-h11.html

https://snailworks.com/dox/f-v-h12.html

https://snailworks.com/dox/f-v-h2.html

https://snailworks.com/dox/f-v-h3.html

https://snailworks.com/dox/f-v-h4.html

https://snailworks.com/dox/f-v-h5.html

https://snailworks.com/dox/f-v-h6.html

https://snailworks.com/dox/f-v-h7.html

https://snailworks.com/dox/f-v-h8.html

https://snailworks.com/dox/f-v-h9.html

https://snailworks.com/dox/f-v-i1.html

https://snailworks.com/dox/f-v-i10.html

https://snailworks.com/dox/f-v-i2.html

https://snailworks.com/dox/f-v-i3.html

https://snailworks.com/dox/f-v-i4.html

https://snailworks.com/dox/f-v-i5.html

https://snailworks.com/dox/f-v-i6.html

https://snailworks.com/dox/f-v-i7.html

https://snailworks.com/dox/f-v-i8.html

https://snailworks.com/dox/f-v-i9.html

https://snailworks.com/dox/f-v-i10.html

http://www.uscm.at/atp/f-v-h1.html

http://www.uscm.at/atp/f-v-h2.html

http://www.uscm.at/atp/f-v-h3.html

http://www.uscm.at/atp/f-v-h4.html

http://www.uscm.at/atp/f-v-i7.html

http://www.uscm.at/atp/f-v-i8.html

http://www.uscm.at/atp/f-v-i9.html

http://www.uscm.at/atp/f-v-i10.html

https://snailworks.com/fuj/b-v-f1.html

https://snailworks.com/fuj/b-v-f2.html

https://snailworks.com/fuj/b-v-f3.html

https://snailworks.com/fuj/b-v-f4.html

https://snailworks.com/fuj/b-v-f5.html

https://snailworks.com/fuj/b-v-i1.html

https://snailworks.com/fuj/b-v-i2.html

https://snailworks.com/fuj/b-v-i3.html

https://snailworks.com/fuj/b-v-i4.html

https://snailworks.com/fuj/b-v-i5.html

https://snailworks.com/fuj/b-v-u1.html

https://snailworks.com/fuj/b-v-u2.html

https://snailworks.com/fuj/b-v-u3.html

http://www.uscm.at/atp/t-v-j1.html

http://www.uscm.at/atp/t-v-j2.html

http://www.uscm.at/atp/t-v-j3.html

http://www.uscm.at/atp/t-v-j4.html

http://www.uscm.at/atp/t-v-j5.html

http://www.uscm.at/atp/t-v-j6.html

https://snailworks.com/fuj/t-v-m1.html

https://snailworks.com/fuj/t-v-m2.html

https://snailworks.com/fuj/t-v-m3.html

https://snailworks.com/fuj/t-v-m4.html

https://snailworks.com/fuj/t-v-n1.html

https://snailworks.com/fuj/t-v-n2.html

https://snailworks.com/fuj/t-v-n3.html

https://snailworks.com/fuj/t-v-n4.html

https://snailworks.com/fuj/t-v-n5.html

https://snailworks.com/fuj/t-v-n6.html

https://snailworks.com/fuj/t-v-n7.html

https://snailworks.com/fuj/t-v-n8.html

https://snailworks.com/fuj/t-v-o1.html

https://snailworks.com/fuj/t-v-o2.html

https://snailworks.com/fuj/t-v-o3.html

https://snailworks.com/dox/m-v-a1.html

https://snailworks.com/dox/m-v-a2.html

https://snailworks.com/dox/m-v-a3.html

https://snailworks.com/dox/m-v-b1.html

https://snailworks.com/dox/m-v-b2.html

https://snailworks.com/dox/m-v-g1.html

https://snailworks.com/dox/m-v-g2.html

https://snailworks.com/dox/m-v-k1.html

https://snailworks.com/dox/m-v-k2.html

https://snailworks.com/dox/m-v-p1.html

https://snailworks.com/dox/m-v-p2.html

https://snailworks.com/dox/m-v-t1.html

https://snailworks.com/dox/m-v-t2.html

https://snailworks.com/dox/p-v-e1.html

https://snailworks.com/dox/p-v-e2.html

https://snailworks.com/dox/p-v-e3.html

https://snailworks.com/dox/f-v-j1.html

https://snailworks.com/dox/f-v-j2.html

https://snailworks.com/dox/f-v-j3.html

https://snailworks.com/dox/f-v-j4.html

http://www.uscm.at/atp/f-v-j1.html

http://www.uscm.at/atp/f-v-j2.html

http://www.uscm.at/atp/f-v-j3.html

http://www.uscm.at/atp/f-v-j4.html

https://snailworks.com/fuj/g-v-s1.html

https://snailworks.com/fuj/g-v-s2.html

https://snailworks.com/fuj/g-v-s3.html

https://snailworks.com/fuj/g-v-s4.html

https://snailworks.com/fuj/g-v-s5.html

https://snailworks.com/fuj/g-v-s6.html

https://snailworks.com/fuj/g-v-s7.html

https://snailworks.com/fuj/g-v-s8.html

https://snailworks.com/fuj/g-v-s9.html

https://snailworks.com/fuj/g-v-s10.html

https://snailworks.com/fuj/g-v-s11.html

https://snailworks.com/fuj/g-v-s12.html

https://snailworks.com/fuj/g-v-s13.html

https://snailworks.com/fuj/g-v-s14.html

https://snailworks.com/fuj/g-v-s15.html

https://snailworks.com/fuj/g-v-s16.html

https://snailworks.com/fuj/g-v-s17.html

https://snailworks.com/fuj/g-v-s18.html

https://snailworks.com/dox/p-v-d1.html

https://snailworks.com/dox/p-v-d2.html

https://snailworks.com/dox/p-v-d3.html

https://snailworks.com/dox/p-v-d4.html

https://snailworks.com/dox/p-v-d5.html

https://snailworks.com/dox/p-v-d6.html

🚀 Escaping the YouTube algorithm

I love watching YouTube videos that improve my life in some tangible way. Unfortunately, the YouTube algorithm doesn’t agree. It likes to feed me clickbait and other garbage.

This isn’t all that surprising. The algorithm prioritises clicks and watch time.

So I set out on a mission: Can I write code that will automatically find me valuable videos, eliminating my dependence on the YouTube algorithm?

Here’s how it went.

🗺️ The best laid plans

I started by visualising what I wanted the tool to do. I wanted something that would (i) rank videos based on likely relevance for me and (ii) automatically send me suggested videos, which I could select from.

I figured I could make some major productivity gains if I could batch-decide the videos I was going to watch each week and eliminate infinity scrolling YouTube browsing.

I knew I’d need the YouTube API to get video information (what’s an API?). I’d then create a formula which processed that information to rank videos. For the final step, I planned to set up an automated email to myself using AWS Lambda, which would list the top-ranked videos.

That’s not exactly how it ended up, though.

(If you want to skip the story and see the final code, click here.)

⛵️ Navigating the YouTube API

I wanted to find metrics that I could use to rank videos in terms of their likely interest to me.

I read through YouTube’s documentation here and saw that you can get information at the level of videos (title, when published, how many views, the thumbnail, etc) and at the channel level (number of subscribers, comments, views, channel playlists, etc).

Seeing this, I was pretty confident I could use this to define a metric and rank videos.

I obtained an API key through the developer console here and copied it into my Python script.

This enables you to initialise an API call and retrieve results with the following lines of code: